This is actually not a problem with your WSDL, as far as I can see. Policy references can be embedded in policy documents, and you're allowed to embed the policy documents directly as children of the WSDL components.
The NPE is caused by CXF not setting a policy context for Neethi when normalizing the policy. I've created a bug for this core issue: https://issues.apache.org/jira/browse/CXF-3037 - Dennis On 09/26/2010 05:00 AM, Aki Yoshida wrote: > Hi Dan, > Thanks for your advice. It turned out the real problem was actually in > the WSDL file. > > The original WSDL file was large, so I tried to make a simpler one > based on hello_world_rm.wsdl by adding the same policy usage. Then, I > noticed that the policy reference was incorrectly referenced in the > original WSDL. By fixing this wrong usage, the NPE disappeared. > > So, the problem has been solved. But I think throwing another > exception would be more appropriate than throwing the NPE, so for now, > I explain what caused this error. > > The broken WSDL had something like: > > <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter"> > <wsp:Policy> > <wsp:PolicyReference URI="#binding_policy"/> > </wsp:Policy> > > instead of the correct way of: > > <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter"> > <wsp:PolicyReference URI="#binding_policy"/> > > Then, this lead to the NPE at > Caused by: java.lang.NullPointerException > at > org.apache.neethi.AbstractPolicyOperator.normalizeOperator(AbstractPolicyOperator.java:116) > at > org.apache.neethi.AbstractPolicyOperator.normalize(AbstractPolicyOperator.java:73) > at org.apache.neethi.Policy.normalize(Policy.java:64) > at org.apache.neethi.Policy.normalize(Policy.java:49) > at > org.apache.cxf.ws.policy.EndpointPolicyImpl.initializePolicy(EndpointPolicyImpl.java:144) > at > org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:131) > at > org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:482) > at > org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:229) > at > org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:211) > at > org.apache.cxf.transport.http.policy.PolicyUtils.getClient(PolicyUtils.java:150) > ... > > I will look into it to see where we can detect this usage and throw > another exception. > > Thanks. > Regards, aki > > On Fri, Sep 24, 2010 at 10:12 PM, Daniel Kulp <[email protected]> wrote: > >> Honestly, without seeing the wsdl/policies, I'm not sure what to suggest to >> look at. If you could create a small example and attach to a JIRA, that >> could >> potentially be a start. >> >> Dan >> >> >> On Thursday 23 September 2010 10:25:15 am Aki Yoshida wrote: >> >>> Hi, >>> When I use a WSDL file with some ws-policy entries, I am getting an >>> NPE from my CXF client (2.2.9/10/11 and trunk). >>> I was wondering if there is some configuration issue or there is some >>> issue with the way how CXF uses neethi. >>> >>> As I observed, both org.apache.cxf.ws.policy.EffectivePolicyImpl and >>> org.apache.cxf.ws.policy.EndpointPolicyImpl lead to a call >>> policy.normalize(true), where policy is an instance of >>> org.apache.neethi.Policy. >>> >>> And this method of Policy in neethi 2.0.4 calls another method with >>> the policy registry parameter set as null. >>> >>> org.apache.neethi.Policy >>> 48: public PolicyComponent normalize(boolean deep) { >>> 49: return normalize(null, deep); >>> 50: } >>> >>> This method subsequently calls AbstractPolicyOperator's >>> normalizeOperator. Since parameter reg is given as null, line 116 of >>> this method is throwing an NPE. >>> >>> org.apache.neethi.AbstractPolicyOperator >>> 77: private static PolicyComponent >>> normalizeOperator(PolicyOperator operator, PolicyRegistry reg, boolean >>> deep) { >>> 78: >>> 79: short type = operator.getType(); >>> ... >>> 114: } else if (policyComponent.getType() == >>> Constants.TYPE_POLICY_REF) { >>> 115: String uri = ((PolicyReference) >>> policyComponent).getURI(); 116: policyComponent = >>> reg.lookup(uri); >>> >>> Can someone give an advice here how to solve this problem without >>> modifying the WSDL? >>> >>> Thanks. >>> Regards, aki >>> >> -- >> Daniel Kulp >> [email protected] >> http://dankulp.com/blog >> >> >
