Announcement Announcement Module
Collapse
No announcement yet.
Hibernate session exception - JDBC begin failed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 3.2.3.ga, 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:

    Code:
    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:
    ** BEGIN NESTED EXCEPTION **
    java.net.SocketException
    MESSAGE: Software caused connection abort: recv failed
    STACKTRACE:
    java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(Unknown Source)
    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1910)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2304)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2803)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3118)
    at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5215)
    at org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
    at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
    at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:63)
    at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326)
    at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:510)
    at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:350)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:262)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:102)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
    at org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy1.loadUserByUsername(Unknown Source)
    at org.xxx.util.DaoAuthenticationProvider.getUserFromBackend(DaoAuthenticationProvider.java:396)
    at org.xxx.util.DaoAuthenticationProvider.authenticate(DaoAuthenticationProvider.java:223)
    at org.acegisecurity.providers.ProviderManager.doAuthentication(ProviderManager.java:208)
    at org.acegisecurity.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:49)
    at org.acegisecurity.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:90)
    at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:228)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:220)
    at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
    at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
    at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)
    ** END NESTED EXCEPTION **
    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, 12:58 PM.

    Comment


    • #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.

      Comment


      • #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, 12:57 PM.

        Comment

        Working...
        X