没有任何政策选择可以满足例外

时间:2012-06-20 08:38:07

标签: jboss cxf webservice-client ws-security policy

我尝试了之前的消息/论坛中提到的许多选项。它们中的任何一个似乎都无效。

请在这方面帮助我。请注意,我必须编写一个客户端,因为该服务已由其他供应商托管:

问题:

我在JAVA 1.5上使用jboss-4.2.3GA和Apache CXF 2.6。(使用ANT作为构建工具)

我有一个需要WssUsername Token。(PasswordText)机制的Web服务。

a)我确定了cxf-rt-core-2.2.7.jar,cxf-ws-addr-2.2.7.jar,cxf-rt-ws-policy-2.2.7.jar,cxf-rt -ws-security-2.2.7.jar都在classpath上。

b)也导入了以下XML:

<import resource="classpath:META-INF/cxf/cxf.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-extension-ws-security.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-policy.xml" />  
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-addr.xml" />

c)配置我的政策如下:

<cxf:bus>
      <cxf:features>
      <p:policies/>
         <cxf:logging/>
      </cxf:features>
      <cxf:inInterceptors>
            <ref bean="logInbound"/>
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outFaultInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="logInbound"/>
        </cxf:inFaultInterceptors>  
   </cxf:bus>


  <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>


   <jaxws:client name="{namespace of the WSDL}<name attribute of the desired wsdl:port elementname   createdFromAPI="true"> 
        <jaxws:properties>
        <entry key="ws-security.username" value="myusername"/>
        <entry key="ws-security.password" value="mypassword"/>        
        </jaxws:properties>
  </jaxws:client>

我的堆栈跟踪:

org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.mymethod(Unknown Source) 
        at com.rest.test.MyClass.MyMethod(MyClass.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89) 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) 
        ... 41 more 
12:14:01,513 ERROR [STDERR] Jun 20, 2012 12:14:01 PM org.apache.cxf.phase.PhaseInterceptorChain unwind 
WARNING: Exception in handleFault on interceptor org.apache.cxf.binding.xml.interceptor.XMLFaultOutInterceptor@cfdc01 
org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.MyMethod(Unknown Source) 
        at com.rest.test.MyCass.MyMethod(MyClass.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89) 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) 
        ... 41 more 
12:14:01,786 ERROR [STDERR] Jun 20, 2012 12:14:01 PM org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver onMessage 
SEVERE: Error occurred during error handling, give up! 
org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.MyMethod(Unknown Source) 
        at com.rest.test.MyClass.MyMethod(MyClass.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89) 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) 
        ... 41 more 
12:14:01,935 ERROR [[CXFServlet]] Servlet.service() for servlet CXFServlet threw exception 
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:116) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:322) 
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211) 
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) 
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) 
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:129) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:187) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:115) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:690) 
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:166) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) 
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230) 
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182) 
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84) 
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157) 
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
        at com.redhat.jboss.support.ConfigureSessionCookieValve.invoke(ConfigureSessionCookieValve.java:20) 
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262) 
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) 
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446) 
        at java.lang.Thread.run(Thread.java:595) 
Caused by: org.apache.cxf.interceptor.Fault: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:162) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:128) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167) 
        at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58) 
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94) 
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262) 
        ... 28 more 
Caused by: javax.xml.ws.soap.SOAPFaultException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) 
        at $Proxy190.MyMethod(Unknown Source) 
        at com.rest.test.MyClass.MyMethod(FirstCXF.java:123) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:585) 
        at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180) 
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) 
        ... 33 more 
Caused by: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied. 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.chooseAlternative(EndpointPolicyImpl.java:165) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.finalizeConfig(EndpointPolicyImpl.java:145) 
        at org.apache.cxf.ws.policy.EndpointPolicyImpl.initialize(EndpointPolicyImpl.java:141) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.createEndpointPolicyInfo(PolicyEngineImpl.java:549) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getEndpointPolicy(PolicyEngineImpl.java:295) 
        at org.apache.cxf.ws.policy.PolicyEngineImpl.getClientEndpointPolicy(PolicyEngineImpl.java:278) 
        at org.apache.cxf.ws.policy.PolicyDataEngineImpl.getClientEndpointPolicy(PolicyDataEngineImpl.java:61) 
        at org.apache.cxf.transport.http.HTTPConduit.updateClientPolicy(HTTPConduit.java:318) 
        at org.apache.cxf.transport.http.HTTPConduit.<init>(HTTPConduit.java:303) 
        at org.apache.cxf.transport.http.HTTPTransportFactory.getConduit(HTTPTransportFactory.java:250) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:228) 
        at org.apache.cxf.binding.soap.SoapTransportFactory.getConduit(SoapTransportFactory.java:235) 
        at org.apache.cxf.endpoint.AbstractConduitSelector.getSelectedConduit(AbstractConduitSelector.java:103) 
        at org.apache.cxf.endpoint.UpfrontConduitSelector.prepare(UpfrontConduitSelector.java:63) 
        at org.apache.cxf.endpoint.ClientImpl.prepareConduitSelector(ClientImpl.java:846) 
        at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:527) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367) 
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320) 
        at org.apache.cx

1 个答案:

答案 0 :(得分:0)

我已经发现问题是jaxws:client中的错误命名空间和端口详细信息。

我也使用了WSS4JOutInterceptor而不是ws-security标签。