1 Reply Latest reply on Jul 7, 2010 10:54 AM by jaikiran

    How to package a persistent archive for use in JBoss and Tomcat standalone

    gonne

      Hi all,

       

      I am trying to build a persistent archive (Hibernate 3.5 as JPA provider) containing entities that should be usable in different applications.

       

      My first use case is a web application running in a standalone Tomcat 5.5 environment. The JNDI reference to the datasource in the persistence.xml for that environment must be relative to the JNDI ENC, e.g.:

       

      {code:xml}<jta-data-source>java:/comp/env/jdbc/MyDatabase</jta-data-source>{code}

       

      My other use case is an enterprise application for JBoss 6. The JNDI reference to the database in my JBoss deployment is e.g. java:/MyDatabase

      If I use the persistent archive with the same persistence.xml as in my first use case the datasource can not be found.

       

      How can I override the reference to the datasource without changing the persistent archive?

      Or is it possible to create a link in JNDI?

       

      I tried to remove the persistence.xml from the persistent archive (located in ear/lib) and created a new persistence.xml in my ear referencing the persistent archive by using the jar-file element and the datasource java:/MyDatabase. That works in JBoss 6, but I do not know how to deploy that in Tomcat 5.5. The corresponding method by usign the jar-file element does only work in Tomcat by using an absolute path for the persistent archive what I do not prefer.

       

      Can anyone help?

       

      Thanks,

      Gonne