6 Replies Latest reply on Nov 7, 2011 2:22 PM by Scott Marlow

    Hibernate Session is Closed!

    dev0 Newbie

      Hi

       

      I am trying to migrate a simple service from JBoss 5.1.0.GA to 7.0.2.Final I am however experiencing some strange problems with my Hibernate session.

       

       

      Below is a very simple reproduction of the problem - involving a Service and a Dao.

       

       

      The second time I invoke the service an exception is thrown (The session is closed).

       

       

      I am starting the AS using the following command:

       

       

      .\standalone.bat --server-config=standalone-preview.xml

       

       

       

       

      @Stateless
      @WebService
      public class DaoTestService {
      
      
                @EJB
                TestDao testDao;
        
                @WebMethod
                public void testDao() {
                          System.out.println("USING Dao: " + testDao.getClass() + "@" + testDao.hashCode());
                          testDao.getAll();
                }
      }
      

       

       

       

       

      @Stateless
      public class TestDao {
        
                @PersistenceContext
                protected Session session; 
        
                public List<Tenant> getAll() {
                          System.out.println("USING Session: " + session.getClass() + "@" + session.hashCode());
                          System.out.println("session.isOpen() = " + session.isOpen());
        
                          Criteria criteria = session.createCriteria(Tenant.class);
        
                          return criteria.list();
                }
      }
      

       

      From the server.log

       

       

      4:23:36,825 INFO  [stdout] (http--127.0.0.1-8080-1) USING Dao: class com.company.dao.impl.TestDao$$$view6@280380
      
      
      14:23:36,863 INFO  [stdout] (http--127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@17534882
      
      
      14:23:36,864 INFO  [stdout] (http--127.0.0.1-8080-1) session.isOpen() = true
      
      
      14:23:36,894 INFO  [stdout] (http--127.0.0.1-8080-1) Hibernate: select this_.id as id3_0_, this_.address as address3_0_, this_.address2 as address3_3_0_, this_.city as city3_0_, this_.country as country3_0_, this_.name as name3_0_, this_.sequenceNumber as sequence7_3_0_, this_.state as state3_0_, this_.zip as zip3_0_ from Tenant this_
      
      
      14:23:40,014 INFO  [stdout] (http--127.0.0.1-8080-1) USING Dao: class com.company.dao.impl.TestDao$$$view6@280380
      
      
      14:23:40,015 INFO  [stdout] (http--127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@17534882
      
      
      14:23:40,016 INFO  [stdout] (http--127.0.0.1-8080-1) session.isOpen() = false
      
      
      14:23:40,016 ERROR [org.jboss.as.ejb3.tx.CMTTxInterceptor] (http--127.0.0.1-8080-1) javax.ejb.EJBTransactionRolledbackException: Session is closed!
      14:23:40,017 ERROR [org.jboss.as.webservices.invocation.InvocationHandlerEJB3] (http--127.0.0.1-8080-1) Method invocation failed with exception: Session is closed!: javax.ejb.EJBTransactionRolledbackException: Session is closed!
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:133) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:196) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:286) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:182) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
                at com.company.dao.impl.TestDao$$$view6.getAll(Unknown Source) [BridgeDataModel-1.0-SNAPSHOT.jar:]
                at com.company.services.impl.DaoTestService.testDao(DaoTestService.java:20) [ServiceManagementBridge-1.0-SNAPSHOT.jar:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_17]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_17]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_17]
                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_17]
                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:50) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:211) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:284) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:182) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:71) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.webservices.invocation.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:130)
                at org.jboss.wsf.stack.cxf.JBossWSInvoker._invokeInternal(JBossWSInvoker.java:169)
                at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:117)
                at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) [cxf-rt-core-2.4.0.jar:]
                at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [:1.6.0_17]
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [:1.6.0_17]
                at java.util.concurrent.FutureTask.run(FutureTask.java:138) [:1.6.0_17]
                at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37) [cxf-rt-core-2.4.0.jar:]
                at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106) [cxf-rt-core-2.4.0.jar:]
                at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) [cxf-api-2.4.0.jar:]
                at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118) [cxf-rt-core-2.4.0.jar:]
                at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208) [cxf-rt-transports-http-2.4.0.jar:]
                at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:91)
                at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:162)
                at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)
                at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184) [cxf-rt-transports-http-2.4.0.jar:]
                at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:107) [cxf-rt-transports-http-2.4.0.jar:]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
                at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)
                at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:138) [jbossws-spi-2.0.0.Beta7.jar:2.0.0.Beta7]
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139)
                at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)
                at java.lang.Thread.run(Thread.java:619) [:1.6.0_17]
      Caused by: org.hibernate.SessionException: Session is closed!
                at org.hibernate.internal.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:126)
                at org.hibernate.internal.SessionImpl.createCriteria(SessionImpl.java:1423)
                at com.company.dao.impl.TestDao.getAll(TestDao.java:23) [BridgeDataModel-1.0-SNAPSHOT.jar:]
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_17]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_17]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_17]
                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_17]
                at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45) [jboss-as-jpa-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:50) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287) [jboss-invocation-1.1.0.Final.jar:1.1.0.Final]
                at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed(SessionInvocationContextInterceptor.java:126) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:194) [jboss-as-ejb3-7.0.2.Final.jar:7.0.2.Final]
                ... 76 more
      
        • 1. Re: Hibernate Session is Closed!
          Scott Marlow Master

          That sounds like a bug to me.  Your in a JTA transaction but the underlying Hibernate session is getting closed.  Thats not good.  Could you create a (JPA) jira https://issues.jboss.org/browse/AS7 for this.

           

          As a workaround, you could use a SessionFactory and control when the session is closed.

           

          Thanks for reporting this.

           

          Scott

          • 2. Re: Hibernate Session is Closed!
            Scott Marlow Master

            When you create the jira, please link to it here so others can follow.  Also, include the full package name for the Session class.

            • 3. Re: Hibernate Session is Closed!
              dev0 Newbie

              I have created a jira, and attached a simple ready-to-deploy maven project plus the full server.log.

               

              https://issues.jboss.org/browse/AS7-2433

              • 4. Re: Hibernate Session is Closed!
                Scott Marlow Master

                I'm making a few internal changes to how we inject from a PersistenceContext into a Hibernate Session.  The web service invocation is looking better (the session is staying open for each invocation).

                00:03:25,240 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:25,300 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:25,301 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) session.isOpen() = true

                00:03:25,456 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:03:31,847 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:31,848 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:31,848 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:03:31,849 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:03:42,084 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:42,086 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:42,086 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:03:42,087 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:03:42,971 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:42,971 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:42,971 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:03:42,972 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:03:43,613 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:43,614 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:43,614 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:03:43,615 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:03:44,302 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:44,302 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:44,302 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:03:44,303 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:03:44,883 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:44,884 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:44,884 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:03:44,885 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:03:45,583 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:03:45,584 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:03:45,584 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:03:45,585 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:04:27,115 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:04:27,115 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:04:27,115 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:04:27,116 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                00:04:27,975 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Dao: class com.somecompany.TestDao$$$view2@522272322

                00:04:27,975 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) USING Session: class org.hibernate.internal.SessionImpl@1470195146

                00:04:27,975 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) session.isOpen() = true

                00:04:27,976 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-1) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                • 5. Re: Hibernate Session is Closed!
                  Scott Marlow Master

                  Injecting persistence context into Hibernate sessions is working correctly on my branch now (both extended persistence context and transaction scoped entity managers). 

                   

                  Output from standalone test is now:

                  08:44:48,064 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Dao: class com.somecompany.TestDao$$$view2@29073669

                  08:44:48,138 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Session: class $Proxy43@629920590

                  08:44:48,138 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) session.isOpen() = true

                  08:44:48,331 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                  08:44:49,496 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Dao: class com.somecompany.TestDao$$$view2@29073669

                  08:44:49,497 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Session: class $Proxy43@1327112367

                  08:44:49,497 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) session.isOpen() = true

                  08:44:49,498 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                  08:44:51,612 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Dao: class com.somecompany.TestDao$$$view2@29073669

                  08:44:51,613 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) USING Session: class $Proxy43@937024954

                  08:44:51,613 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) session.isOpen() = true

                  08:44:51,614 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-3) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                  08:44:52,352 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-2) USING Dao: class com.somecompany.TestDao$$$view2@29073669

                  08:44:52,353 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-2) USING Session: class $Proxy43@465001913

                  08:44:52,353 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-2) session.isOpen() = true

                  08:44:52,354 INFO  [stdout] (http-smarlowpc.localdomain-127.0.0.1-8080-2) Hibernate: select this_.id as id0_0_ from SomeEntity this_

                  • 6. Re: Hibernate Session is Closed!
                    Scott Marlow Master

                    The fix is checked in and the nightly build is available here http://community.jboss.org/thread/167590.  Let me know if you get a chance to try it.

                     

                    Thanks again for reporting the issue and providing a test case!  :-)