2 Replies Latest reply on Aug 28, 2010 8:57 AM by fidox666

    Could not enlist in transaction on entering meta-aware object! (PostgreSQL + SQLite))

    fidox666

      Hello everyone, this might be repeated question, but i cant find a solution for my problem, i'm using:

       

      * jboss: 5.1.0.GA

      * java: 1.6.0_20

      * postgres: 8.3.11

      * sqlite: 3.5.9

       

      I want to access two different data sources from a single ejb class (one for sqlite and other for postgres) using two different Entity Managers, first make a query for an object to the first em (postgres) and then save a new object to the second pm using this information. After doing the first query I get this exception:


       

      =========================================================================

       

      10:01:52,665 WARN  [loggerI18N] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] [com.arjuna.ats.internal.jta.transaction.arjunacore.lastResource.disallow] Adding multiple last resources is disallowed. Current resource is org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource@14db297
      10:01:52,677 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: null
      10:01:52,677 ERROR [JDBCExceptionReporter] Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000101:92ed:4c6bd97a:206 status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: 7f000101:92ed:4c6bd97a:206 status: ActionStatus.ABORT_ONLY >))
      10:01:52,702 ERROR [TxPolicy] javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection
      10:01:52,714 ERROR [TimerImpl] Error invoking ejbTimeout
      javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.GenericJDBCException: Cannot open connection
      at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:115)
      at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:194)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:176)
      at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:216)
      at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
      at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
      at $Proxy493.getArticlebyName(Unknown Source)
      at com.act.ejb.ArticleManagerTimer.execute(ArticleManagerTimer.java:241)

       

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
      at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
      at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
      at sun.reflect.GeneratedMethodAccessor272.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
      at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_30960050.invoke(InvocationContextInterceptor_z_fillMethod_30960050.java)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
      at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_30960050.invoke(InvocationContextInterceptor_z_setup_30960050.java)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:80)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
      at org.jboss.ejb3.stateless.StatelessContainer.callTimeout(StatelessContainer.java:249)
      at org.jboss.as.ejb3.timerservice.TimedObjectInvokerBridge.callTimeout(TimedObjectInvokerBridge.java:44)
      at org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run(TimerImpl.java:561)
      at java.util.TimerThread.mainLoop(Timer.java:512)
      at java.util.TimerThread.run(Timer.java:462)
      ==========================================================================

       

      I try to increase the transaction timeout on the EJB but nothing happens.

       

      This is my data source file:

       

      ==========================================================================

       


       

      <datasources>


      <!-- Postgresql -->

      <local-tx-datasource>

      <jndi-name>Postgres1DS</jndi-name>

      <connection-url>jdbc:postgresql://localhost:5432/db0</connection-url>

      <driver-class>org.postgresql.Driver</driver-class>

      <user-name>user1</user-name>

      <password>u1pass</password>

      </local-tx-datasource>


      <!-- SQLite -->

      <local-tx-datasource>

      <jndi-name>Sqlite1DS</jndi-name>

      <connection-url>jdbc:sqlite:${jboss.server.data.dir}${/}db1.db</connection-url>

      <driver-class>org.sqlite.JDBC</driver-class>

      <user-name>user1</user-name>

      <password>u1pass</password>

      <connection-property name="autoReconnect">true</connection-property>

      </local-tx-datasource>


      </datasources>

       

       

      ==========================================================================

       

       

       

       

      Can someone please help me out with this?

       

      Thanks in advance,

       

       

      Fido

        • 1. Re: Could not enlist in transaction on entering meta-aware object! (Posgres + SQLite))
          rvaler22

          Did you get to solve your problem?

          I have the exact error except that I use a postgres and a mysql datasource.

          • 2. Re: Could not enlist in transaction on entering meta-aware object! (PostgreSQL + SQLite))
            fidox666

            I solve the problem as follows:

             

            (1) Data source type "local-tx-datasource" does not support multiple data sources (sqlite and postgresql concurrent transactions). The solution here is to change the type of data source from "local-tx-datasource"  to  "xa-datasource".

             

            (2) Also sqlite does not support "xa-datasource" type (specifically the problem with sqlite was that I could not find an sqlite implementation of the class "rg.postgresql.xa.PGXADataSource", (*) maybe you can find one for mysql ), so I change the second data source database from sqlite to postgresql.

             

             

            This is my "old" data source file:

             

            <datasources>

            <!-- Postgresql -->

            <local-tx-datasource>

            <jndi-name>Postgres1DS</jndi-name>

            <connection-url>jdbc:postgresql://localhost:5432/db0</connection-url>

            <driver-class>org.postgresql.Driver</driver-class>

            <user-name>user1</user-name>

            <password>u1pass</password>

            </local-tx-datasource>


            <!-- SQLite -->

            <local-tx-datasource>

            <jndi-name>Sqlite1DS</jndi-name>

            <connection-url>jdbc:sqlite:${jboss.server.data.dir}${/}db1.db</connection-url>

            <driver-class>org.sqlite.JDBC</driver-class>

            <user-name>user1</user-name>

            <password>u1pass</password>

            <connection-property name="autoReconnect">true</connection-property>

            </local-tx-datasource>

            </datasources>

             

             

            And this is the "new one":

             

            <datasources>

            <!-- Postgresql -->

               <xa-datasource>

            <jndi-name>Postgres1DS</jndi-name>

                   <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                   <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
                   <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
                   <xa-datasource-property name="DatabaseName">db0</xa-datasource-property>
                   <xa-datasource-property name="User">user1</xa-datasource-property>
                   <xa-datasource-property name="Password">u1pass</xa-datasource-property>
                   <track-connection-by-tx></track-connection-by-tx>
            </xa-datasource>


            <!-- Postgresql -->

             

             

             

             

                <xa-datasource>

                   <jndi-name>Postgres2DS</jndi-name>

                   <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>

             

             

             

                   <xa-datasource-property name="ServerName">localhost</xa-datasource-property>

             

                   <xa-datasource-property name="PortNumber">5432</xa-datasource-property>

                   <xa-datasource-property name="DatabaseName">db1</xa-datasource-property>

                   <xa-datasource-property name="User">user1</xa-datasource-property>

                   <xa-datasource-property name="Password">u1pass</xa-datasource-property>

                   <track-connection-by-tx></track-connection-by-tx>

            </xa-datasource>

            </datasources>


             

             

            So.. what I suggest you is to change the type of your data sources from "local-tx-datasource" to "xa-datasource", as I say (*).. you must to find a mysql implementation of the class "xa-datasource-class", and finally if you can not found this class, you should change the mysql database to postgresql.

             

            I hope I have been clear enough, if you find another point of view for this problem please let me know, sorry for my poor english.

             

            Best regards..
            Fido.