users@glassfish.java.net

JPA portability with JNDI names

From: <glassfish_at_javadesktop.org>
Date: Tue, 25 Nov 2008 04:30:20 PST

Hello, I'm developing a JEE application and part of it will be a WAR file containing persistent classes. I'm using JPA and I'm trying to follow the strict standard because my goal is to support both Glassfish and JBoss, however, I'm facing a big problem relating to JNDI names:

I've created a datasource in Glassfish and JBoss named 'jdbc/ds' and I'm trying to link it to my persistence.xml file, however, Glassfish and JBoss uses different schemas for JNDI naming of datasources so Glassfish expects this:

<persistence-unit name="Datas" transaction-type="RESOURCE_LOCAL">
        <non-jta-data-source>jdbc/reminder</non-jta-data-source>
</persistence-unit>

while JBoss expects this:

<persistence-unit name="Datas" transaction-type="RESOURCE_LOCAL">
        <non-jta-data-source>java:jdbc/reminder</non-jta-data-source>
</persistence-unit>

So I would need two persistence.xml files and I need to change them when I'm trying to deploy the war to either JBoss or Glassfish.
Is there a way to have the same file and make Glassfish use the java: naming scheme or make JBoss not require it?
[Message sent by forum member 'getaceres' (getaceres)]

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