You can deploy the same WAR file multiple times with different names/context roots to accomplish what you want. You would need to do something like having the application look at its name/context root to load a different set of properties or use a different data source name to connect to the different database, but that is very straight forward.
Note that this does in fact deploy the same code twice though. If you want only a single deploy but to use multiple backend databases, you may just need to make your app multi-tenant and have the logic in your code to connect to different databases based on the user.
From: Blake McBride <blake_at_arahant.com<mailto:blake_at_arahant.com>>
Reply-To: "users_at_glassfish.java.net<mailto:users_at_glassfish.java.net>" <users_at_glassfish.java.net<mailto:users_at_glassfish.java.net>>
Date: Tue, 16 Apr 2013 14:38:13 -0700
To: "users_at_glassfish.java.net<mailto:users_at_glassfish.java.net>" <users_at_glassfish.java.net<mailto:users_at_glassfish.java.net>>
Subject: Can I run multiple instances of one application
Greetings,
I have a web application that connects to a single database and serves X number of simultaneous users without a problem.
I would like to start up another instance of the same application that would connect to a different database and serve Y simultaneous users from a different URL.
If this is possible with glassfish, presumably it would be able to use a single copy of the code base with independent and isolated data spaces.
All the applications instances (for now) would be run on the same machine.
I know I can just copy the application code, reconfigure for another database, and boot it as a separate application. The point is not have to have multiple copies of the application on the disk or in memory. The only things different between the instances would be the database it points to, the URL to access it, and the memory it takes to support the runtime data.
I need this because the application is very large (15,000+ classes). I want to achieve the ability of creating many independent instances running without the need to have multiple copies of the code both on disk and in memory.
Thanks.
Blake McBride