1 Reply Latest reply on Jan 19, 2012 6:50 PM by jfitzpatrick

    NullPointerException when deploying JAX-WS web-service in com.sun.xml.ws.policy.jaxws.PolicyWSDLParserExtension line 980.

    jfitzpatrick

      Hi There,

       

      I have been struggling to deploy a web-application which implements two JAX-WS endpoints, one of which uses the provider API and the other using the POJO method.

       

      My environment:

       

      jbossws-metro-3.3.1

       

      Java Version: 1.6.0.20

       

      JBoss Version: 5.1.0.GA

       

      OS: Ubuntu 10.04 LTS Desktop

       

      What I do:

       

      Implement a web-application that implements two web-service endpoints, one using the JAX-WS provider API and the other using the POJO approach with relevant @WebService annotation. Example code snippets:

       

      AddNumbersImpl.java:

       

      @ServiceMode(value=Service.Mode.PAYLOAD)

      @WebServiceProvider(portName="AddNumbersPort",

              serviceName="AddNumbersService",

              targetNamespace="http://duke.example.org",

              wsdlLocation="WEB-INF/wsdl/AddNumbers.wsdl")

      public class AddNumbersImpl implements Provider<Source> {

        .... body of class here

      }

       

      SubtractNumbersImpl.java

       

      @WebService(    serviceName = "SubtractNumbersService",

                      portName = "SubtractNumbersPort",

                      endpointInterface = "provider.server.SubtractNumbersPortType" )

      public class  SubtractNumbersImpl {

      .... body of class here

      }

       

      I have setup web.xml with all of the relevant servlets and mappings and corresponding wsdl files.

       

      The SubtractNumbersImpl class has a single method called subtractNumbers which throws a single exception.

       

      When I deploy my web-application, I get the following stack trace:

       

      12:35:16,621 ERROR [AbstractKernelController] Error installing to Real: name=vfszip:/opt/jboss/jboss-5.1.0.GA/server/web/deploy/jaxws-provider.war/ state=PreReal mode=Manual requiredState=Real

      org.jboss.deployers.spi.DeploymentException: Error during deploy: vfszip:/opt/jboss/jboss-5.1.0.GA/server/web/deploy/jaxws-provider.war/

          at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)

          at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:177)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)

          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)

          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)

          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)

          at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)

          at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)

          at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)

          at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)

          at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)

          at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)

          at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

          at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)

          at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)

          at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)

          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)

          at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)

          at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)

          at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)

          at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)

          at org.jboss.Main.boot(Main.java:221)

          at org.jboss.Main$1.run(Main.java:556)

          at java.lang.Thread.run(Thread.java:619)

      Caused by: javax.xml.ws.WebServiceException: Failed to build METRO runtime model

          at org.jboss.wsf.stack.metro.metadata.RuntimeModelDeploymentAspect.start(RuntimeModelDeploymentAspect.java:135)

          at org.jboss.webservices.integration.deployers.WSDeploymentAspectDeployer.internalDeploy(WSDeploymentAspectDeployer.java:107)

          at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)

          at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)

          ... 29 more

      Caused by: java.lang.NullPointerException

          at com.sun.xml.ws.policy.jaxws.PolicyWSDLParserExtension.finished(PolicyWSDLParserExtension.java:980)

          at com.sun.xml.ws.wsdl.parser.DelegatingParserExtension.finished(DelegatingParserExtension.java:183)

          at com.sun.xml.ws.wsdl.parser.WSDLParserExtensionFacade.finished(WSDLParserExtensionFacade.java:328)

          at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:229)

          at com.sun.xml.ws.server.EndpointFactory.getWSDLPort(EndpointFactory.java:513)

          at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:199)

          at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)

          at org.jboss.wsf.stack.metro.DeploymentDescriptorParserExt.parseAdapters(DeploymentDescriptorParserExt.java:295)

          at org.jboss.wsf.stack.metro.DeploymentDescriptorParserExt.parse(DeploymentDescriptorParserExt.java:171)

          at org.jboss.wsf.stack.metro.metadata.RuntimeModelDeploymentAspect.start(RuntimeModelDeploymentAspect.java:111)

          ... 32 more

       

      If I modify the SubtractNumbers service so that no exception is thrown then the application deploys without any problems.

       

      What I Expect:

       

      The web-application should deploy without any exceptions being thrown.

       

      Detailed Replication Steps:

       

      Attached to this post is a zip file containing the test case I am using to replicate this error.

       

      Detailed steps to reproduce the problem:

       

      Pre-requisites:

       

      JBoss 5.1.0.GA

       

      Sun Java 6 JDK

       

      JAX-WS RI 2.1.7

       

      jbossws-metro-3.3.1

       

      1. Download the attached zip file.

       

      2. Extract to a directory somewhere.

       

      3. Open a terminal and move into the directory where the files were extracted.

       

      3. Set JAXWS_HOME to the JAX-WS home.

       

      export JAXWS_HOME=/home/jfitzpatrick/Downloads/jaxws-ri-20090416-2.1.7/

       

      4. Build the server side code.

       

      ant build-server-wsdl

       

      5. Create the war file.

       

      ant create-war

       

      6. Copy the war file to the jboss deployment directory.

       

      cp build/war/jaxws-provider.war /opt/jboss/jboss-5.1.0.GA/server/web/deploy

       

      7. Start JBoss.

       

      /opt/jboss/jboss-5.1.0.GA/bin/run.sh -c web -b 0.0.0.0

       

      8. Observe the exception described above.

       

      If the above steps are repeated after modifying the SubtractNumbers service so that no exceptions are thrown, the application deploys without any errors.

       

      To see this, simply comment out anything related to the fault/exception in the SubtractNumbers.wsdl file and modify SubtractNumbersImpl.java so that the exception is no longer thrown.

       

      After doing an "ant clean" and repeating the steps above, you should observe that the exception is no longer thrown.

       

      My questions:

       

      Has anyone else observed this behaviour?

       

      Am I doing something wrong in regards to the configuration of the application?

       

      Is it possible to deploy JAX-WS with different endpoints using different programming models?

       

      If anyone has any hints, ideas, or anything at all that may help it would be greatly appreciated.

       

      Thank you,

       

      John Fitzpatrick

        • 1. Re: NullPointerException when deploying JAX-WS web-service in com.sun.xml.ws.policy.jaxws.PolicyWSDLParserExtension line 980.
          jfitzpatrick

          I finally managed to find a solution to the problem although I do not know about about the detailed implementation to understand why my solution works.

           

          When I initially started to work on getting something implemented, I looked at the JAX-WS samples which showed how to use the provider API and deploy using the sun-jaxws deployment descriptor. For some reason, deploying this way meant that the wsdl had to be in the WEB-INF directory of the war. Specifying the wsdl location to be anything but that caused an exception with a message saying that the wsdl location had to start with WEB-INF/wsdl. It seems that if on the other hand you use jbossws with the metro web-services stack and put the wsdl in the WEB-INF directory, you will get the exception described above. It seems that when I first started debugging the problem, I wrongly attributed the cause of the exception.

           

          The summary is, if your implemented web-service has web methods that may throw exceptions, putting the wsdl in a sub-directory of the WEB-INF in the deployed war will cause the above issue. The solution is to put the wsdl at the root of the war, e.g. myapp.war/wsdl/...

           

          Hopefully you find this thread before banging your head against the wall for a few days. If anyone has any insight as to why this happens, e.g. if it is a bug, etc, I would love to hear from you. Any Sun, ahem, I mean Oracle people care to comment?

           

          John