12418


こんばんは。  
現在本番運用中のシステムで、下記メッセージが表示され接続ができずにエラーとなる事象が発生しました。ただ、再度接続するとつながるようになります。  
夜間にサーバ起動後、しばらくアクセスしない時間が続いた場合に発生する、というのはわかっているのですが、対処方法が分かりません。

お知恵を拝借いたしたく、よろしくお願いします。

環境：  
OS：CentOS release 6.5 (Final)  
tomcat:6.0.39  
apache:2.2.21  
java:1.7.0_45

[code]

    java.sql.SQLRecoverableException: IOエラー: Broken pipe
        at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:865)
        at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
        at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1477)
        at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:392)
        at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
        at org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)
        at util.DbUtil.getResultSet(DbUtil.java:409)
        at util.DbUtil.getDataTable(DbUtil.java:466)
        at util.DbUtil.getDataTable(DbUtil.java:441)
        at page.logic.BusinessLogic.getOlf(BusinessLogic.java:51)
        at page.common.Common.checkPreCondtion(Common.java:106)
        at page.action.AbstractAction.checkPreCondition(AbstractAction.java:64)
        at framework.action.AbstractAction.doAction(AbstractAction.java:460)
        at framework.action.AbstractAction.index(AbstractAction.java:183)
        at page.action.Am001011Action$$EnhancedByS2AOP$$4f65cbd2.$$index$$invokeSuperMethod$$(Am001011Action$$EnhancedByS2AOP$$4f65cbd2.java)
        at page.action.Am001011Action$$EnhancedByS2AOP$$4f65cbd2$$MethodInvocation$$index5.proceed(MethodInvocationClassGenerator.java)
        at org.seasar.extension.tx.DefaultTransactionCallback.execute(DefaultTransactionCallback.java:58)
        at org.seasar.extension.tx.adapter.JTATransactionManagerAdapter.required(JTATransactionManagerAdapter.java:65)
        at org.seasar.extension.tx.RequiredInterceptor.invoke(RequiredInterceptor.java:50)
        at page.action.Am001011Action$$EnhancedByS2AOP$$4f65cbd2$$MethodInvocation$$index5.proceed(MethodInvocationClassGenerator.java)
        at org.seasar.framework.aop.interceptors.ThrowsInterceptor.invoke(ThrowsInterceptor.java:79)
        at page.action.Am001011Action$$EnhancedByS2AOP$$4f65cbd2$$MethodInvocation$$index5.proceed(MethodInvocationClassGenerator.java)
        at org.seasar.framework.aop.interceptors.TraceInterceptor.invoke(TraceInterceptor.java:56)
        at page.action.Am001011Action$$EnhancedByS2AOP$$4f65cbd2$$MethodInvocation$$index5.proceed(MethodInvocationClassGenerator.java)
        at page.action.Am001011Action$$EnhancedByS2AOP$$4f65cbd2.index(Am001011Action$$EnhancedByS2AOP$$4f65cbd2.java)
        at sun.reflect.GeneratedMethodAccessor53.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.seasar.framework.util.MethodUtil.invoke(MethodUtil.java:96)
        at org.seasar.struts.action.ActionWrapper.execute(ActionWrapper.java:139)
        at org.seasar.struts.action.ActionWrapper.execute(ActionWrapper.java:87)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.seasar.struts.action.S2RequestProcessor.process(S2RequestProcessor.java:132)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.extension.filter.RequestDumpFilter.doFilter(RequestDumpFilter.java:127)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.framework.container.filter.S2ContainerFilter.doFilter(S2ContainerFilter.java:79)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.framework.container.hotdeploy.HotdeployFilter.doFilter(HotdeployFilter.java:71)
        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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
        at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
        at org.seasar.struts.action.S2RequestProcessor.doForward(S2RequestProcessor.java:306)
        at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
        at org.seasar.struts.action.S2RequestProcessor.process(S2RequestProcessor.java:134)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.extension.filter.RequestDumpFilter.doFilter(RequestDumpFilter.java:127)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.framework.container.filter.S2ContainerFilter.doFilter(S2ContainerFilter.java:79)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.framework.container.hotdeploy.HotdeployFilter.doFilter(HotdeployFilter.java:71)
        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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
        at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
        at org.seasar.struts.filter.RoutingFilter.forward(RoutingFilter.java:219)
        at org.seasar.struts.filter.RoutingFilter.doFilter(RoutingFilter.java:152)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.framework.container.filter.S2ContainerFilter.doFilter(S2ContainerFilter.java:79)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.framework.container.hotdeploy.HotdeployFilter.doFilter(HotdeployFilter.java:71)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.seasar.extension.filter.EncodingFilter.doFilter(EncodingFilter.java:69)
        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.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:311)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
        at java.lang.Thread.run(Thread.java:662)
    Caused by: java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at oracle.net.ns.DataPacket.send(DataPacket.java:199)
        at oracle.net.ns.NetOutputStream.write(NetOutputStream.java:176)
        at oracle.jdbc.driver.T4CSocketOutputStreamWrapper.flush(T4CSocketOutputStreamWrapper.java:98)
        at oracle.jdbc.driver.T4CSocketOutputStreamWrapper.flush(T4CSocketOutputStreamWrapper.java:91)
        at oracle.jdbc.driver.T4CSocketOutputStreamWrapper.write(T4CSocketOutputStreamWrapper.java:59)
        at oracle.jdbc.driver.T4CMAREngine.value2Buffer(T4CMAREngine.java:974)
        at oracle.jdbc.driver.T4CMAREngine.marshalSB4(T4CMAREngine.java:424)
        at oracle.jdbc.driver.T4CMAREngine.marshalUB4(T4CMAREngine.java:448)
        at oracle.jdbc.driver.T4C8Oall.marshalPisdef(T4C8Oall.java:1179)
        at oracle.jdbc.driver.T4C8Oall.marshal(T4C8Oall.java:958)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:189)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:852)
        ... 101 more
    
[/code]


CC BY-SA 3.0
2015-07-16T11:03:16.573
12417
2015-07-16T11:28:09.813
2015-07-16T11:07:19.673
5750
10349
question
java apache tomcat
Broken pipe　エラー


おそらくデータベース（Oracle)接続のタイムアウト値が一定期間過ぎてしまった場合に発生します。

まず確認していただきたいのは、Tomcatの設定またはWebアプリケーション内でデータベース接続の設定を書かれている場所があるかと思います。

Tomcatに直接書かれている場合は、Tomcat/conf の server.xml または
context.xml、Webアプリケーションに書かれている場合は、META-INF/context.xmlに以下のような設定が書かれていると思います。

[code]

    <Resource name="jdbc/sampleConnection"
            auth="Container"
            type="javax.sql.DataSource"
            username="接続ユーザ名"
            password="接続パスワード"
            driverClassName="JDBCドライバー名"
            url="接続先のURL"
            maxActive="20"
            maxIdle="2"
            validationQuery="SELECT 1 FROM DUAL"
            />
    
[/code]

この validationQuery
がない場合は追記してください。このクエリはデータベース接続が確立できているかを確認するだけのSQLで、一定間隔で実行します。他にも
maxActiveやmaxIdleなど接続数の最大/最小を決定できるパラメータもありますので、こちらも無ければ環境の負荷にあわせて調整してください。

なお、接続の自動切断はTomcat側だけでなく、Oracle側の設定もありますのでご確認ください。

以下、Tomcat(7.0)のjdbcに関するリファレンスです(英語)  
<https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>

お役に立てば幸いです。


CC BY-SA 3.0
2015-07-16T11:28:09.813
12418
2015-07-16T11:28:09.813
5778
12417
answer