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

PolicyAnnotationListener throws NPE in jar

    XMLWordPrintableJSON

Details

    • Novice

    Description

      I've attached a security policy to my service using:

      @Policy(uri = "classpath:some-security-policy.xml", placement = Policy.Placement.DEFAULT)

      Everything works fine inside Eclipse. But an NPE is thrown in PolicyAnnotationListener on line 348 when I run the executable jar that I build with maven-shade-plugin:

      Exception in thread "main" javax.xml.ws.WebServiceException: java.lang.NullPointerException
      at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:357)
      at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:246)
      at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:525)
      at com.reverb.ison.ws.InteliSonServer.publish(InteliSonServer.java:21)
      at com.reverb.ison.ws.InteliSonServer.main(InteliSonServer.java:15)
      Caused by: java.lang.NullPointerException
      at org.apache.cxf.ws.policy.PolicyAnnotationListener.addPolicy(PolicyAnnotationListener.java:348)
      at org.apache.cxf.ws.policy.PolicyAnnotationListener.addPolicy(PolicyAnnotationListener.java:328)
      at org.apache.cxf.ws.policy.PolicyAnnotationListener.addPolicies(PolicyAnnotationListener.java:249)
      at org.apache.cxf.ws.policy.PolicyAnnotationListener.addPolicies(PolicyAnnotationListener.java:165)
      at org.apache.cxf.ws.policy.PolicyAnnotationListener.handleEvent(PolicyAnnotationListener.java:77)
      at org.apache.cxf.service.factory.AbstractServiceFactoryBean.sendEvent(AbstractServiceFactoryBean.java:72)
      at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:200)
      at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
      at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
      at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:442)
      at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:329)
      ... 4 more

      Looks like the issue is:

      cls.getResource("/").toString()

      which will return null when the class is inside a jar.

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            ebergner Emil Bergner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: