Spring:部署后创建bean,管道损坏时出错

时间:2014-09-01 18:29:09

标签: mysql spring tomcat jdbc mybatis

当我在我的大学的应用程序服务器上部署我的应用程序时,我遇到了这个反复出现的错误.1或者在部署我的应用程序后2天,当我进入应用程序时,我收到错误消息。的网址。一旦发生这种情况,我已经发现了几件事。

  1. 如果我刷新网页,则错误消失
  2. 一旦发生这种情况,大约一个小时后,我的数据库模型就完全冻结了,并且它不允许使用该模型的其他应用程序运行,这些应用程序也会冻结。
  3. 解决此问题的唯一方法是重新启动服务器。
  4. 这是我的aplicationContext文件

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                        http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/aop 
                        http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
                        http://www.springframework.org/schema/context 
                        http://www.springframework.org/schema/context/spring-context.xsd
                        http://www.springframework.org/schema/tx 
                        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    
    <context:annotation-config />
    
    <context:component-scan base-package="pe.edu.sistemas.sisdiho" />
    
    <context:property-placeholder location="classpath:application.properties" />
    
    
    <tx:annotation-driven transaction-manager="transactionManager" />
    
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"></property>
    </bean>
    
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="pe.edu.sistemas.sisdiho.mappers" />
    </bean>
    
    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
        <constructor-arg index="0" ref="sqlSessionFactory" />
    </bean>
    
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="typeAliasesPackage" value="pe.edu.sistemas.sisdiho.entities" />
        <property name="mapperLocations"
            value="classpath*:pe/edu/sistemas/sisdiho/mappers/**/*.xml" />
    </bean>
    
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}"></property>
        <property name="url" value="${jdbc.url}"></property>
        <property name="removeAbandoned" value="true"></property>
        <property name="username" value="${jdbc.username}"></property>
        <property name="password" value="${jdbc.password}"></property>
        <property name="initialSize" value="3"></property>
    </bean>
    

    这是我的服务器日志中发现的错误

    ago 22, 2014 10:10:39 AM org.apache.catalina.core.StandardWrapperValve invoke SEVERE:     
    El Servlet.service() para el servlet [Faces Servlet] en el contexto con ruta [/sisdiho] lanzó la excepción 
    [Error creating bean with name 'commonLaboScheduleController': Invocation of init method failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 
    The last packet successfully received from the server was 60.409.421 milliseconds ago. The last packet sent successfully to the server was 60.409.421 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.] con causa raíz java.net.SocketException: broken Pipeline
    

    我最近的错误日志是20页长,所以我将链接我的驱动器上共享的错误日志。

    Application error log

    有人可以告诉我,我做错了什么?我该如何解决?

    我正在使用: Spring Tool Suite MyBatis的 Mysql的 Primefaces

1 个答案:

答案 0 :(得分:0)

切换到另一个连接池,看看它是否适合您:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driverClassName}"></property>
    <property name="url" value="${jdbc.url}"></property>
    <property name="removeAbandoned" value="true"></property>
    <property name="username" value="${jdbc.username}"></property>
    <property name="password" value="${jdbc.password}"></property>
    <property name="initialSize" value="3"></property>
</bean>

其他一些java连接池包括:

相关问题