1 Reply Latest reply on Apr 27, 2011 10:22 AM by Hernán Chanfreau

    Exception caught from before_completion synchronization operation: org.hibernate.SessionException: Session is closed!

    santhi_krishna Newbie

      Hello All,

         I am using Spring with Hibernate Envers to insert record into audit tables. When Wicket application (web) calls service, I see Spring uses OpenSessionViewFiler and sets flushmode to Manual. AuditProcess class the following code in doBeforeTransactionCompletion method:

       

           if (FlushMode.isManualFlushMode(session.getFlushMode())) {

       

           IsManual becomes true, then it uses temporary session to insert record into audit tables. It is working fine.

       

       

      We have another application EJB, Spring, Hibernate in WebSphere. When we call the same service from EJB, flushmode becomes AUTO and it fails in AuditProcess class in above mentioned method with the error:

       

      "WTRN0074E: Exception caught from before_completion synchronization operation: org.hibernate.SessionException: Session is closed!"

       

      Please let me know your ideas to resolve this issue:

       

      [4/23/11 17:42:53:582 CDT] 00000023 RegisteredSyn E   WTRN0074E: Exception caught from before_completion synchronization operation: org.hibernate.SessionException: Session is closed!

                at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72)

                at org.hibernate.impl.SessionImpl.contains(SessionImpl.java:1739)

                at org.hibernate.envers.synchronization.AuditProcess.getCurrentRevisionData(AuditProcess.java:125)

                at org.hibernate.envers.synchronization.AuditProcess.executeInSession(AuditProcess.java:104)

                at org.hibernate.envers.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:152)

                at org.hibernate.engine.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:543)

                at org.hibernate.engine.ActionQueue.beforeTransactionCompletion(ActionQueue.java:216)

                at org.hibernate.impl.SessionImpl.beforeTransactionCompletion(SessionImpl.java:571)

                at org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(JDBCContext.java:250)

                at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:125)

                at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51)

                at org.hibernate.transaction.WebSphereExtendedJTATransactionLookup$TransactionManagerAdapter$TransactionAdapter$1.invoke(WebSphereExtendedJTATransactionLookup.java:209)

                at $Proxy44.beforeCompletion(Unknown Source)

                at com.ibm.ws.jtaextensions.SynchronizationCallbackWrapper.beforeCompletion(SynchronizationCallbackWrapper.java:65)

                at com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:242)

                at com.ibm.ws.Transaction.JTA.TransactionImpl.prePrepare(TransactionImpl.java:2408)

                at com.ibm.ws.Transaction.JTA.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:1641)

                at com.ibm.ws.Transaction.JTA.TransactionImpl.processCommit(TransactionImpl.java:1612)

                at com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1547)

                at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:247)

                at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:167)

                at com.ibm.ws.uow.UOWManagerImpl.uowCommit(UOWManagerImpl.java:1055)

                at com.ibm.ws.uow.UOWManagerImpl.uowEnd(UOWManagerImpl.java:1025)

                at com.ibm.ws.uow.UOWManagerImpl.runUnderNewUOW(UOWManagerImpl.java:975)

                at com.ibm.ws.uow.UOWManagerImpl.runUnderUOW(UOWManagerImpl.java:509)

                at org.springframework.transaction.jta.WebSphereUowTransactionManager.execute(WebSphereUowTransactionManager.java:281)

                at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:127)

                at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

                at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)

                at $Proxy66.getAocBufferData(Unknown Source)

                at com.cvscaremark.links.submitorder.SubmitOrderFacade.executeSubmitOrderServices(SubmitOrderFacade.java:59)

                at com.cvscaremark.links.submitorder.SubmitOrderBean.processSubmitOrder(SubmitOrderBean.java:129)

                at com.cvscaremark.links.submitorder.SubmitOrderBean.ejbTimeout(SubmitOrderBean.java:102)

                at com.ibm.ejs.container.TimedObjectWrapper.ejbTimeout(TimedObjectWrapper.java:90)

                at com.ibm.ejs.container.TimerTaskHandler.doWork(TimerTaskHandler.java:265)

                at com.ibm.ws.scheduler.AlarmListener.executeTaskWithNotification(AlarmListener.java:795)

                at com.ibm.ws.scheduler.AlarmListener.access$700(AlarmListener.java:120)

                at com.ibm.ws.scheduler.AlarmListener$TaskWork.doWork(AlarmListener.java:426)

                at com.ibm.ws.scheduler.AlarmListener$TaskWork.run(AlarmListener.java:212)

                at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:782)

                at com.ibm.ws.asynchbeans.ExecutionContextImpl.go(ExecutionContextImpl.java:85)

                at com.ibm.ws.scheduler.AlarmListener.fireTask(AlarmListener.java:1400)

                at com.ibm.ws.scheduler.AlarmListener.fired(AlarmListener.java:1318)

                at com.ibm.ws.asynchbeans.AlarmImpl.callListenerMethod(AlarmImpl.java:338)

                at com.ibm.ws.asynchbeans.timer.GenericTimer.run(GenericTimer.java:216)

                at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:1150)

                at com.ibm.ws.asynchbeans.AlarmImpl.runListenerAsCJWork(AlarmImpl.java:173)

                at com.ibm.ws.asynchbeans.am._Alarm.fireAlarm(_Alarm.java:332)

                at com.ibm.ws.asynchbeans.am._Alarm.run(_Alarm.java:229)

                at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)

       

      Thanks for your help,

      Venkat