3 Replies Latest reply on Jun 30, 2007 12:19 PM by mtedone1

    Multiple persistence units (one JTA one RESOURCE_LOCAL) fail

    mtedone1

      Hi, I created a persistence.xml file with the definition of two persistence units: one with JTA (for EE components) and one with RESOURCE_LOCAL (for JUnit testing). When deploying the application fails saying that I didn't define a non-jta-data-source for the RESOURCE_LOCAL, but the fact is that since this p.u is for JUnit I didn't define a datasource at all, but just properties to connect to the database.

      This issue deemed to be already resolved in 4.2.0-CR2, as stated here:

      http://jira.jboss.com/jira/browse/EJBTHREE-433

      However I'm running 4.2.0-GA and it's still there.

        • 1. Re: Multiple persistence units (one JTA one RESOURCE_LOCAL)
          mtedone1

          Any news on this one?

          • 2. Re: Multiple persistence units (one JTA one RESOURCE_LOCAL)
            bmcgovern

            Mtedone1, I don't have an answer for you, but can you post your xml regarding JTA, I cannot get JTA working right on 4.2.0. Specifically I cannot seem to lookup TransactionManager from JNDI. I can get UserTransaction from JNDI, but when I do, the expected Transactional behavior simply doesn't work. THe system operates like there is no transaction running and i get partial commits.

            Using UserTransaction I get a warning in the logs, but not an error : JTA cannot find TransactionManager, JTA will not be able to syncronize with existing JTA transactions.

            So I think the root cause is something with JNDI and TransactionManger. Please paste your configs.

            Thanks.

            • 3. Re: Multiple persistence units (one JTA one RESOURCE_LOCAL)
              mtedone1

               

              <?xml version="1.0" encoding="UTF-8"?>
              <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
              
              
               <persistence-unit name="jemos-ejb3-test" transaction-type="JTA">
               <provider>org.hibernate.ejb.HibernatePersistence</provider>
               <jta-data-source>java:/JemosTestDS</jta-data-source>
               <properties>
               <property name="hibernate.hbm2ddl.auto" value="update"/>
               <property name="hibernate.show_sql" value="true" />
               </properties>
               </persistence-unit>
              
              
               <persistence-unit name="jemos-ejb3-test-junit" transaction-type="RESOURCE_LOCAL">
               <provider>org.hibernate.ejb.HibernatePersistence</provider>
               <class>uk.co.jemos.ejb3.entities.Employee</class>
               <properties>
               <property name="hibernate.hbm2ddl.auto" value="update"/>
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
               <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
               <property name="hibernate.connection.username" value="user"/>
               <property name="hibernate.connection.password" value="password"/>
               <property name="hibernate.connection.url" value="jdbc:mysql://localhost/test"/>
               </properties>
               </persistence-unit>
              
              </persistence>