1 Reply Latest reply on Feb 2, 2005 6:19 AM by null null

    HibernateContext

    null null Newbie

      Hello

      I am trying to get the hibernate session to flush automatically before a
      JTA transaction commit. The HibernateContext class seems to be the perfect match for that.

      I encountered some problems however:

      In the case of nested JTA transactions (RequiresNew), the HibernateContext creates a new session for the nested transaction. This leads to hibernate complaining about collections that belong to multiple sessions etc... An alternative implementation could use one session for
      both the surrounding and the nested transaction, but then the session would be unusable (stale) as soon as the nested transaction gets rolled back. Not ideal either.. Should i conclude that running nested transactions within one hibernate session is just not a good idea ?
      FlushMode.NEVER is not respected. The HibernateContext will always flush the session before a commit, even is the FlushMode is NEVER. I guess that's a bug.
      CachedConnectionManager is not liking it. When using the HibernateContext, the CachedConnectionManager is logging lot's of "Trying to return an unknown connection2" warnings (with full stacktrace), even with the debug flag set to false. Should i just disable the whole cachedconnectionmanager ? Will this have any impact on jboss performance ?

      Thanks,
      Koen

      Win2000
      Jboss4.0.1
      Jdk5.0

        • 1. A log file showing unwanted logging in CachedConnectionManag
          null null Newbie

          I enabled the tracing on org.jboss.resource and org.jboss.hibernate.
          The log file reflects a simple hibernate operation (transaction already active). Jboss first generates an IllegalStateException and then gives another warning that it closed a connection for me.


          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [HibernateContext] No session bound; generating
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [TransactionSynch] Preparing synch [name=java:/hibernate/SessionFactory, session=net.sf.hibernat
          e.impl.SessionImpl@441371]
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] subject: null
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] getManagedConnection trackByTx=true tx=TransactionImpl:XidImpl[FormatId=25
          7, GlobalId=beantn0019495/179, BranchQual=, localId=179]
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [JBossManagedConnectionPool] supplying ManagedConnection from pool: org.jboss.resource.connectio
          nmanager.TxConnectionManager$TxConnectionEventListener@b8f675[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@70898b hand
          les=0 lastUse=1107342461952 permit=false trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@5606f3 context=or
          g.jboss.resource.connectionmanager.InternalManagedConnectionPool@1e2793d]
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [JBossManagedConnectionPool] Getting connection from pool org.jboss.resource.connectionmanager.T
          xConnectionManager$TxConnectionEventListener@b8f675[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@70898b handles=0 last
          Use=1107342461952 permit=true trackByTx=true mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@5606f3 context=org.jboss.reso
          urce.connectionmanager.InternalManagedConnectionPool@1e2793d] [InUse/Available/Max]: [1/29/30]
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] enlisting currenttx: TransactionImpl:XidImpl[FormatId=257, GlobalId=beantn
          0019495/179, BranchQual=, localId=179], ManagedConnection: org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@70898b trackByTx=true
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] start, xid: XidImpl[FormatId=257, GlobalId=beantn0019495/179, BranchQual=1
          , localId=179], flags: 0
          12:07:41,952 RMI TCP Connection(7)-138.203.2.97 TRACE [CachedConnectionManager] registering connection from org.jboss.resource.connectionmanager.TxCon
          nectionManager@a99013, connection : org.jboss.resource.adapter.jdbc.WrappedConnection@13f67a9, key: org.jboss.resource.connectionmanager.CachedConnect
          ionManager$KeyConnectionAssociation@1f5e4b6
          12:07:41,962 RMI TCP Connection(7)-138.203.2.97 TRACE [CachedConnectionManager] old stack for key: com.alcatel.ni.datacollection.ejb.ChartGeneratorBea
          n@1b664bb
          12:07:42,012 RMI TCP Connection(7)-138.203.2.97 TRACE [CachedConnectionManager] popped object: org.jboss.resource.connectionmanager.CachedConnectionMa
          nager$KeyConnectionAssociation@1b664bb
          12:07:42,012 RMI TCP Connection(7)-138.203.2.97 TRACE [CachedConnectionManager] old stack for key: com.alcatel.util.ejb.PersisterBean@1ceb670
          12:07:42,022 RMI TCP Connection(7)-138.203.2.97 TRACE [CachedConnectionManager] popped object: org.jboss.resource.connectionmanager.CachedConnectionMa
          nager$KeyConnectionAssociation@1ceb670
          12:07:42,022 RMI TCP Connection(7)-138.203.2.97 TRACE [CachedConnectionManager] popped object: org.jboss.resource.connectionmanager.CachedConnectionMa
          nager$KeyConnectionAssociation@1f5e4b6
          12:07:42,022 RMI TCP Connection(7)-138.203.2.97 TRACE [TransactionSynch] Flushing Session
          12:07:42,022 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] end on xid: XidImpl[FormatId=257, GlobalId=beantn0019495/179, BranchQual=1
          , localId=179] called with flags 67108864
          12:07:42,062 RMI TCP Connection(7)-138.203.2.97 TRACE [TransactionSynch] Closing Session
          12:07:42,062 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] connectionClosed called mc=org.jboss.resource.adapter.jdbc.local.LocalMana
          gedConnection@70898b
          12:07:42,062 RMI TCP Connection(7)-138.203.2.97 TRACE [CachedConnectionManager] unregistering connection from org.jboss.resource.connectionmanager.TxC
          onnectionManager@a99013, object: org.jboss.resource.adapter.jdbc.WrappedConnection@13f67a9, key: org.jboss.resource.connectionmanager.CachedConnection
          Manager$KeyConnectionAssociation@136d1d7
          12:07:42,062 RMI TCP Connection(7)-138.203.2.97 INFO [TxConnectionManager] throwable from unregister connection
          java.lang.IllegalStateException: Trying to return an unknown connection2! org.jboss.resource.adapter.jdbc.WrappedConnection@13f67a9
          at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:374)
          at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionClosed(TxConnectionManager.java:508)
          at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:300)
          at org.jboss.resource.adapter.jdbc.WrappedConnection.close(WrappedConnection.java:116)
          at net.sf.hibernate.connection.DatasourceConnectionProvider.closeConnection(DatasourceConnectionProvider.java:64)
          at net.sf.hibernate.impl.BatcherImpl.closeConnection(BatcherImpl.java:297)
          at net.sf.hibernate.impl.SessionImpl.disconnect(SessionImpl.java:3348)
          at net.sf.hibernate.impl.SessionImpl.close(SessionImpl.java:576)
          at org.jboss.hibernate.session.TransactionSynch.afterCompletion(TransactionSynch.java:71)
          at org.jboss.tm.TransactionImpl.doAfterCompletion(TransactionImpl.java:1418)
          at org.jboss.tm.TransactionImpl.completeTransaction(TransactionImpl.java:1090)
          at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:349)
          at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:454)
          at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:322)
          at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
          at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:123)
          at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
          at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
          at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
          at org.jboss.ejb.Container.invoke(Container.java:870)
          at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
          at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:82)
          at $Proxy171.purgeAllInspections(Unknown Source)
          at com.alcatel.ni.inspectionsystem.InspectionTestUtil.dropInspectionStuff(InspectionTestUtil.java:120)
          at com.alcatel.ni.datacollection.ejb.DataCollectionConfigurationBeanTest.tearDown(DataCollectionConfigurationBeanTest.java:75)
          at junit.framework.TestCase.runBare(TestCase.java:130)
          at net.sourceforge.junitejb.EJBTestCase.runBare(EJBTestCase.java:133)
          at net.sourceforge.junitejb.EJBTestRunnerBean.runTestCase(EJBTestRunnerBean.java:99)
          at net.sourceforge.junitejb.EJBTestRunnerBean.run(EJBTestRunnerBean.java:43)
          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:585)
          at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
          at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
          at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
          at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
          at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
          at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
          at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:153)
          at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
          at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
          at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:123)
          at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
          at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
          at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
          at org.jboss.ejb.Container.invoke(Container.java:870)
          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:585)
          at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
          at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
          at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
          at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
          at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
          at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
          at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
          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:585)
          at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
          at sun.rmi.transport.Transport$1.run(Transport.java:153)
          at java.security.AccessController.doPrivileged(Native Method)
          at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
          at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
          at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
          at java.lang.Thread.run(Thread.java:595)
          12:07:42,072 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] unregisterConnection: 0 handles left
          12:07:42,072 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] isManagedConnectionFree=false mc=org.jboss.resource.adapter.jdbc.local.Loc
          alManagedConnection@70898b
          12:07:42,072 RMI TCP Connection(7)-138.203.2.97 TRACE [JBossManagedConnectionPool] putting ManagedConnection back into pool kill=false cl=org.jboss.re
          source.connectionmanager.TxConnectionManager$TxConnectionEventListener@b8f675[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnec
          tion@70898b handles=0 lastUse=1107342461952 permit=true trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@56
          06f3 context=org.jboss.resource.connectionmanager.InternalManagedConnectionPool@1e2793d]
          12:07:42,072 RMI TCP Connection(7)-138.203.2.97 TRACE [JBossManagedConnectionPool] Returning connection to pool org.jboss.resource.connectionmanager.T
          xConnectionManager$TxConnectionEventListener@b8f675[state=NORMAL mc=org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@70898b handles=0 last
          Use=1107342462072 permit=false trackByTx=false mcp=org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool@5606f3 context=org.jboss.re
          source.connectionmanager.InternalManagedConnectionPool@1e2793d] [InUse/Available/Max]: [0/30/30]
          12:07:42,072 RMI TCP Connection(7)-138.203.2.97 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.r
          esource.adapter.jdbc.WrappedConnection@13f67a9
          12:07:42,072 RMI TCP Connection(7)-138.203.2.97 TRACE [TxConnectionManager] subject: null