Announcement Announcement Module
No announcement yet.
Deploying Spring Applications Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deploying Spring Applications

    Not sure if this is the right place to post this. Might be nice to have a seperate section to discuss deployment issues.

    Anyway, here's my question...

    So if I have multiple Spring webapps (WARs) that need to be deployed accessing the same set of Spring services, what is the best way to do that? Do each of these wars need to be packaged up into an EAR? My guess is that packaging as an EAR would work. But how would you indicate to the app server to start the services? This might be different for each app server. What about servers such as tomcat that don't support the EAR deployment model?

  • #2
    I'm not sure of the "right" way (probably .ear is the right way), but I am currently taking the quick and dirty approach. It is rather ugly, but gets the job done and really simplifies things for me - though I doubt this would be an option in many cases. Basically, I'm packaging up all my web applications into a single .war. I'm creating one big web.xml that encapsulates all the web applications. I have an Ant build that "merges" .wars - creating a destination .war that is a composite of all the src .war's web.xml files and pages. In my case, I am simply creating subfolders off of the destination .war root folder for each src .war. So, if I have a "humanresources.war", all of its web pages are placed in /humanresources/*" in the destination war - while everything under its WEB-INF is merged with the destination .war's /WEB-INF folder.


    • #3
      Here's where JNDI becomes useful. AFAIK the biggest scope in webapps is Application. There is no scope that is System. If you want to share an application context holding services and business beans among multiple webapps (IMHO a decent goal) then you could write a small services only webapp that merely starts up and loads the AppContext into JNDI.

      There probably is a way to then make that AppContext a parent of your particular webapp contexts. That way you can avoid the JNDI calls in your code and still use injection.

      So the question I now have is: Can I use a AppContext found in JNDI as the parent for a local ApplicationContext?


      • #4
        I do not see why not.

        Two things you would have to implement the logic of binding the configured ApplicationContext into global JNDI context; this I think will be container dependent.

        After that you would need to rewrite ContextLoader in org.springframework.web.context pacakge to force it return the JNDI bound ApplicationContext as a parent of your root WebApplicationContext instead of null as it returns now. Then provide your own ContextLoader<Servlet|Listener> to actually use your version ContextLoader

        This is just some outline, but it seems like a doable thing