Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Not A Problem
-
3.2.5
-
None
-
None
-
I am using JDK 1.8.0_144, Apache CXF 3.2.5, Tomcat 8.0.5, and Spring 5.0.4 for this sample project.
-
Unknown
Description
I successfully published a simple JAX-WS web-service using Apache CXF Spring configuration. I am now trying to configure an inbound interceptor for that service. The Interceptor works fine when I use the following configuration:
<jaxws:endpoint id="helloWorld-ws"
implementor="com.nit.ws.service.impl.HelloWorldServiceImpl" address="/HelloWorldService">
<jaxws:inInterceptors>
<ref bean="httpAuthHeaderInterceptor" />
</jaxws:inInterceptors>
</jaxws:endpoint>
<bean id="httpAuthHeaderInterceptor" class="com.nit.ws.security.HttpAuthHeaderInterceptor" />
However, if I try to configure the interceptor using a CXF Bus instead of above configuration like below:
<jaxws:endpoint id="helloWorld-ws" bus="serverBus"
implementor="com.nit.ws.service.impl.HelloWorldServiceImpl" address="/HelloWorldService"/>
<cxf:bus name="serverBus">
<cxf:inInterceptors>
<ref bean="httpAuthHeaderInterceptor" />
</cxf:inInterceptors>
</cxf:bus>
<bean id="httpAuthHeaderInterceptor" class="com.nit.ws.security.HttpAuthHeaderInterceptor" />
*Then it throws the following exception in Tomcat 8 server when I hit the WSDL(http://localhost:8080/springcxfserver/services/HelloWorldService?wsdl):*
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' available org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:686) org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1205) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:205) org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1091) org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:80) org.apache.cxf.transport.servlet.CXFNonSpringServlet.init(CXFNonSpringServlet.java:83) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
The HttpAuthHeaderInterceptor extends org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor and it just prints "Hello World" on the console in case of successful execution as defined above.
I am trying to use Bus configuration so that all the JAX-WS endpoints can be configured using the same bus configuration to allow applying common interceptors to all of them without duplicating the configuration in each element.
I've attached the web.xml, application-context.xml, cxf-beans.xml, and dispatcher-servlet.xml with this ticket for ready reference. The configurations described above have been defined inside cxf-beans.xml which is imported by application-context.xml.application-context.xml
I am using JDK 1.8.0_144, Apache CXF 3.2.5, Tomcat 8.0.5, and Spring 5.0.4 for this sample project.
The pom.xml snippet for Apache CXF dependencies is as follows:
<!-- Apache CXF Dependencies starts -->
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.2.5</version>
</dependency>
<!-- Apache CXF Dependencies ends -->