users@glassfish.java.net

glassfish v2ur2 and EJB3.0 connection pool bug

From: <glassfish_at_javadesktop.org>
Date: Thu, 19 Jun 2008 02:07:37 PDT

I'm writing about a problem that I discovered using glassfish v2ur2 with netbeans 6.1 and JPA.
RAR7099 (The mcf being used to allocate the connection and the MCF in the pool are not equal)
this is launched when two different ejb containers accessing to different databases on the same DBMS.

an accurate description of the problem is there:
http://javacollassato.wordpress.com/2008/06/15/multiple-enterprise-application-and-jpa-does-not-work-in-netbeans-61/

quickly:
If I launch an EA all works fine.
The problem begin when I "run" the second one: the latter works fine(as
the first before), but now the first doesn't work.

the error is due to the fact that all the two application launches the
query on the same database(the database of the second enterprise
application launched)!

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)

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.

I solved it by hand creation of a new JDBC connection pool related to the second database and manually
inserted this address in the ejb container instead the original one

an accuarate description of my rough solution is available in:
http://javacollassato.wordpress.com/2008/06/18/how-to-run-multiple-enterprise-application-and-jpa-in-netbeans-61/

If someone have a better solution, please contact me.
Do you think that is a glassfish/netbeans bug? (It happens with toplink and hibernate)
if is it, do you think that I have to post the bug to some bug report?
Thank you in advance
[Message sent by forum member 'wka' (wka)]

http://forums.java.net/jive/thread.jspa?messageID=281234