I'm using a single TomEE instance to deploy 2 Webapplications. Both applications use a different database and different entities.
Application 2 is integrated into Application 1, so I need both the schema anytime while running.
I have both DataSources
configured in the tomee.xml
like this:
<tomee>
<Resource id="testDBPool" type="DataSource">
jdbcDriver = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost:3306/testDB"
username = "admin"
password = "admin"
</Resource>
</tomee>
<tomee>
<Resource id="testDBPool2" type="DataSource">
jdbcDriver = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost:3306/testDB2"
username = "admin"
password = "admin"
</Resource>
</tomee>
In Application 1 I use this persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="testDBPool" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/testDBPool</jta-data-source>
</persistence-unit>
</persistence>
In Application 2 I use this persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="testDBPool2" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/testDBPool2</jta-data-source>
</persistence-unit>
</persistence>
When I tried to run application then it is throwing testDB.table1 is not exist
, whereas actually the table1
exist in testDB2
schema not in testDB
, I do not understand why it is pointing to wrong schema?