1 Reply Latest reply on Feb 26, 2009 10:47 AM by Peter Johnson

    Multiple instances from single EAR/WAR

    Dave Sunerton-Burl Newbie

      I have a requirement to be able to create multiple instances of the same application on a single server under difference context roots. Additionally, each instance of the application will need to be configurable. At this stage, the only difference between the instances would be the datasource used i.e. there will be multiple identical web applications, each accessing data from a different database. There will be upwards of 50 instances, so this is essentially a maintenance issue - I don't want 50 copies of the same application code/pages when the only difference is the database connection.

      The application in question is built using Seam and there is likely to be other instance-specific configuration needed - but I figure that I can store any other configuration information in the database and have the Seam application respond accordingly.

      I've seen this done before with a web application in Tomcat - JSPWiki - where there is only one WAR file on the server but you can easily add instances pointing to different configurations, so I'm sure it ought to be relatively easy. I just can't find out how in JBoss at the moment.

      Any pointers gratefully received!

        • 1. Re: Multiple instances from single EAR/WAR
          Peter Johnson Master

          Here are some issues I can think of (other than those you already mentioned like supplying unique contexts), off the top of my head:

          1) You will have to ascertain that the JNDI names for your EJBs (and anything else that needs JNDI names, such as the data source) are unique between the apps. This should not be an issue for the EJBs if you go with the default jndi naming convention of ear-name/ejb-name/local (or ../remote)
          [Note that this item has the built-in assumption that you will have to rename the EAR file for each app...]

          2) Each app will have to adjust how it looks up EJBs to use up the correct "ear-name" section of the JNDI name. This could be done via a properties file.

          3) You will have to configure a loader repository for each app - this will keep the classloaders separate and ensure proper scoping of the classes (each ear gets its own copy of the classes)

          4) You will need a *-ds.xml file for each app, each with its own custom JNDI name and the app will have to be configured to use the new name. Given that you are using Seam, I am not sure if there are mechanisms to programmatically alter the Hibernate/JPA configuration or if you will have to modify the persistence.xml file before deploying. (If you use Ant to deploy, you could modify the persistence.xml file at deploy time. Considering that you already have to modify the application.xml file to supply a unique context, this might not be all that big of a hardship.)

          Those are the things I can think of. But it is usually the unforeseen issues that end up getting to you.

          Good luck!