0 Replies Latest reply on Apr 15, 2013 11:05 AM by jpsteck

    container independent datasource jndi name in persistence.xml

    jpsteck

      Hello,

       

      I'm setting up a prototype application that has to be container independent, as far as possible.

      I started with Jboss-as-7.1.1, and now I'm trying to migrate this prototype to Glassfish 3.

       

      First problem I found is the jndi name of the datasource used in my persistence.xml file.

      In JBoss, I have declared a datasource with the jndi name "java:jboss/datasources/MyDS" in standalone.xml. And I use that name "java:jboss/datasources/MyDS" in persistence.xml.

      Now in Glassfish, the declared datasource is "jdbc/MyDS". If I change my persistence.xml to "jdbc/MyDS", everything works.

      But I can't set a jndi name with a ":" in Glassfish, so I have to touch something to the JBoss side.

       

      But how can I use the same persistence.xml file for both application server ?

       

      What I've done is to change the datasource definition in jboss standalone.xml :

      I defined a "java:/jdbc/MyDS" datasource with use-java-context="false"

       

      And now it's working on both JBoss and Glassfish with the same exact persistence.xml file, having the jta-datasource set to "jdbc/MyDS".

       

      My question : is it the right way to achieve this portability ?

      What is the exact consequence of use-java-context=false ? I read that it makes the datasource available to an external client. Does it implies security issues ?

       

      My next step will be to test the portability of using a JMS Queue, and then other app server.

      Has anyone such experience to share about application server portability ?

       

      Thanks

      --JPS