'Invalid transaction state' in HttpSessionListener with dist
greyfairer Feb 23, 2006 12:15 PMHi all,
We are developing a web application that needs to track when a user logs out, or when it's session times out, so we wrote an HttpSessionListener that uses Hibernate to update a login record when the authentication attribute is removed from the HttpSession. This works in a non-clustered environment.
Then we wanted to make this work in a load-balancing/failover cluster., so we marked the web.xml distributable, and configured the JBoss cluster. The session failover works fine, e.g. when we shut down one cluster, the user's session was still active at the second cluster.
The HttpSessionListener didn't work anymore with 'distributable', even if there was only one cluster node active: it gets an 'invalid transaction state' when trying to get a JDBC connection from the local firebird DataSource. Stack trace follows below.
I crossposted this to the firebird people, too (http://groups.yahoo.com/group/Firebird-Java/message/8353). Error 25S01 seems to mean 'invalid transaction state'.
What does the ClusteredSession expiration have to do with my transactions? The cluster is still up and running, only one user's session is expiring...
Used versions: JBoss 4.0.3sp1, hibernate 3.0.5, spring 1.2.6, firebirdsql.rar 1.5.5.
2006-02-22 17:08:50,640 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[www.acme.com].[/server]] standardSession.attributeEvent org.springframework.transaction.CannotCreateTransactionException:Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionException: JDBC begin failed: org.hibernate.TransactionException: JDBC begin failed: at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:58) at org.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:24) at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:271) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1079) at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:520) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:282) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:111) at com.acme.utils.AbstractHibernateTransactionRunnable.run(AbstractHibernateTransactionRunnable.java:53) at com.acme.webctrl.AcegiApplicationListener.timeoutEvent(AcegiApplicationListener.java:44) at com.acme.webctrl.J2EEWebAppListener.attributeRemoved(J2EEWebAppListener.java:59) at org.jboss.web.tomcat.tc5.session.ClusteredSession.removeAttributeInternal(ClusteredSession.java:558) at org.jboss.web.tomcat.tc5.session.ClusteredSession.expire(ClusteredSession.java:418) at org.jboss.web.tomcat.tc5.session.ClusteredSession.expire(ClusteredSession.java:345) at org.apache.catalina.session.StandardSession.isValid(StandardSession.java:567) at org.jboss.web.tomcat.tc5.session.JBossCacheManager.processExpires(JBossCacheManager.java:683) at org.jboss.web.tomcat.tc5.session.JBossManager.backgroundProcess(JBossManager.java:662) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1283) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1568) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1577) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1557) at java.lang.Thread.run(Thread.java:595) Caused by: org.firebirdsql.jdbc.FBSQLException: Resource Exception. No local transaction active: can't commit, error code: 25S01 at org.firebirdsql.jdbc.AbstractConnection.setAutoCommit(AbstractConnection.java:328) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:53)