Hello,

I use Tapestry 3.0.3 + hibernate extended Session pattern described here
http://hibernate.org/43.html. Everything goes ok until session is not
invalidated first time (both by application server or by direct calling of
invalidate() method)


If application server perform httpSession.invalidate() at the method
doFilter from class HibernateThreadExtendedFilter on 'finally' section
marked line throws exception:

finally {
                log.error("Cleanup after exception!");
 
                // Cleanup
                log.debug("Closing and unbinding Session from thread");
                sf.getCurrentSession().close(); // Unbind is automatic here
 
                log.debug("Removing Session from HttpSession");

                httpSession.setAttribute(HIBERNATE_SESSION_KEY, null);
<<<<<<<<<<<<<<< removeAttribute: Can't do it because session already
invalidated!

 

            }
 
            // Let others handle it... maybe another interceptor for
exceptions?
            throw new ServletException(ex);
        }
 
    }

 

After that I have a trouble with restoring transaction even if new
conversation has been started. Here is my log. I've done
httpSession.invalidate() (logout in my app), then I try to login again.

==============================================================start
log====================================================

135032 ERROR company.name.app.util.HibernateThreadExtendedFilter :
removeAttribute: Session already invalidated   <<<< finally section after
logout

450344 DEBUG company.name.app.util.HibernateThreadExtendedFilter : >>> New
conversation                           <<< try to log in again.

450344 DEBUG company.name.app.util.HibernateThreadExtendedFilter : Starting
a database transaction

450344 DEBUG company.name.app.util.ExtendedThreadLocalSessionContext :
Opening a new Session

450344 DEBUG company.name.app.util.ExtendedThreadLocalSessionContext :
Disabling automatic flushing of the Session

450407 DEBUG company.name.app.util.HibernateThreadExtendedFilter :
Committing database transaction

450407 DEBUG company.name.app.util.HibernateThreadExtendedFilter : Unbinding
Session from thread

450407 DEBUG company.name.app.util.HibernateThreadExtendedFilter : Storing
Session in the HttpSession

450407 DEBUG company.name.app.util.HibernateThreadExtendedFilter : >
Returning to user in conversation

468985 DEBUG company.name.app.util.HibernateThreadExtendedFilter : <
Continuing conversation

468985 DEBUG company.name.app.util.HibernateThreadExtendedFilter : Starting
a database transaction

org.hibernate.HibernateException: createCriteria is not valid without active
transaction

      at
org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper
.invoke(ThreadLocalSessionContext.java:289)

      at $Proxy0.createCriteria(Unknown Source)

      at
company.name.app.dao.hibernate.GenericDAOHibernate.findByCriteria(GenericDAO
Hibernate.java:106)

      at
company.name.app.dao.hibernate.GenericDAOHibernate.findAll(GenericDAOHiberna
te.java:77)

==============================================================finish
log====================================================

 

Could somebody tell me what might be the reason of such application
behavior? Is it possible to make transaction restore with the session?

 

Thanks in advance,

 

Andrey

Reply via email to