Results 1 to 4 of 4

Thread: Deploying Spring Applications

  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    229

    Default

    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. #3
    Join Date
    Aug 2004
    Location
    Hawaii, US
    Posts
    225

    Default

    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. #4
    Join Date
    Aug 2004
    Posts
    109

    Default

    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
    Thanks,
    Alex.

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 2
    Last Post: Oct 24th, 2005, 07:52 AM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Spring: useful for J2EE. not so useful for J2SE?
    By Edward Kenworthy in forum Container
    Replies: 2
    Last Post: Nov 2nd, 2004, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •