7 Replies Latest reply on Jul 16, 2012 2:08 PM by swakesh

    Communication Link Failure

    swakesh

      Hi,

      I have implemented a simple connection pooling using Jboss Appication Server 7

       

      DataSource ds = (DataSource) new InitialContext().lookup("jdbc/myDS");

       

      MY SQL Database is installed on a server and we are accessign through ip address and database name.

       

      I am getting a exception after running 2 to 3 webservices.


       

      15:03:23,514 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) 2012-07-05 15:03:23,513 [http-localhost-127.0.0.1-8080-1] ERROR com.tetrus.collab.dao.UserOperationDAOImpl  - Error in adding user to database

       

      15:03:23,522 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver.

       

      15:03:23,523 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

       

      15:03:23,524 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

       

      15:03:23,525 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

       

      15:03:23,526 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

       

      15:03:23,527 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)

       

      15:03:23,528 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.Util.getInstance(Util.java:384)

       

      15:03:23,529 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)

       

      15:03:23,530 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)

       

      15:03:23,531 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)

       

      15:03:23,531 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)

       

      15:03:23,532 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.ConnectionImpl.throwConnectionClosedException(ConnectionImpl.java:1204)

       

      15:03:23,533 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.ConnectionImpl.checkClosed(ConnectionImpl.java:1191)

       

      15:03:23,534 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.ConnectionImpl.prepareStatement(ConnectionImpl.java:4276)

       

      15:03:23,535 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.doPrepareStatement(BaseWrapperManagedConnection.java:677)

       

      15:03:23,537 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.java:652)

       

      15:03:23,538 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.jca.adapters.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:404)

       

      15:03:23,539 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.tetrus.collab.dao.UserOperationDAOImpl.addUser(UserOperationDAOImpl.java:49)

       

      15:03:23,539 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.tetrus.collab.service.AdminService.addUser(AdminService.java:46)

       

      15:03:23,541 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.tetrus.collab.rest.AdministrationRSImpl.addUser(AdministrationRSImpl.java:41)

       

      15:03:23,543 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       

      15:03:23,545 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

       

      15:03:23,546 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

       

      15:03:23,548 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.lang.reflect.Method.invoke(Method.java:597)

       

      15:03:23,550 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155)

       

      15:03:23,552 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)

       

      15:03:23,553 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)

       

      15:03:23,554 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)

       

      15:03:23,555 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525)

       

      15:03:23,556 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)

       

      15:03:23,557 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)

       

      15:03:23,558 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

       

      15:03:23,559 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

       

      15:03:23,561 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

       

      15:03:23,562 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

       

      15:03:23,563 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

       

      15:03:23,564 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

       

      15:03:23,565 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

       

      15:03:23,566 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

       

      15:03:23,568 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

       

      15:03:23,569 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

       

      15:03:23,571 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

       

      15:03:23,572 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

       

      15:03:23,573 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

       

      15:03:23,574 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

       

      15:03:23,575 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

       

      15:03:23,576 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

       

      15:03:23,577 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.lang.Thread.run(Thread.java:662)

       

      15:03:23,578 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

       

      15:03:23,579 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)

       

      15:03:23,580 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) The last packet successfully received from the server was 318,751 milliseconds ago. The last packet sent successfully to the server was 318,753 milliseconds ago.

       

      15:03:23,581 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

       

      15:03:23,583 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

       

      15:03:23,584 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

       

      15:03:23,585 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)

       

      15:03:23,586 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)

       

      15:03:23,587 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1122)

       

      15:03:23,588 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3317)

       

      15:03:23,589 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1941)

       

      15:03:23,590 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114)

       

      15:03:23,591 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2696)

       

      15:03:23,592 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2105)

       

      15:03:23,592 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1367)

       

      15:03:23,593 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.execute(CachedPreparedStatement.java:297)

       

      15:03:23,595 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:404)

       

      15:03:23,595 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.tetrus.collab.dao.UserOperationDAOImpl.addUser(UserOperationDAOImpl.java:69)

       

      15:03:23,596 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     ... 30 more

       

      15:03:23,597 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Caused by: java.net.SocketException: Connection reset by peer: socket write error

       

      15:03:23,598 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.net.SocketOutputStream.socketWrite0(Native Method)

       

      15:03:23,599 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)

       

      15:03:23,599 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.net.SocketOutputStream.write(SocketOutputStream.java:136)

       

      15:03:23,601 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)

       

      15:03:23,602 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

       

      15:03:23,604 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3298)

       

      15:03:23,605 INFO  [stdout] (http-localhost-127.0.0.1-8080-1)     ... 38 more

       

      I have turned off my fire wall and tested the webservices still i am getting the above exception.

        • 1. Re: Communication Link Failure
          jaikiran

          Exceptions like these most likely mean that the driver jar version you are using isn't compatible with the database server version with which it is communicating. Make sure you have the right vendor and version of the driver jar.

          • 2. Re: Communication Link Failure
            sfcoy

            Is there a firewall device between you and the database? These things are also known to unceremoniously drop your connections after a period of time.

            • 3. Re: Communication Link Failure
              swakesh

              We have installed My SQL version 5.5.25  on local machine and server.

              Connector J version 5.1 ( mysql-connector-java-5.1.12-bin.jar ).

               

              As per the http://dev.mysql.com/doc/refman/5.5/en/connector-j-versions.html documention there is no compatability issues.

               

              When i connect to same My Sql  database on my local machine there is no communicaiton link failure error.

              • 4. Re: Communication Link Failure
                swakesh

                Stephen Coy wrote:

                 

                Is there a firewall device between you and the database? These things are also known to unceremoniously drop your connections after a period of time.

                If there was a firewall issue then  connection with My SQL work bench should also be dropped after some time.

                I can connect to  the database on server using work bench, i don't find any problem.

                 

                I also found out that there is no fire wall installed in the network to block the access.

                • 5. Re: Communication Link Failure
                  swakesh

                  I have created connection pooling using this code. Please let me know  if there is a issue with the below lines

                   

                  <subsystem xmlns="urn:jboss:domain:datasources:1.0">

                              <datasources>

                                  <datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">

                                      <connection-url>jdbc:mysql://192.........../DBname:</connection-url>

                                      <driver-class>com.mysql.jdbc.Driver</driver-class>

                                      <driver>com.mysql</driver>

                                      <pool>

                                          <min-pool-size>5</min-pool-size>

                                          <max-pool-size>100</max-pool-size>

                                          <prefill>true</prefill>

                                      </pool>

                                      <security>

                                          <user-name>root</user-name>

                                          <password>*********</password>

                                      </security>

                                      <statement>

                                          <prepared-statement-cache-size>32</prepared-statement-cache-size>

                                          <share-prepared-statements>true</share-prepared-statements>

                                      </statement>

                                  </datasource>

                                  <drivers>

                                      <driver name="h2" module="com.h2database.h2">

                                          <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>

                                      </driver>

                                      <driver name="com.mysql" module="com.mysql">

                                          <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>

                                      </driver>

                                  </drivers>

                              </datasources>

                          </subsystem>

                  • 6. Re: Communication Link Failure
                    leonardo.devai

                    This looks like network intermitence or MySQL Server restart.

                     

                    Try appending "?autoReconnect=true" to your connection URL:

                     

                    jdbc:mysql://19..../mydb?autoReconnect=true

                    1 of 1 people found this helpful
                    • 7. Re: Communication Link Failure
                      swakesh

                      Thanks.