Friday, October 30, 2015

Hibernate session is closed!

WHAT! The session was closed? Hibernate has closed the shop? No more business?
2015-10-29 12:29:04 ERROR javax.faces.event.MethodExpressionActionListener[180]: org.hibernate.SessionException: Session is closed!
 at org.hibernate.internal.AbstractSessionImpl.errorIfClosed(
 at org.hibernate.internal.SessionImpl.createCriteria(
 at org.huahsin.MyBoImpl.filterBottle(
This is so ridiculous!! May be I have overlooked on this matter. Remember, I have TransactionInterceptor being define in the following way:
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager">
            <ref bean="transactionManager"/>
        <property name="transactionAttributes">
                <prop key="add*">PROPAGATION_REQUIRED</prop>
                <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
Any method defined in the BO/DAO that doesn't start with add or get will expect to see this error. In my case as shown in the stack trace, I have filterBottle() defined in MyBoImpl. To fix this, I'm require to define additional transactionAttributes in TransactionInterceptor.

No comments: