Announcement Announcement Module
No announcement yet.
Hibernate session exception - JDBC begin failed Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate session exception - JDBC begin failed

    Hi, I'm getting a org.hibernate.transaction.JDBCTransaction error due to the db connection going down once my application session expires.
    This has started happening since I upgraded from Spring 1.2.8 to 2.0.5. I am using Hibernate, MySQL 5, Commons DBCP Connection Pooling and the Open Session in View pattern.
    My app starts up and works fine, but if the session expires and I try to access a page, the authentication filters try to access the db which fails when trying to open a new Transaction.

    On my MySQL connection I have added autoreconnect=true which doesn't make a difference, but I think it depends on something to do with the Spring upgrade. After the exception I can reauthenticate and carry on without problems (until the next Session expiry).

    Here is the Stacktrace:

    2007-06-19 09:17:43,920 ERROR [org.hibernate.transaction.JDBCTransaction] - <JDBC begin failed>
    com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
    MESSAGE: Software caused connection abort: recv failed
    STACKTRACE: Software caused connection abort: recv failed
    at Method)
    at Source)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(
    at com.mysql.jdbc.MysqlIO.readFully(
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(
    at com.mysql.jdbc.MysqlIO.sendCommand(
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
    at com.mysql.jdbc.Connection.execSQL(
    at com.mysql.jdbc.Connection.setAutoCommit(
    at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(
    at org.hibernate.transaction.JDBCTransaction.begin(
    at org.hibernate.impl.SessionImpl.beginTransaction(
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
    at org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
    at $Proxy1.loadUserByUsername(Unknown Source)
    at org.acegisecurity.providers.ProviderManager.doAuthentication(
    at org.acegisecurity.AbstractAuthenticationManager.authenticate(
    at org.acegisecurity.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(
    at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
    at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(
    at org.acegisecurity.util.FilterChainProxy.doFilter(
    at org.acegisecurity.util.FilterToBeanProxy.doFilter(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.apache.catalina.core.StandardWrapperValve.invoke(
    at org.apache.catalina.core.StandardContextValve.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke(
    at org.apache.catalina.core.StandardEngineValve.invoke(
    at org.apache.catalina.connector.CoyoteAdapter.service(
    at org.apache.coyote.http11.Http11Processor.process(
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(
    at org.apache.tomcat.util.threads.ThreadPool$
    at Source)
    Last packet sent to the server was 20 ms ago.

  • #2
    What have you actually changed during the upgrade? The exception is obviously generated down in the JDBC driver so that would be the first thing to look at. If you replace the new Spring JAR with the old one does the problem go away?
    Last edited by karldmoore; Aug 29th, 2007, 11:58 AM.


    • #3
      I'm afraid I didn't do much digging, but because the problem was urgent I ended up replacing dbcp with c3po connection pooling, which did the trick. C3PO seems to have more tweaking options, not that I've delved very much into DBCP though. If I get some time I'll try and figure out which upgrade exactly caused the change in default behaviour to drop the connection when the session expires. Replacing the Spring jar is not quite that simple, as it involves a series of dependencies with their relative jar files.


      • #4
        The move to c3p0 seems to be quite a common thing, we did the same thing on the last project and I've read quite a few threads from other's who've done the same thing.
        Last edited by karldmoore; Aug 29th, 2007, 11:57 AM.