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