1. Axis2
  2. AXIS2-5062

Connection is not released while using JAXWS client API



      1. Using Dispatch API
      A bit more description for my case, the server side is a simple web service, for the client side, the codes are something like :
      Service service = new HelloService();
      Dispatch dispatchJaxb = service.createDispatch(PORT_QNAME, JAXBContext.newInstance(org.test.ObjectFactory.class),;
      dispatchJaxb.invokeOneWay(new HelloRequest());

      After adding some code fragments in the finally block of BaseDispatch.invokeOneWay method, it looks to me work fine.
      try {
      if (requestMsgCtx != null && requestMsgCtx.getAxisMessageContext() != null) {
      org.apache.axis2.context.MessageContext axisMsgCtx = requestMsgCtx.getAxisMessageContext();
      if (axisMsgCtx.getTransportOut() != null && axisMsgCtx.getTransportOut().getSender() != null)

      { axisMsgCtx.getTransportOut().getSender().cleanup(axisMsgCtx); }

      } catch (Exception ignore) {

      I also googled this issue, and do found a lot of information for the same timeout exception, also read some related codes
      a. In the HttpSender, there is a method named cleanup, which is used to release the connection, but it has the precondition to configure the AUTO_RELEASE_CONNECTION. And actually I did not see other setting configurations in the Axis2 codes, and think that it should be configured by the users in the Options ?
      b. Some posts in the mail list recommended to call the getTransport().cleanup() in the Axis2 specific client codes. And in the testing scenario above, since the standard JAX-WS API is used, suppose that Axis2 should do this ?
      And very appreciated with any comment ? Thanks.

      2. I might find another connection leak while using JAXWS API on client side. In the scenario below :
      For the server side, it requires basic authentication.

      The client codes are something like :
      HelloPort helloPort = (HelloPort)service.getPort(HelloPort.class);

      The client codes did not set the user name and password by the BindingProvider interface, so the server return a 404 to the client side, then the method HttpSender.handleResponse will enter the fourth block :
      private void handleResponse(MessageContext msgContext,
      HttpMethodBase method) throws IOException {
      int statusCode = method.getStatusCode();
      log.trace("Handling response - " + statusCode);
      if (statusCode == HttpStatus.SC_OK)

      { // Save the HttpMethod so that we can release the connection when cleaning up msgContext.setProperty(HTTPConstants.HTTP_METHOD, method); processResponse(method, msgContext); }

      else if (statusCode == HttpStatus.SC_ACCEPTED)

      { /* When an HTTP 202 Accepted code has been received, this will be the case of an execution * of an in-only operation. In such a scenario, the HTTP response headers should be returned, * i.e. session cookies. */ obtainHTTPHeaderInformation(method, msgContext); // Since we don't expect any content with a 202 response, we must release the connection method.releaseConnection(); }

      else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR ||
      statusCode == HttpStatus.SC_BAD_REQUEST) {
      // Save the HttpMethod so that we can release the connection when cleaning up
      msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
      Header contenttypeHeader =
      String value = null;
      if (contenttypeHeader != null)

      { value = contenttypeHeader.getValue(); }

      OperationContext opContext = msgContext.getOperationContext();
      MessageContext inMessageContext =

      { inMessageContext.setProcessingFault(true); }

      if (value != null)

      { processResponse(method, msgContext); }

      if (org.apache.axis2.util.Utils.isClientThreadNonBlockingPropertySet(msgContext))

      { throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode), method.getStatusText())); }

      } else

      { throw new AxisFault(Messages.getMessage("transportError", <--- Running here String.valueOf(statusCode), method.getStatusText())); }


      The stack trace is :

      org.apache.axis2.AxisFault: Transport error: 403 Error: Forbidden
      at org.apache.axis2.transport.http.HTTPSender.handleResponse(
      at org.apache.axis2.transport.http.HTTPSender.sendViaPost(
      at org.apache.axis2.transport.http.HTTPSender.send(
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(
      at org.apache.axis2.engine.AxisEngine.send(
      at org.apache.axis2.description.OutInAxisOperationClient.send(
      at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(
      at org.apache.axis2.client.OperationClient.execute(
      at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(
      at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(
      at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(
      at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(
      at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(
      at $Proxy89.helloPort(Unknown Source)
      at org.test.HelloServlet.doPost(
      at javax.servlet.http.HttpServlet.service(
      at javax.servlet.http.HttpServlet.service(
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(
      at org.apache.catalina.core.StandardWrapperValve.invoke(
      at org.apache.catalina.core.StandardContextValve.invoke(
      at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(
      at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(
      at org.apache.geronimo.tomcat.valve.ProtectedTargetValve.invoke(
      at org.apache.catalina.core.StandardHostValve.invoke(
      at org.apache.catalina.valves.ErrorReportValve.invoke(
      at org.apache.catalina.valves.AccessLogValve.invoke(
      at org.apache.catalina.core.StandardEngineValve.invoke(
      at org.apache.catalina.connector.CoyoteAdapter.service(
      at org.apache.coyote.http11.Http11Processor.process(
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
      at org.apache.geronimo.pool.ThreadPool$
      at org.apache.geronimo.pool.ThreadPool$
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(
      at java.util.concurrent.ThreadPoolExecutor$




          • Assignee:
            Andreas Veithen
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: