Details
Description
I'm getting "No security action was defined!":
May 6, 2010 12:11:18 PM org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor getAction
WARNING: No security action was defined!
May 6, 2010 12:11:18 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLoggingWARNING: Interceptor for
corporateAuthService has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: No security action was defined!
at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.getAction(WSS4JInInterceptor.java:421)
at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:189)
at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:78)
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:178)
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.doPost(AbstractHTTPServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
When using Spring autowire by type, WSS4jInInterceptor.setProperties() is called twice, thus overwriting my configuration below:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd"
default-autowire="byType">
<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-servlet.xml" />
<jaxws:endpoint id="auth" implementor="#authServiceImpl"
address="/swAuth">
<jaxws:inInterceptors>
<bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor" />
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
<entry key="passwordCallbackRef">
<ref bean="serverPasswordCallback" />
</entry>
</map>
</constructor-arg>
</bean>
</jaxws:inInterceptors>
</jaxws:endpoint>
<bean id="serverPasswordCallback" class="com.company.auth.service.ServerPasswordCallback">
<property name="username">
<value>ws-client</value>
</property>
<property name="password">
<value>123</value>
</property>
</bean>
<bean id="authServiceImpl" class="com.company.auth.service.AuthServiceImpl">
<property name="employeeDao" ref="employeeDao" />
</bean>
</beans>
----------
This is evidenced while debugging:
First time at WSS4JInInterceptor instantiation it calls setProperties() with my values:
Thread [main] (Suspended (breakpoint at line 112 in WSS4JInInterceptor))
WSS4JInInterceptor.<init>(Map<String,Object>) line: 112
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor<T>.newInstance(Object...) line: 513
BeanUtils.instantiateClass(Constructor, Object[]) line: 100
CglibSubclassingInstantiationStrategy(SimpleInstantiationStrategy).instantiate(RootBeanDefinition, String, BeanFactory, Constructor, Object[]) line: 87
ConstructorResolver.autowireConstructor(String, RootBeanDefinition, Constructor[], Object[]) line: 248
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).autowireConstructor(String, RootBeanDefinition, Constructor[], Object[]) line: 925
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBeanInstance(String, RootBeanDefinition, Object[]) line: 835
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 440
AbstractAutowireCapableBeanFactory$1.run() line: 409
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 380
BeanDefinitionValueResolver.resolveInnerBean(Object, String, BeanDefinition) line: 219
BeanDefinitionValueResolver.resolveValueIfNecessary(Object, Object) line: 117
BeanDefinitionValueResolver.resolveManagedList(Object, List) line: 287
BeanDefinitionValueResolver.resolveValueIfNecessary(Object, Object) line: 126
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).applyPropertyValues(String, BeanDefinition, BeanWrapper, PropertyValues) line: 1245
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).populateBean(String, AbstractBeanDefinition, BeanWrapper) line: 1010
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 472
AbstractAutowireCapableBeanFactory$1.run() line: 409
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 380
AbstractBeanFactory$1.getObject() line: 264
DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String, ObjectFactory) line: 222
DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String, Class, Object[], boolean) line: 261
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String, Class, Object[]) line: 185
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String) line: 164
DefaultListableBeanFactory.preInstantiateSingletons() line: 429
XmlWebApplicationContext(AbstractApplicationContext).finishBeanFactoryInitialization(ConfigurableListableBeanFactory) line: 728
XmlWebApplicationContext(AbstractApplicationContext).refresh() line: 380
ContextLoader.createWebApplicationContext(ServletContext, ApplicationContext) line: 255
ContextLoader.initWebApplicationContext(ServletContext) line: 199
ContextLoaderListener.contextInitialized(ServletContextEvent) line: 45
StandardContext.listenerStart() line: 3972
StandardContext.start() line: 4467
StandardHost(ContainerBase).start() line: 1045
StandardHost.start() line: 722
StandardEngine(ContainerBase).start() line: 1045
StandardEngine.start() line: 443
StandardService.start() line: 516
StandardServer.start() line: 710
Catalina.start() line: 593
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
Bootstrap.start() line: 289
Bootstrap.main(String[]) line: 414
And then another invokation to setProperties(Map):
Thread [main] (Suspended (breakpoint at line 130 in AbstractWSS4JInterceptor))
WSS4JInInterceptor(AbstractWSS4JInterceptor).setProperties(Map<String,Object>) line: 130
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
BeanWrapperImpl.setPropertyValue(BeanWrapperImpl$PropertyTokenHolder, PropertyValue) line: 840
BeanWrapperImpl.setPropertyValue(PropertyValue) line: 651
BeanWrapperImpl(AbstractPropertyAccessor).setPropertyValues(PropertyValues, boolean, boolean) line: 78
BeanWrapperImpl(AbstractPropertyAccessor).setPropertyValues(PropertyValues) line: 59
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).applyPropertyValues(String, BeanDefinition, BeanWrapper, PropertyValues) line: 1276
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).populateBean(String, AbstractBeanDefinition, BeanWrapper) line: 1010
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 472
AbstractAutowireCapableBeanFactory$1.run() line: 409
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 380
BeanDefinitionValueResolver.resolveInnerBean(Object, String, BeanDefinition) line: 219
BeanDefinitionValueResolver.resolveValueIfNecessary(Object, Object) line: 117
BeanDefinitionValueResolver.resolveManagedList(Object, List) line: 287
BeanDefinitionValueResolver.resolveValueIfNecessary(Object, Object) line: 126
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).applyPropertyValues(String, BeanDefinition, BeanWrapper, PropertyValues) line: 1245
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).populateBean(String, AbstractBeanDefinition, BeanWrapper) line: 1010
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 472
AbstractAutowireCapableBeanFactory$1.run() line: 409
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 380
AbstractBeanFactory$1.getObject() line: 264
DefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String, ObjectFactory) line: 222
DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String, Class, Object[], boolean) line: 261
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String, Class, Object[]) line: 185
DefaultListableBeanFactory(AbstractBeanFactory).getBean(String) line: 164
DefaultListableBeanFactory.preInstantiateSingletons() line: 429
XmlWebApplicationContext(AbstractApplicationContext).finishBeanFactoryInitialization(ConfigurableListableBeanFactory) line: 728
XmlWebApplicationContext(AbstractApplicationContext).refresh() line: 380
ContextLoader.createWebApplicationContext(ServletContext, ApplicationContext) line: 255
ContextLoader.initWebApplicationContext(ServletContext) line: 199
ContextLoaderListener.contextInitialized(ServletContextEvent) line: 45
StandardContext.listenerStart() line: 3972
StandardContext.start() line: 4467
StandardHost(ContainerBase).start() line: 1045
StandardHost.start() line: 722
StandardEngine(ContainerBase).start() line: 1045
StandardEngine.start() line: 443
StandardService.start() line: 516
StandardServer.start() line: 710
Catalina.start() line: 593
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
Bootstrap.start() line: 289
Bootstrap.main(String[]) line: 414