8 Replies Latest reply on May 22, 2006 11:48 AM by Emmanuel Bernard

    could not register synchronization with JTA TransactionManag

    blalls asdsd Novice

      All of s sudden I am getting this error message:

      17:29:04,349 ERROR [STDERR] org.hibernate.TransactionException: could not register synchronization with JTA TransactionManager
      



        • 2. Re: could not register synchronization with JTA TransactionM
          Robert DeNiro Newbie

          Hi Bill,

          I am using jboss version jboss-4.0.4.GA and am experiencing the JTA synchronization problem. Was this bug to be fixed in jboss-4.0.4.GA?

          Thanks

          Robert

          • 4. Re: could not register synchronization with JTA TransactionM
            Robert DeNiro Newbie

            Hi Emmanuel,

            We are running a web application with JBoss 4.0.4.GA. We are not
            using EJBs, just a WAR. Some of the processes in the web application
            run for over 5 minutes and depending on the number of users may timeout,
            as TransactionTimeout is set to 300 in server/default/conf/jboss-service.xml.

            Here's is some of the stack trace after a transaction timeout

            org.hibernate.exception.GenericJDBCException: Cannot open connection
            at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
            at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
            at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
            at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
            at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:363)
            at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)

            .
            .

            Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=abc.local/99, BranchQual=, localId=99]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=abc.local/99, BranchQual=, localId=99])
            at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:79)
            at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
            at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)

            2006-05-09 12:31:55,769 http-0.0.0.0-8090-4 INFO am.write(LoggerStream.java:140) - org.hibernate.TransactionException: could not register synchronization with JTA TransactionManager
            at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:160)
            at org.hibernate.jdbc.JDBCContext.(JDBCContext.java:79)
            at org.hibernate.impl.SessionImpl.(SessionImpl.java:266)
            at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:436)
            at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:460)

            Caused by: javax.transaction.RollbackException: Already marked for rollback TransactionImpl:XidImpl[FormatId=257, GlobalId=abc.local/99, BranchQual=, localId=99]
            at org.jboss.tm.TransactionImpl.registerSynchronization(TransactionImpl.java:617)
            at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:149)
            ... 33 more
            2006-05-09 12:31:55,770 http-0.0.0.0-8090-4 ERROR tSession(HibernateUtil.java:29) - [HibernateUtil] caught while trying to get session
            org.hibernate.TransactionException: could not register synchronization with JTA TransactionManager
            at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:160)
            at org.hibernate.jdbc.JDBCContext.(JDBCContext.java:79)
            at org.hibernate.impl.SessionImpl.(SessionImpl.java:266)
            at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:436)
            at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:460)
            at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:468)


            It seems that once a transaction times out we can no longer use the session factory.

            Thanks

            Robert

            • 5. Re: could not register synchronization with JTA TransactionM
              Emmanuel Bernard Master

              Are you usre you use the latest version and do not override the hibernate transaction factory? The Default JoinableCMTTransactionFactory should not behave like this.

              • 6. Re: could not register synchronization with JTA TransactionM
                Emmanuel Bernard Master

                you also must stop using the entity manager when an exception occurs

                • 7. Re: could not register synchronization with JTA TransactionM
                  Edmond Nolan Newbie

                  Hi Emmanuel,

                  Thank you for your reply. I'm not sure if we are inadvertently overriding the hibernate transaction factory. We have an EAR which contains a .har file and a .war file. We use JNDI to obtain the session factory. The .har file contains the hibernate.cfg.xml which contains:

                  <hibernate-configuration>
                  <session-factory name="java:comp/env/hibernate/SessionFactory">
                  java:jdbc/ourJNDIName
                  org.hibernate.connection.DatasourceConnectionProvider
                  org.hibernate.transaction.JTATransactionFactory
                  org.hibernate.transaction.JBossTransactionManagerLookup

                  .
                  .
                  </session-factory>
                  </hibernate-configuration>

                  Is the session factory name here important?

                  You mentioned that the entity manager should no longer be used when an exception occurs, how can I do that?

                  Thanks again,

                  Robert

                  • 8. Re: could not register synchronization with JTA TransactionM
                    Emmanuel Bernard Master

                    You are not using the entity manager at all here. A har means an Hibernate Session, not an EJB3 EntityManager