7 Replies Latest reply: Mar 19, 2012 4:49 AM by David Wery RSS

«Session is closed!» again, Hibernate 3.5.3-Final, Spring 3.0.0 and WebSphere 6.1

Igor Sakovich Newbie

Subject: «Session is closed!», again, Hibernate 3.5.3-Final, Spring 3.0.0 and WebSphere 6.1

 

First of all i want to give thanks for Envers. Great product. But, i can't get it working under WebShpere.

 

I assume that problem is somewhere in transaction configuration, but i can't figure out what the problem is.

 

I have configured AuditEventListener in eventListeners property of AnnotationConfigurationSessionBean, as suggested in http://stackoverflow.com/questions/1647894/does-hibernatetemplate-work-with-envers-if-so-how. Now it works in unittests and throw «Session is closed!» under WebSphere. I'm using Spring 3.0.0, Hibernate 3.5.3-Final and WebSphere 6.1.

 

I think problem is somewhere in transaction configuration but i can't figure out where.

I'm using declarative transction management via Spring AOP proxies.

Sessin factory bean, auditEventListener and transaction manager in spring context:

 

    <bean id="sessionFactory"

          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

        <property name="dataSource" ref="dataSource" />

 

        <property name="hibernateProperties">

            <props>

                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>

                <prop key="session_factory_name">hibernate/session_factory</prop>

                <prop key="hibernate.cache.use_second_level_cache">false</prop>

                <prop key="hibernate.cache.use_query_cache">false</prop>

                <prop key="hibernate.bytecode.use_reflection_optimizer">false</prop>

                <prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>

                <prop key="hibernate.query.substitutions">yes='Y', no='N'</prop>

                <prop key="hibernate.show_sql">true</prop>

                <prop key="hibernate.connection.release_mode">after_statement</prop>

                <prop key="hibernate.transaction.flush_before_completion">true</prop>

                <prop key="hibernate.transaction.auto_close_session">true</prop>

                <prop key="hibernate.current_session_context_class">jta</prop>

                <prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</prop>

                <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>

                <prop key="jta.UserTransaction">java:comp/UserTransaction</prop>

            </props>

        </property>

 

        <property name="eventListeners">

            <map>

                <entry key="post-insert" value-ref="auditEventListener" />

                <entry key="post-update" value-ref="auditEventListener" />

                <entry key="post-delete" value-ref="auditEventListener" />

                <entry key="pre-collection-update" value-ref="auditEventListener" />

                <entry key="pre-collection-remove" value-ref="auditEventListener" />

                <entry key="post-collection-recreate" value-ref="auditEventListener" />

            </map>

        </property>

    </bean>

 

    <bean id="auditEventListener" class="org.hibernate.envers.event.AuditEventListener">

    </bean>

 

    <bean id="transactionManager"

          class="org.springframework.transaction.jta.WebSphereUowTransactionManager">

    </bean>

 

Stack trace of root cause:

 

Caused by org.hibernate.SessionException with message: "Session is closed!"

 

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

org.hibernate.impl.SessionImpl.contains(SessionImpl.java:1729)

org.hibernate.envers.synchronization.AuditProcess.getCurrentRevisionData(AuditProcess.java:123)

org.hibernate.envers.synchronization.AuditProcess.executeInSession(AuditProcess.java:102)

org.hibernate.envers.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:150)

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

org.hibernate.engine.ActionQueue.beforeTransactionCompletion(ActionQueue.java:211)

org.hibernate.impl.SessionImpl.beforeTransactionCompletion(SessionImpl.java:563)

org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(JDBCContext.java:229)

org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:90)

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

$Proxy1535.beforeCompletion(Unknown Source)

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

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

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

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

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

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

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

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

com.ibm.ws.Transaction.JTA.UserTransactionImpl.commit(UserTransactionImpl.java:293)

org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:52)

org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:613)

org.jboss.seam.jsf.SeamPhaseListener.commitOrRollback(SeamPhaseListener.java:604)

org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsAfterPhase(SeamPhaseListener.java:345)

org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:245)

org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)

com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)

com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)

com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)