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

NullPointerException when trying to customize the package name for a service definition without customizing the class name.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6.1
    • Fix Version/s: 2.4.9, 2.5.5, 2.6.2, 2.7
    • Component/s: Tooling
    • Labels:
      None
    • Environment:

      JDK v1.7
      Maven v3.0.4
      cxf-codegen-plugin v2.6.1

    • Estimated Complexity:
      Unknown

      Description

      Hello

      When I try to use jax-ws customization to customize the package name without customizing the class name, for example using the following XML code

      <bindings wsdlLocation="myService.wsdl" xmlns="http://java.sun.com/xml/ns/jaxws" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
      <bindings node="wsdl:definitions/wsdl:service[@name='MyService_V1']">
      <package name="com.acme.myservice.v1.wsdl"/>
      </bindings>
      </bindings>

      I get the following exception:

      [WARNING] WSDLToJava Error: java.lang.NullPointerException
      [WARNING]
      [WARNING] org.apache.cxf.tools.common.ToolException: java.lang.NullPointerException
      [WARNING] at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:294)
      [WARNING] at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:103)
      [WARNING] at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:113)
      [WARNING] at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:86)
      [WARNING] at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:184)
      [WARNING] Caused by: java.lang.NullPointerException
      [WARNING] at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ServiceProcessor.processService(ServiceProcessor.java:207)
      [WARNING] at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal.ServiceProcessor.process(ServiceProcessor.java:100)
      [WARNING] at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.wsdlDefinitionToJavaModel(WSDLToJavaProcessor.java:91)
      [WARNING] at org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.WSDLToJavaProcessor.process(WSDLToJavaProcessor.java:60)
      [WARNING] at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl(WSDLToJavaContainer.java:253)
      [WARNING] at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:139)
      [WARNING] at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:286)
      [WARNING] ... 4 more

      The problem is in the class named ‘org.apache.cxf.tools.wsdlto.frontend.jaxws.processor.internal. ServiceProcessor’ in line 207:

      if (serviceBinding2.getJaxwsClass().getComments() != null) {

      }

      If you don’t customize the class name, serviceBinding2.getJaxwsClass() will returns null so calling getComments() results in a NullPointerException .

      A possible quick solution could be to change the condition as follows:

      if (serviceBinding2.getJaxwsClass() != null && serviceBinding2.getJaxwsClass().getComments() != null) {

      }

      On the other hand, a possible workaround is to customize the class name. For example, the following XML code will work fine.

      <bindings wsdlLocation="myService.wsdl" xmlns="http://java.sun.com/xml/ns/jaxws" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
      <bindings node="wsdl:definitions/wsdl:service[@name='MyService_V1']">
      <package name="com.acme.myservice.v1.wsdl"/>
      <class name="MyServiceV1" />
      </bindings>
      </bindings>

      Best regards,


      Sandy Pérez González
      Indaba Consultores S.L.
      http://www.indaba.es/

        Attachments

          Activity

            People

            • Assignee:
              ffang Freeman Yue Fang
              Reporter:
              sandyperez Sandy Perez
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: