I have a Netbeans project, from which I build a .war file. I now deploy two instances of that war file on my glassfish server, each with a different context root, e.g. mydomain.com/abc
and mydomain.com/def
This works fine but they are still operating on the same database, since I declare the persistence unit in the persistence.xml
and the glassfish-resources.xml
.
My glassfish-resources.xml
file:
...
<jdbc-resource enabled="true"
jndi-name="jdbc/abc"
object-type="user"
pool-name="abcPool">
<description/>
</jdbc-resource>
<jdbc-connection-pool
...
name="abcPool"
...
<property name="URL" value="jdbc:mysql://localhost:3306/abc"/>
...
</jdbc-connection-pool>
My persistence.xml
file:
...
<persistence-unit name="abcPU" transaction-type="JTA">
<jta-data-source>jdbc/abc</jta-data-source>
...
</persistence-unit>
...
Does anybody have a solution on how to have two instances of one war file, operating on two different databases?
Is there maybe a way to upload a different glassfish-resources.xml
and persistence.xml
to each application, overwriting the packaged one?
It would be acceptable to change the module descriptors in the glassfish domain admin console once the application is deployed, if that is possible.
If screenshots from the glassfish domain admin console are needed, please write in the comments, I will add them.
Thank you in advance!