休眠会话无法打开事务

休眠会话无法打开事务

本文介绍了休眠会话无法打开事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我有关下面的异常情况。我每天尝试登录几次就会得到这个异常。但经过一些尝试后,第二天它又来了。



以下是例外:

例外

 > org.springframework.web.util.NestedServletException:请求
>处理失败;嵌套异常是
> org.springframework.transaction.CannotCreateTransactionException:
>无法打开Hibernate Session进行事务处理;嵌套异常是
> org.hibernate.TransactionException:JDBC开始失败:
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)root
>导致
>
> org.springframework.transaction.CannotCreateTransactionException:
>无法打开Hibernate Session进行事务处理;嵌套异常是
> org.hibernate.TransactionException:JDBC开始失败:
> org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:596)
> org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
> org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
> $ Proxy48.loginUser(未知来源)
> com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> java.lang.reflect.Method.invoke(Method.java:616)
> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)root
>导致
>
> org.hibernate.TransactionException:JDBC开始失败:
> org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:96)
> org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
> org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
> org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
> org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
> $ Proxy48.loginUser(未知来源)
> com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> java.lang.reflect.Method.invoke(Method.java:616)
> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)root
>导致
>
> com.mysql.jdbc.CommunicationsException:通信链接失败
>由于潜在的例外:
>
> ** BEGIN嵌套异常**
>
> java.io.EOFException
>
> STACKTRACE:
>
>在
处的java.io.EOFException> com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1963)at
> com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2375)at
> com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)at
> com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)at
> com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)at
> com.mysql.jdbc.Connection.execSQL(Connection.java:3243)at
> com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5371)at
> org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
>在
> org.apache.commons.dbcp.PoolingDataSource $ PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
>在
> org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:91)
>在
> org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
>在
> org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
>在
> org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
>在
> org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
>在
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
>在
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>在
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
> at $ Proxy48.loginUser(Unknown Source)at
> com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)at sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at
> java.lang.reflect.Method.invoke(Method.java:616) org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
>在
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
>在
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
>在
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
>在
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
>在
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
>在
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
>在javax.servlet.http.HttpServlet.service(HttpServlet.java:637)at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>在
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>在
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>在
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>在
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>在
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>在
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>在
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>在
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
>在
> org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:588)
>在
> org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489)
>在java.lang.Thread.run(Thread.java:679)
>
>
> **结束性异常**
>
>
>
>发送到服务器的最后一个数据包是1毫秒前。
> com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2586)
> com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
> com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
> com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
> com.mysql.jdbc.Connection.execSQL(Connection.java:3243)
> com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5371)
> org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
> org.apache.commons.dbcp.PoolingDataSource $ PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
> org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:91)
> org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
> org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
> org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
> org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
> $ Proxy48.loginUser(未知来源)
> com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> java.lang.reflect.Method.invoke(Method.java:616)
> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


解决方案 div>

这是一个迟到的答案,但是,我面临同样的问题。这是由于c3po的配置不当造成的。



$ c>< bean id =dataSourceclass =com.mchange.v2.c3p0.ComboPooledDataSourcedestroy-method =close>
< property name =driverClassvalue =$ {jdbc.driverClassName}/>
< property name =jdbcUrlvalue =$ {jdbc.url}/>
< property name =uservalue =$ {jdbc.username}/>
< property name =passwordvalue =$ {jdbc.password}/>

< property name =checkoutTimeoutvalue =30000/>
< property name =idleConnectionTestPeriodvalue =30/>
< property name =initialPoolSizevalue =10/>
< property name =maxIdleTimevalue =30/>
< property name =maxPoolSizevalue =100/>
< property name =minPoolSizevalue =10/>
< property name =maxStatementsvalue =10/>


Can some one tell about the following exception.I am getting this exception every day once i try to login for few times.but after some attempts it gone and next day it comes again.

Following is the Exception:

exception

> org.springframework.web.util.NestedServletException: Request
> processing failed; nested exception is
> org.springframework.transaction.CannotCreateTransactionException:
> Could not open Hibernate Session for transaction; nested exception is
> org.hibernate.TransactionException: JDBC begin failed:
>   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
>   org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root
> cause
>
> org.springframework.transaction.CannotCreateTransactionException:
> Could not open Hibernate Session for transaction; nested exception is
> org.hibernate.TransactionException: JDBC begin failed:
>   org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:596)
>   org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
>   org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
>   org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
>   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>   $Proxy48.loginUser(Unknown Source)
>   com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)     sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)
>   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   java.lang.reflect.Method.invoke(Method.java:616)
>   org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
>   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
>   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
>   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
>   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
>   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
>   org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root
> cause
>
> org.hibernate.TransactionException: JDBC begin failed:
>   org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:96)
>   org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
>   org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
>   org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
>   org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
>   org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
>   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>   $Proxy48.loginUser(Unknown Source)
>   com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)     sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)
>   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   java.lang.reflect.Method.invoke(Method.java:616)
>   org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
>   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
>   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
>   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
>   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
>   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
>   org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:717) root
> cause
>
> com.mysql.jdbc.CommunicationsException: Communications link failure
> due to underlying exception:
>
> ** BEGIN NESTED EXCEPTION **
>
> java.io.EOFException
>
> STACKTRACE:
>
> java.io.EOFException  at
> com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1963)   at
> com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2375)  at
> com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)    at
> com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)     at
> com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)  at
> com.mysql.jdbc.Connection.execSQL(Connection.java:3243)   at
> com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5371)     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:91)
>   at
> org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
>   at
> org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
>   at
> org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
>   at
> org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
>   at
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
>   at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>   at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>   at $Proxy48.loginUser(Unknown Source)   at
> com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)   at sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)    at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:616)     at
> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
>   at
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
>   at
> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
>   at
> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
>   at
> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
>   at
> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
>   at
> org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)     at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)  at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>   at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>   at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>   at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>   at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>   at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>   at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>   at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>   at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
>   at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
>   at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>   at java.lang.Thread.run(Thread.java:679)
>
>
> ** END NESTED EXCEPTION **
>
>
>
> Last packet sent to the server was 1 ms ago.
>   com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2586)
>   com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2874)
>   com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
>   com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1715)
>   com.mysql.jdbc.Connection.execSQL(Connection.java:3243)
>   com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5371)
>   org.apache.commons.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:331)
>   org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:317)
>   org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:91)
>   org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
>   org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
>   org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
>   org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
>   org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
>   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>   $Proxy48.loginUser(Unknown Source)
>   com.sapat.competition_tracker.controller.AdminController.userLogin(AdminController.java:59)     sun.reflect.GeneratedMethodAccessor510.invoke(Unknown Source)
>   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   java.lang.reflect.Method.invoke(Method.java:616)
>   org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
>   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:427)
>   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:415)
>   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
>   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
>   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
>   org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
>   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
解决方案

This is a late answer but, I had faced same issue. It's due to improper configuration for c3po.

Please use below c3po configuration:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <property name="driverClass" value="${jdbc.driverClassName}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />

        <property name="checkoutTimeout" value="30000" />
        <property name="idleConnectionTestPeriod" value="30"/>
        <property name="initialPoolSize" value="10" />
        <property name="maxIdleTime" value="30" />
        <property name="maxPoolSize" value="100" />
        <property name="minPoolSize" value="10" />
        <property name="maxStatements" value="10" />

</bean

这篇关于休眠会话无法打开事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 03:43