【问题标题】:Spring : Error creating bean , broken pipeline after deploymentSpring:创建 bean 时出错,部署后管道损坏
【发布时间】:2014-09-01 18:29:09
【问题描述】:

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

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

这是我的应用上下文文件

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

谁能告诉我我做错了什么?我该如何解决?

我正在使用: 弹簧工具套件 MyBatis mysql 素颜

【问题讨论】:

  • 作为首要任务,请确保所有超时同步。 db 连接池、db 本身和任何其他地方,db 连接可能会保持活动一段时间。如果从池中返回死连接,则可能会发生类似的情况。其次,在池中配置连接检查,因为您可能会收到损坏的连接。
  • 对不起,我该如何编辑它,我对服务器和数据库这一切真的很陌生。我正在使用带有 phpmyadmin 的 spring 工具套件和 mysql 数据库。在哪里可以检查或更改这些设置。
  • 对于 MySQL,如果你什么都没碰,默认会很长(我认为是 8 小时)。我猜你正在使用某种连接池,对吧?但是什么? Tomcat提供的那个? c3p0?还有什么?

标签: mysql spring tomcat jdbc mybatis


【解决方案1】:

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

<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连接池包括:

【讨论】:

    猜你喜欢
    • 2017-12-20
    • 2015-11-06
    • 2016-06-24
    • 2013-10-06
    • 2014-01-25
    • 1970-01-01
    • 2021-01-01
    • 2017-02-03
    • 1970-01-01
    相关资源
    最近更新 更多