how to run multiple enterprise application and JPA in Netbeans 6.1

June 18, 2008

In my previous post I wrote about problem that happens when two different enterprise application (or better ejb modules) use different JPAs.

problem scope

I discovered that this problem happens when two or more JPA access to the same DBMS (I found this problem in postgres, mysql and derby)

problem description

The problem is related to the connection pool used by the persistence unit:

in both  ServerResources/sun-resources.xml  files has been wrote  the same connection pool:

<jdbc-resource enabled=”true” jndi-name=”EA1_dataSource” object-type=”user” pool-name=”derby_netPool”/>

<jdbc-resource enabled=”true” jndi-name=”dataSource_EA2″ object-type=”user” pool-name=”derby_netPool”/>

each time an enterprise application is ran he overwrites the bound database, in this way the EA launched before fails, because she tries to access to a database with another structure than the one expected.

how to solve it

the screenshot below shown the connection pool shared by the two EA

It’s easy understand that is related only to VIR database

1) I created a new JDBC connection pool (derby_netPool2) using the same general settings provided by the original one

2) In the second step I inserted the data provided into ServerResources/sun-resources.xml file of the EA related to TRAVEL database

3) I manually substitute derby_netPool2 to derby_netPool in the ServerResources/sun-resources.xml file of the EA related to TRAVEL database

4) clear and build – run EA1 – run EA2

all EAs work properly!


Follow

Get every new post delivered to your Inbox.