Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:32:57+00:00 2026-05-28T19:32:57+00:00

I’m building a Clojure Noir web application to run as a WAR file in

  • 0

I’m building a Clojure Noir web application to run as a WAR file in CloudFoundry.

In my project.clj I have:

:ring {:handler appname.server/handler}

In server.clj I create a handler using Noir:

(def handler (noir.server/gen-handler {:ns 'appname}))

I build the WAR file using a lein ring plugin:

lein ring uberwar

Then push to CloudFoundry using:

vmc push appname

The request handler works fine and I can browse to the URL of the application just fine.

So the question is: what is the correct way to do initialization when the application is started?

I can do the following in server.clj:

(when (System/getenv "VCAP_APPLICATION")
  (init-func))

But there are a couple problems with that. First, it seems like that is doing the initialization at the wrong time (when the code is read/eval’d rather than on app start). Second, the protector is specific to CloudFoundry and I certain there is a proper general WAR way to do this.

I think this is the purpose of the contextInitialized method on the ServletContextListener but how do I hook that in with Noir/ring?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:32:59+00:00Added an answer on May 28, 2026 at 7:32 pm

    Figured it out by looking at ring source for WAR handling

    The project.clj :ring map takes an :init keyword like so:

    :ring {:init appname.server/my-init
           :handler appname.server/handler}
    

    The my-init function will be called on application startup.

    Caveat: this apparently balloons the amount of memory needed by the application for initial startup. 128M was sufficient without the initialization. With the initialization code , the app startup failed, so I had to bump the memory to 256M. I suspect that with the init code the JVM doesn’t have time to garbage collect before the Clojure code is compiled/executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a reasonable size flat file database of text documents mostly saved in
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.