5 Replies Latest reply on Apr 5, 2004 12:11 AM by arpitmittal

    Network Problem while accessing database: Connection reset b

    arpitmittal

      Hi ,

      I have an application successfully deployed and running on the JBoss3.2.3 server. Now when the network goes down and resumes up the
      application faces the following problem:

      Connection reset by peer: socket write error

      Now i have to restart the server and then everything works fine.

      Do anyone have solution to this problem.
      Please reply

      -Regards
      Arpit Mittal

      PS: the detail of the error is as follows:-


      15:37:36,570 ERROR [STDERR] java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Connection reset by peer: socket write error
      15:37:36,602 ERROR [STDERR] at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
      15:37:36,602 ERROR [STDERR] at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
      15:37:36,602 ERROR [STDERR] at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
      15:37:36,602 ERROR [STDERR] at com.microsoft.jdbc.sqlserver.tds.TDSExecuteRequest.submitRequest(Unknown Source)
      15:37:36,602 ERROR [STDERR] at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.rollbackTransaction(Unknown Source)
      15:37:36,602 ERROR [STDERR] at com.microsoft.jdbc.base.BaseConnection.rollback(Unknown Source)
      15:37:36,602 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.local.LocalManagedConnection.rollback(LocalManagedConnection.java:118)
      15:37:36,617 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource.rollback(TxConnectionManager.java:832)
      15:37:36,617 ERROR [STDERR] at org.jboss.tm.TransactionImpl.rollbackResources(TransactionImpl.java:1664)
      15:37:36,617 ERROR [STDERR] at org.jboss.tm.TransactionImpl.rollback(TransactionImpl.java:458)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:390)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:277)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      15:37:36,617 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:700)
      15:37:36,617 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      15:37:36,617 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      15:37:36,617 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      15:37:36,617 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      15:37:36,617 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
      15:37:36,617 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
      15:37:36,617 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:101)
      15:37:36,617 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
      15:37:36,617 ERROR [STDERR] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      15:37:36,617 ERROR [STDERR] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
      15:37:36,617 ERROR [STDERR] at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:100)
      15:37:36,617 ERROR [STDERR] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
      15:37:36,617 ERROR [STDERR] at $Proxy50.processRequest(Unknown Source)
      15:37:36,617 ERROR [STDERR] at com.igt.action.mst.AircraftMainAC.populateCollection(AircraftMainAC.java:349)
      15:37:36,617 ERROR [STDERR] at com.igt.action.mst.AircraftMainAC.execute(AircraftMainAC.java:90)
      15:37:36,617 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
      15:37:36,633 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
      15:37:36,633 ERROR [STDERR] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
      15:37:36,633 ERROR [STDERR] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
      15:37:36,649 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      15:37:36,649 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      15:37:36,649 ERROR [STDERR] at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      15:37:36,649 ERROR [STDERR] at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      15:37:36,649 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      15:37:36,649 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      15:37:36,649 ERROR [STDERR] at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197)
      15:37:36,649 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
      15:37:36,649 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
      15:37:36,649 ERROR [STDERR] at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
      15:37:36,649 ERROR [STDERR] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
      15:37:36,649 ERROR [STDERR] at java.lang.Thread.run(Thread.java:536)

        • 1. Re: Network Problem while accessing database: Connection res
          mikelarnett

          It may be helpful to post your mssql-ds.xml file, but without seeing it, my guess is that you need to add an ExceptionSorter and a check-valid-sql tag to your mssql-ds.xml. Something like this:



          <local-tx-datasource>

          <jndi-name>someDataSource</jndi-name>

          <connection-url>
          jdbc:microsoft:sqlserver://someUrl:1433;DatabaseName=someDb;SelectMethod=cursor
          </connection-url>

          <driver-class>
          com.microsoft.jdbc.sqlserver.SQLServerDriver
          </driver-class>

          <user-name>someUser</user-name>

          somePass

          <exception-sorter-class-name>
          com.yourpkg.SqlServerExceptionSorter
          </exception-sorter-class-name>

          <min-pool-size>10</min-pool-size>

          <max-pool-size>20</max-pool-size>

          <valid-connection-sql>
          select count(*) from SomeConnectionTest
          </valid-connection-sql>

          </local-tx-datasource>



          The sql used should be very fast. In my example SomeConnectionTest is a one column table with only one row. Also, you will have to develop an ExceptionSorter, but there are several examples in the docs directory. Essentially, try this:

          public class SqlServerExceptionSorter implements ExceptionSorter, Serializable
          {
          public SqlServerExceptionSorter()
          {
          } // SqlServerExceptionSorter constructor

          public boolean isExceptionFatal(SQLException e)
          {
          return true;
          }
          } // SqlServerExceptionSorter


          ...if you want all Exceptions thrown by the JDBC driver to force the Connection to be removed from the connection pool.
          Finally, a search for ExceptionSorter and valid-connection-sql on this forum will result in a lot of answers to this situation that may have more helpful info.

          Hope this all helps,
          -MLA

          • 2. Re: Network Problem while accessing database: Connection res
            arpitmittal

            HI,

            This is my mssql-ds.xml


            <local-tx-datasource>
            <jndi-name>AirDeccanDS</jndi-name>
            <connection-url>jdbc:microsoft:sqlserver://10.220.74.82:1433;SelectMethod=cursor;DatabaseName=AirDeccan</connection-url>
            <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
            <user-name>sa</user-name>

            <!-- sql to call when connection is created
            <new-connection-sql>SELECT * FROM COUNTRY</new-connection-sql>
            -->
            <!-- sql to call on an existing pooled connection when it is obtained from pool
            <check-valid-connection-sql>SELECT * FROM COUNTRY</check-valid-connection-sql>
            -->

            </local-tx-datasource>




            But didn't understand that how does it will help me to reterive a connection to database, when network gets down in between and resumes up immediately.

            My application uses serviceLocator pattern where i use to get datasource through the JNDI name.

            MoreOver I have my own AppExceptionHandler for the whole application which handles anytype of Exception, filters it and ouput is controlled as per the business logic.


            I possible can you send me an working example.

            • 3. Re: Network Problem while accessing database: Connection res
              mikelarnett

              Ok, now I'm confused. Did you try adding an ExceptionSorter? If so, and you are still seeing the problem, then I am stumped. If not, then knock yourself out. If you are confused about how to implement or deploy an ExceptionSorter, then as I said, do a search on the JBoss Forums for ExceptionSorter (several threads on the subject).
              -MLA

              • 4. Re: Network Problem while accessing database: Connection res

                Why is your check-valid-connection-sql commented out?

                Regards,
                Adrian

                • 5. Re: Network Problem while accessing database: Connection res
                  arpitmittal

                  Hi,

                  My problem is solved , thanks to you both Mikelarnett and Adrian.


                  mikelarnett,

                  There is nothing to confuse, I have my own exceptional handler which is not handling the problem I am facing.
                  Well now, I do not need the ExceptionSorter.


                  Adrian,

                  Thanks for bringing me the notice about the commented code. Actually sometime people do miss the simple stuff like this one .


                  Thanks to you all, now my problem is solved.

                  -Regards
                  Arpit Mittal