Hi 

I have multiple third party web services (I connect to a third party web 
service) and a server RESTfull web service (web service clients connect to me) 
in a Spring application.

One third party web service is only working if a policy engine is specified like

   <bean id="org.apache.cxf.ws.policy.PolicyEngine" 
class="org.apache.cxf.ws.policy.PolicyEngineImpl">
      <property name="bus" ref="cxf"/>
      <property name="enabled" value="true"/>
   </bean>

as it otherwise throws the following exception:

java.lang.NullPointerException
 at 
org.apache.cxf.ws.policy.WSPolicyFeature.initialize(WSPolicyFeature.java:100)
 at 
org.apache.cxf.ws.policy.WSPolicyFeature.initializeEndpointPolicy(WSPolicyFeature.java:139)
 at 
org.apache.cxf.ws.policy.WSPolicyFeature.initialize(WSPolicyFeature.java:112)
 at 
org.apache.cxf.frontend.ClientFactoryBean.applyFeatures(ClientFactoryBean.java:71)
 at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:60)
 at 
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:102)
 at 
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:115)


But as soon as I add the PolicyEngine bean into the xml my RESTful web service 
does not work any longer. It throws the following null pointer exception:

2010-04-23 13:08:40,758 WARN [org.apache.cxf.phase.PhaseInterceptorChain] - 
Interceptor for {http://party.misc.profidaweb/}PartyServiceRest has thrown 
exception, unwinding now
java.lang.NullPointerException
 at 
org.apache.cxf.ws.policy.PolicyInInterceptor.handle(PolicyInInterceptor.java:132)
 at 
org.apache.cxf.ws.policy.AbstractPolicyInterceptor.handleMessage(AbstractPolicyInterceptor.java:45)
 at 
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
 at 
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:110)
 at 
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98)
 at 
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:423)
 at 
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:139)
 at 
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142)
 at 
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179)
 at 
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:108)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)


I attach my configuration file for the RESTfull web service. The client web 
services are defined in java like:

            Map<String, Object> outProps = new HashMap<String, Object>();
            outProps.put(WSHandlerConstants.ACTION, 
WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN);
            outProps.put(WSHandlerConstants.USER, userPerson.fseLoginType() + 
"\\" + userPerson.getFSELoginName());
            outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
            outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, 
PasswordCallbackHandler.class.getName());
            WSS4JOutInterceptor wss4jOut = new WSS4JOutInterceptor(outProps);
            
            JaxWsProxyFactoryBean wsFactory = new JaxWsProxyFactoryBean();
            wsFactory.getOutInterceptors().add(wss4jOut);
            wsFactory.setServiceClass(FseWebService_DEF.class);
            wsFactory.setAddress(url);
            wsFactory.getFeatures().add(new WSPolicyFeature());
            
            FseWebService_DEF fseWebService = 
(FseWebService_DEF)wsFactory.create();


Please help, how can I either change the client or the RESTfull web service 
declaration to avoid the null pointer exception and have both working next to 
each other?

Best regards
Daniel Putra
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns = "http://www.springframework.org/schema/beans";
       xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance";
       xmlns:jaxrs = "http://cxf.apache.org/jaxrs";
       xmlns:cxf = "http://cxf.apache.org/core";
       xsi:schemaLocation = "http://www.springframework.org/schema/beans 
                             http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                             http://cxf.apache.org/jaxrs
                             http://cxf.apache.org/schemas/jaxrs.xsd
                             http://cxf.apache.org/core
                             http://cxf.apache.org/schemas/core.xsd";>
   
   
   <import resource="classpath:META-INF/cxf/cxf.xml"/>
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
   <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
   <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
   
   
   <jaxrs:server id="profidaRestService" address="/">
      <jaxrs:features>
         <cxf:logging/>
      </jaxrs:features>
      
      <jaxrs:serviceBeans>
         <bean class="profidaweb.misc.party.PartyServiceRest"/>
         <bean class="profidaweb.misc.contract.ContractServiceRest"/>
      </jaxrs:serviceBeans>
      
      <jaxrs:inInterceptors>  
         <ref bean="securityInterceptor"/>  
      </jaxrs:inInterceptors>  
   </jaxrs:server>
   
   
   <bean id="securityInterceptor" class="profidaweb.application.security.BasicAuthAuthorizationInterceptor" init-method="initialise">
      <property name="userService" ref="userService"/>
      <property name="licenseService" ref="licenseService"/>
   </bean>
   
   
   <!-- <bean id="org.apache.cxf.ws.policy.PolicyEngine" class="org.apache.cxf.ws.policy.PolicyEngineImpl">
      <property name="bus" ref="cxf"/>
      <property name="enabled" value="true"/>
   </bean> -->
   
</beans>

Reply via email to