5 Replies Latest reply on May 5, 2002 1:49 AM by davidjencks

    error while using datasource

    mattbaird

      If anyone can help me with this, that would be great. I had this working with RC1, and now when I upgraded to RC2 I had to rewrite (tweek, actually) my service.xml files for my datasources, now I get this error message:


      java.sql.SQLException: Connection handle is not currently associated with a ManagedConnection

      is the error message. Here's my service.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- ===================================================================== -->
      <!-- -->
      <!-- JBoss Server Configuration -->
      <!-- -->
      <!-- ===================================================================== -->


      <!--TransactionDSRealm-->
      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->

      <!--real attributes-->


      <config-property>
      <config-property-name>ConnectionURL</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>jdbc:inetdae:localhost:1433?database=Motiva8&amp;sql7=true&amp;useCursorsAlways=true</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>DriverClass</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>com.inet.tds.TdsDriver</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>UserName</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>daytona</config-property-value>
      </config-property>
      <config-property>
      <config-property-name>Password</config-property-name>
      <config-property-type>java.lang.String</config-property-type>
      <config-property-value>ce</config-property-value>
      </config-property>


      SQLServerDS
      <!--hack-->
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper



      <depends optional-attribute-name="ManagedConnectionPool">
      <!--embedded mbean-->


      0
      50
      5000
      15
      <!--criteria indicates if Subject (from security domain) or app supplied
      parameters (such as from getConnection(user, pw)) are used to distinguish
      connections in the pool. Choices are
      ByContainerAndApplication (use both),
      ByContainer (use Subject),
      ByApplication (use app supplied params only),
      ByNothing (all connections are equivalent, usually if adapter supports
      reauthentication)-->
      ByContainer



      <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
      <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:name=JaasSecurityManager
      java:/TransactionManager
      jboss.jca:service=RARDeployer



        • 1. Re: error while using datasource
          mattbaird

          one more thing, and this is the wierd thing. It's not happening all the time. I'm bulk inserting into a DB and this will happen not on every insert....

          • 2. Re: error while using datasource
            mattbaird

            additional information in the stack trace:
            13:51:34,694 INFO [STDOUT] [ojb.broker.accesslayer.StatementsForClass] ERROR:
            13:51:34,694 INFO [STDOUT] Connection handle is not currently associated with a ManagedConnection
            13:51:34,694 ERROR [STDERR] java.sql.SQLException: Connection handle is not currently associated with a ManagedConnection
            13:51:34,694 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.local.LocalConnection.checkStatus(LocalConnection.java:774)
            13:51:34,694 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.local.LocalConnection.prepareStatement(LocalConnection.java:210)
            13:51:34,704 ERROR [STDERR] at ojb.broker.accesslayer.StatementsForClass.prepareStatement(StatementsForClass.java:377)
            13:51:34,704 ERROR [STDERR] at ojb.broker.accesslayer.StatementsForClass.getDeleteStmt(StatementsForClass.java:565)
            13:51:34,704 ERROR [STDERR] at ojb.broker.accesslayer.StatementManager.getDeleteStatement(StatementManager.java:807)
            13:51:34,704 ERROR [STDERR] at ojb.broker.accesslayer.JdbcAccess.executeDelete(JdbcAccess.java:108)
            13:51:34,704 ERROR [STDERR] at ojb.broker.singlevm.PersistenceBrokerImpl.delete(PersistenceBrokerImpl.java:157)
            13:51:34,704 ERROR [STDERR] at ojb.odmg.states.StateOldDelete.commit(StateOldDelete.java:223)
            13:51:34,704 ERROR [STDERR] at ojb.odmg.ObjectEnvelopeTable.commit(ObjectEnvelopeTable.java:211)
            13:51:34,704 ERROR [STDERR] at ojb.odmg.TransactionImpl.doCommit(TransactionImpl.java:407)
            13:51:34,704 ERROR [STDERR] at ojb.odmg.TransactionImpl.commit(TransactionImpl.java:707)
            13:51:34,704 ERROR [STDERR] at ojb.connector.ODMGLocalTransaction.commit(ODMGLocalTransaction.java:62)
            13:51:34,704 ERROR [STDERR] at org.jboss.resource.connectionmanager.LocalTxConnectionManager$LocalConnectionEventListener.commit(LocalTxConnection
            Manager.java:554)
            13:51:34,704 ERROR [STDERR] at org.jboss.tm.TxCapsule.commitResources(TxCapsule.java:1656)
            13:51:34,704 ERROR [STDERR] at org.jboss.tm.TxCapsule.commit(TxCapsule.java:377)
            13:51:34,704 ERROR [STDERR] at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:76)
            13:51:34,704 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:190)
            13:51:34,704 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
            13:51:34,704 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
            13:51:34,704 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
            13:51:34,704 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
            13:51:34,704 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:706)
            13:51:34,704 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
            13:51:34,704 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364)
            13:51:34,704 ERROR [STDERR] at java.lang.reflect.Method.invoke(Native Method)
            13:51:34,704 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
            13:51:34,704 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:152)
            13:51:34,704 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
            13:51:34,704 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
            13:51:34,714 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
            13:51:34,714 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
            13:51:34,714 ERROR [STDERR] at java.lang.Thread.run(Thread.java:484)
            13:51:34,714 INFO [STDOUT] [ojb.broker.ta.PersistenceBrokerJ2EEImpl] ERROR:
            13:51:34,714 INFO [STDOUT] Error in Transaction abort: Connection handle is not currently associated with a ManagedConnection
            13:51:34,714 WARN [TxCapsule] XAException: tx=XidImpl [FormatId=257, GlobalId=PLWRK88//430, BranchQual=] errorCode=XA_UNKNOWN(0)
            javax.transaction.xa.XAException: could not commit local txjavax.resource.ResourceException: Intern transaction was aborted
            at org.jboss.resource.connectionmanager.LocalTxConnectionManager$LocalConnectionEventListener.commit(LocalTxConnectionManager.java:563)
            at org.jboss.tm.TxCapsule.commitResources(TxCapsule.java:1656)
            at org.jboss.tm.TxCapsule.commit(TxCapsule.java:377)
            at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:76)
            at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:190)
            at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:129)
            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)
            at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:313)
            at org.jboss.ejb.Container.invoke(Container.java:706)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:491)
            at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364)
            at java.lang.reflect.Method.invoke(Native Method)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
            at sun.rmi.transport.Transport$1.run(Transport.java:152)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:148)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
            at java.lang.Thread.run(Thread.java:484)
            13:51:35,855 INFO [STDOUT] remove(Class clazz, Object identity)

            • 3. Re: error while using datasource
              davidjencks

              You need to do your cache flush from a synchronization beforeCommit call. By the time commit is called from the tx manager it is too late.

              • 4. Re: error while using datasource
                mattbaird

                Hi David,

                Thanks for the speedy reply. I'm not sure what you mean by this "You need to do your cache flush from a synchronization beforeCommit call".

                Is this behavior that changed from RC1 to RC2? This all worked 100% of the time in RC1.

                this part makes me wonder:13:51:34,714 WARN [TxCapsule] XAException: tx=XidImpl [FormatId=257, GlobalId=PLWRK88//430, BranchQual=] errorCode=XA_UNKNOWN(0)
                javax.transaction.xa.XAException: could not commit local txjavax.resource.ResourceException: Intern transaction was aborted

                The Datasource (as you can see from the service.xml) is declared for local transactions:


                not XA transactions. Is there something wierd going on there?

                • 5. Re: error while using datasource
                  davidjencks

                  I don't know why you are getting errors now and not in rc1. It may have something to do with using the change from the minerva wrapper to the new local tx wrapper I wrote.

                  In my opinion you should be getting this error 100% of the time.

                  You also aren't telling the whole story, since the trace shows commit being called on something that leads to an ojb class, not the MSSQL driver you showed the config for.

                  If you are trying to jca-ify ojb, I strongly suggest you do it in the way suggested by the jdo spec and jca spec:
                  for each transaction the jdo implementation detects, register a synchronization with the tx manager.
                  On the before completion call, flush the cached data for that tx to the underlying resource adapter.

                  Unless you want to take over tx management and pooling on the underlying db connections, I do not suggest trying to make the jdo implementation itself be a jca adapter.

                  Your current implementation is also not possible to use with an xa database. You would have to do the flush on prepare, not commit. The db must guarantee being able to commit after a successful prepare.