Hello everyone,
I have an application (AppAdmin.war) that I
deployed twice to Glassfish. After deployment, I changed the
persistence unit information for one of them so it would point to a
different database. It did not work, however, and the second
deployment still connects to the wrong DB. Below is what I did:
First deployment:
Application name: AppAdmin_Test
Application root: AppAdmin_Test
Second deployment:
Application name: AppAdmin_Prod
Application root: AppAdmin_Prod
After deployment, I modified two files for AppAdmin_Prod
AppAdmin_Prod\WEB-INF\classes\META-INF\persistence.xml
AppAdmin_Prod\WEB-INF\sun-web.xml
Here are the differences in the persistence.xml files:
[b]First deployment AppAdmin_Test):[/b]
<?xml version="1.0" encoding="UTF-8"?>
<persistence
version="1.0" xmlns="[
http://java.sun.com/xml/ns/persistence]"
xmlns:xsi="[
http://www.w3.org/2001/XMLSchema-instance]"
xsi:schemaLocation="[
http://java.sun.com/xml/ns/persistence]
[
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd]">
<persistence-unit name="AppAdmin_Test" transaction-type="JTA">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<jta-data-source>jdbc/AppAdmin_Test</jta-data-source>
<class>com.mycompany.site.entity.ContentFile</class>
<class>com.mycompany.site.entity.Event</class>
<class>com.mycompany.site.entity.Product</class>
<class>com.mycompany.site.entity.Content</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="toplink.ddl-generation" value="create-tables"/>
<property name="[toplink.platform.class.name|
http://toplink.platform.class.name/]" value="oracle.toplink.essentials.platform.database.SQLServerPlatform"/>
</properties>
</persistence-unit>
</persistence>{code}
[b]Second deployment (AppAdmin_Prod):[/b]
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="[
http://java.sun.com/xml/ns/persistence]" xmlns:xsi="[
http://www.w3.org/2001/XMLSchema-instance]" xsi:schemaLocation="[
http://java.sun.com/xml/ns/persistence] [
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd]">
<persistence-unit name="AppAdmin_Prod" transaction-type="JTA">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<jta-data-source>jdbc/AppAdmin_Prod</jta-data-source>
<class>com.mycompany.site.entity.ContentFile</class>
<class>com.mycompany.site.entity.Event</class>
<class>com.mycompany.site.entity.Product</class>
<class>com.mycompany.site.entity.Content</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="toplink.ddl-generation" value="create-tables"/>
<property name="[toplink.platform.class.name|
http://toplink.platform.class.name/]" value="oracle.toplink.essentials.platform.database.SQLServerPlatform"/>
</properties>
</persistence-unit>
</persistence>
The only change I made in sun-web.xml was the context-root (since it was still showing as AppAdmin_Test - does this even matter post deployment?):
<context-root>/AppAdmin_Prod</context-root>
I then restarted the Sun App server, but the persistence unit being used by application AppAdmin_Prod still appears to be using jdbc/AppAdmin_Test.
What am I missing?
[Message sent by forum member 'groverblue' (groverblue)]
http://forums.java.net/jive/thread.jspa?messageID=293398