Since few days, I am seeing the error 'Connection has already been closed' in production environment:
从这几天开始,我看到生产环境中的错误“连接已经关闭”:
Following is the datasource configuration:
以下是数据源配置:
<Resource defaultAutoCommit="true" defaultReadOnly="false"
driverClassName="oracle.jdbc.OracleDriver"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
fairQueue="false" initialSize="10"
jdbcInterceptors="ConnectionState" jmxEnabled="true"
logAbandoned="true" maxActive="100" maxIdle="50"
maxWait="30000" minEvictableIdleTimeMillis="5000"
minIdle="10" name="jdbc/OracleApps" password="APPS"
removeAbandoned="false" removeAbandonedTimeout="60"
testOnBorrow="true" testOnReturn="false"
suspectTimeout="60"
testWhileIdle="true" timeBetweenEvictionRunsMillis="5000"
type="javax.sql.DataSource"
url="jdbcurl"
useEquals="false" username="APPS" validationInterval="30000" validationQuery="SELECT 2+2 FROM DUAL"/>
I have tried the configuration by various ways but it still throws the same error. Any idea is appreciated:
我已经尝试了各种方法的配置,但是仍然有相同的错误。任何想法是感激:
java.sql.SQLException: Connection has already been closed.
at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:118)
at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:94)
at org.apache.tomcat.jdbc.pool.interceptor.ConnectionState.invoke(ConnectionState.java:140)
at $Proxy0.createStatement(Unknown Source)
at cx.PooledDataConnection.open(Unknown Source)
at cx.crm.opportunity.OpportunityHome.getOpportunity(Unknown Source)
at cx.crm.opportunity.OpportunityHome.getOpportunityByPrimaryKey(Unknown Source)
at org.apache.jsp.jsp.WOW.convertquote_jsp._jspService(convertquote_jsp.java:559)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
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 cx.filter.OrginalURLFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at cx.AppblockerFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
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.ajp.AjpProcessor.process(AjpProcessor.java:446)
at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:372)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
1 个解决方案
#1
0
In my case it happened when there were to many open connections in the pool and an in some methods I called con.close() more than just once. Also in my finally(s) I had the following code.
在我的例子中,当池中有许多打开的连接,而在某些方法中,我不止一次地调用了con.close()。同样在我的最后(s)我有以下的代码。
finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {}
}
This doesn't guarantee that the connection is not already closing.
这不能保证连接还没有关闭。
Also my tomcat-jdbc.jar version was old. I replaced it with versión 7.0.55 latest available versión for JDK 1.6 and It works fine even calling the close method serveral times.
还我的tomcat jdbc。jar版本是旧的。我用JDK 1.6的最新版本7.0.55替换了它,它甚至可以调用close方法服务器时间。
#1
0
In my case it happened when there were to many open connections in the pool and an in some methods I called con.close() more than just once. Also in my finally(s) I had the following code.
在我的例子中,当池中有许多打开的连接,而在某些方法中,我不止一次地调用了con.close()。同样在我的最后(s)我有以下的代码。
finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {}
}
This doesn't guarantee that the connection is not already closing.
这不能保证连接还没有关闭。
Also my tomcat-jdbc.jar version was old. I replaced it with versión 7.0.55 latest available versión for JDK 1.6 and It works fine even calling the close method serveral times.
还我的tomcat jdbc。jar版本是旧的。我用JDK 1.6的最新版本7.0.55替换了它,它甚至可以调用close方法服务器时间。