Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-1589

Exception is thrown only the first time an error occur while trying to publish a webservice with HTTP transport

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.6
    • Fix Version/s: 2.1.1, 2.0.7
    • Component/s: Transports
    • Labels:
      None
    • Estimated Complexity:
      Novice

      Description

      When a webservice with HTTP defined as transport is published with the following code and the service is already started at the defined publish address an exception is thrown which is a correct behaviour. The problem is that if the same publish code is executed again no error is thrown.

      try{
      Endpoint end = Endpoint.create(impl);
      endpoint = (EndpointImpl) end;
      endpoint.setWsdlLocation(wsdlfile);
      endpoint.publish();
      }catch(WebServiceException e){
      System.out.println(e);

      //The following error message will be printed if the address is already in use:

      //javax.xml.ws.WebServiceException: org.apache.cxf.interceptor.Fault: START_UP_SERVER_FAILED_MSG
      //org.apache.cxf.interceptor.Fault: START_UP_SERVER_FAILED_MSG
      //java.net.BindException: Address already in use
      }

      try{
      Endpoint end = Endpoint.create(impl);
      endpoint = (EndpointImpl) end;
      endpoint.setWsdlLocation(wsdlfile);
      endpoint.publish();
      }catch(WebServiceException e){
      System.out.println(e);

      //No exception is thrown this time even if the publish address is already in use
      }

      The problem seems to be in the method org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine#addServant. The method has the following structure:

      public synchronized void addServant(URL url, JettyHTTPHandler handler) {

      if (server == null)

      { .... code to start server }

      catch (Exception e) {
      LOG.log(Level.SEVERE, "START_UP_SERVER_FAILED_MSG", new Object[]

      {e.getMessage()}

      );
      //problem starting server
      try

      { server.stop(); server.destroy(); }

      catch (Exception ex)

      { //ignore - probably wasn't fully started anyway }

      // Add the following to fix the problem
      //finally

      { // server = null; //}


      throw new Fault(new Message("START_UP_SERVER_FAILED_MSG", LOG, e.getMessage()), e);
      }
      }

      The problem is that server field is not null the second time publish is called. Adding the expression "server = null;" in a finally block for the server.stop() and server.destroy() try seems to fix the problem.

        Attachments

          Activity

            People

            • Assignee:
              dkulp Daniel Kulp
              Reporter:
              kjell Kjell Winblad
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 20m
                20m
                Remaining:
                Remaining Estimate - 20m
                20m
                Logged:
                Time Spent - Not Specified
                Not Specified