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

org.apache.cxf.ws.policy.PolicyAnnotationListener throws NPE on endpoints with wsdlURL only (i.e. no serviceClass)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.2, 2.3.3
    • 2.4, 2.3.4
    • WS-* Components
    • None
    • Apache Camel context, Maven project

    Description

      Camel context is configured to create a CXF endpoint through use of a WSDL file only (i.e. no implementor). Spring configuration definition is as follows:

      <cxf:cxfEndpoint id="nireusV5"
      		address="http://10.234.2.81:8080/nireus/v5"
      		wsdlURL="classpath:wsdl/nireus_old.wsdl">
      	<cxf:properties>
      		<entry key="dataFormat" value="PAYLOAD" />
      	</cxf:properties>
      </cxf:cxfEndpoint>
      

      Maven dependencies include cxf-rt-ws-policy and cxf-rt-ws-security modules, in an attempt to introduce use of WS-SecurityPolicy in the endpoint. When the camel context is starting up, the following NPE is raised:

      Caused by: java.lang.NullPointerException
              at org.apache.cxf.ws.policy.PolicyAnnotationListener.addPolicies(PolicyAnnotationListener.java:210)
              at org.apache.cxf.ws.policy.PolicyAnnotationListener.handleEvent(PolicyAnnotationListener.java:84)
              at org.apache.cxf.service.factory.AbstractServiceFactoryBean.sendEvent(AbstractServiceFactoryBean.java:73)
              at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:179)
              at org.apache.camel.component.cxf.CxfConsumer.<init>(CxfConsumer.java:251)
      

      PolicyAnnotationListener.addPolicies(...) method code is trying to get any declared @Policy or @Policies annotations on the class object that is being passed as argument. This object though is null, probably because no implementor object or service class is declared on the endpoint (I'm using just a WSDL).

      The problem is solved, and the context is properly started-up, if the method is modified as follows:

          private void addPolicies(AbstractServiceFactoryBean factory, Server server, Class<?> cls) {
              List<Policy> list = CastUtils.cast((List<?>)server.getEndpoint().getEndpointInfo()
                                                 .getInterface().removeProperty(EXTRA_POLICIES));
              if (list != null) {
                  addPolicies(factory, server.getEndpoint(), cls, list, Policy.Placement.BINDING);
              }
              // --- Start of modification ---
              if (cls == null) {
                  return;
              }
              // --- End of modification ---
          ...
      

      I can provide a sample application to exhibit the problem, if that helps.

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            mranest Anestis Georgiadis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: