복붙노트

[SPRING] 최대 절전 세션 트랜잭션을 열 수 없습니다.

SPRING

최대 절전 세션 트랜잭션을 열 수 없습니다.

어떤 사람은 다음과 같은 예외에 대해 말할 수 있습니까? 저는 몇 번 로그인을 시도하면 예외가 발생합니다.하지만 시도가 끝나고 몇 일 후에 다시 시도됩니다.

다음은 예외입니다 :

예외

> 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)

해결법

  1. ==============================

    1.이것은 늦은 대답이지만, 나는 똑같은 문제에 직면했다. 그것은 c3po에 대한 부적절한 구성 때문입니다.

    이것은 늦은 대답이지만, 나는 똑같은 문제에 직면했다. 그것은 c3po에 대한 부적절한 구성 때문입니다.

    아래의 c3po 구성을 사용하십시오.

    <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
    
  2. ==============================

    2.풀에 연결이 만료되어 다시 연결할 수없는 경우 발생합니다.

    풀에 연결이 만료되어 다시 연결할 수없는 경우 발생합니다.

    https://forum.hibernate.org/viewtopic.php?f=1&t=985002

    http://forums.mysql.com/read.php?39,139821,154688

    풀 설정 변경 (시간 초과, idle_test_period, testConnectionOnCheckin 등)

    <prop key="hibernate.c3p0.min_size">5</prop>
    <prop key="hibernate.c3p0.max_size">100</prop>
    <prop key="hibernate.c3p0.timeout">300</prop>
    <prop key="hibernate.c3p0.max_statements">50</prop>
    <prop key="hibernate.c3p0.idle_test_period">60</prop>
    <prop key="hibernate.c3p0.acquire_increment">2</prop>
    

    또는 이와 같은 DataSource가있는 경우 설정을 사용하여 재생 해보십시오.

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
          destroy-method="close">
    
        <property name="minPoolSize" value="5"/>
        <property name="maxPoolSize" value="5"/>
        <property name="maxStatements" value="500"/>
        <property name="loginTimeout" value="300"/>
        <property name="initialPoolSize" value="5"></property>
        <property name="checkoutTimeout" value="1000"/>
        <property name="automaticTestTable" value="C3P0_TEST_TABLE"></property>
        <property name="testConnectionOnCheckin" value="true"></property>
        <property name="idleConnectionTestPeriod" value="60"></property>
    
    </bean>
    
  3. ==============================

    3.이 메시지는 프로세스의 소켓이 부족함을 나타냅니다. 클라이언트와 데이터 계층 서버 (MySQL이있는 곳) 사이에 너무 빠른 연결이 너무 빠릅니다.

    이 메시지는 프로세스의 소켓이 부족함을 나타냅니다. 클라이언트와 데이터 계층 서버 (MySQL이있는 곳) 사이에 너무 빠른 연결이 너무 빠릅니다.

    http://support.sas.com/kb/40/884.html

  4. ==============================

    4.이것은 서블릿 컨텍스트 **에서 해결되었습니다 .xml ** maxidle, minidle 및 maxwait를 추가합니다.

    이것은 서블릿 컨텍스트 **에서 해결되었습니다 .xml ** maxidle, minidle 및 maxwait를 추가합니다.

            <beans:props>
                <beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect
                </beans:prop>
                <beans:prop key="hibernate.show_sql">true</beans:prop>
    
                <beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop>
    
                **<beans:prop key="maxwait">10000</beans:prop>
                <beans:prop key="maxidle">25</beans:prop>
                <beans:prop key="minidle">5</beans:prop>**
    
    
    
            </beans:props>
    
  5. from https://stackoverflow.com/questions/24053684/hibernate-session-could-not-open-for-transaction by cc-by-sa and MIT license