1 Reply Latest reply on Dec 16, 2009 4:44 AM by Al Green

    Tomcat RESOURCE_LOCAL multiple datasources: exception invoking getTransaction()

    rosdorff Newbie

      Hello,


      I am using multiple datasources with Tomcat. Without embedded jBoss I understand I'll have to use RESOURCE LOCAL. The application starts up fine. But when opening a page I get exceptions invoking getTransaction
      With only one datasource all was fine.
      Can somebody give a hint?


      Code persistence-war.xml:


      <persistence-unit name="unit1" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:comp/env/jdbc/datasource1</jta-data-source>
      </persistence-unit>
      <persistence-unit name="unit2" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:comp/env/jdbc/datasource2</jta-data-source>
      </persistence-unit>




      Code components.xml:


      <persistence:managed-persistence-context name="em1" entity-manager-factory="#{factory1}"/>
      <persistence:entity-manager-factory name="factory1" persistence-unit-name="unit1"/>
      <transaction:entity-transaction name="entityTransaction1" entity-manager="#{em1}" />
      
      <persistence:managed-persistence-context name="em2" entity-manager-factory="#{factory2}"/>
      <persistence:entity-manager-factory name="factory2" persistence-unit-name="unit2"/>
      <transaction:entity-transaction name="entityTransaction2" entity-manager="#{em2}" />




      Excerpts from stacktrace:


      2009.04.22 10:59:58 [WARN ] line 199 org.jboss.seam.jsf.SeamPhaseListener
          uncaught exception, passing to exception handler
      java.lang.IllegalStateException: Could not commit transaction
      
      Caused by: java.lang.RuntimeException: exception invoking: getTransaction
      
      Caused by: javax.naming.NamingException: Cannot create resource instance
              at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)
      
      2009.04.22 10:59:58 [ERROR] line 335 org.jboss.seam.contexts.Contexts
          could not discover transaction status
      2009.04.22 10:59:58 [ERROR] line 128 org.jboss.seam.jsf.SeamPhaseListener
          swallowing exception
      java.lang.RuntimeException: exception invoking: getTransaction