I have a Java web application leveraging JPA. The database instance is specified in the persistence.xml
file using the jta-data-source
tag.
I would like to deploy a second copy of the web application on the same (glassfish) server, but pointed at a different database instance.
What is the best way to achieve this? I think ideally, I'd like to place a persistence.xml
override file outside of the war (somewhere on the classpath?). I'm not exactly sure where to put it or how to define it in a way that it wouldn't confilt with my other instance. I can see us hosting a handful of instances in this manner (SaaS) and I'd like the configuration to be outside the deployed war so that it wouldn't become a maintenance issue. Sharing a database instance between clients is not an option for security reasons.
I'm sure this isn't a unique problem to our group. What are the best practices or solutions others are using to solve this problem?