how to run multiple enterprise application and JPA in Netbeans 6.1

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!

Advertisement

3 Responses to how to run multiple enterprise application and JPA in Netbeans 6.1

  1. Milton Moura says:

    An easier fix for this is by changing your “sun-resources.xml” file “Source Resources” in NetBeans the following way:

    This way, glassfish will automatically create your JDBC pool upon deployment, thus solving your problem.

  2. Milton Moura says:

    Seems the code in my latest comment was escaped. I wrote:

    An easier fix for this is by changing your “sun-resources.xml” file “Source Resources” in NetBeans the following way:

    <jdbc-resource enabled=”true” jndi-name=”MY_JNDI_NAME” object-type=”user” pool-name=”MY_POOL_NAME”/>
    <jdbc-connection-pool … name=”MY_POOL_NAME” … >

    This way, glassfish will automatically create your JDBC pool upon deployment.

  3. javacollassato says:

    thank you Milton

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.