[
https://issues.apache.org/jira/browse/CXF-7785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16538116#comment-16538116
]
Nitin Bhardwaj commented on CXF-7785:
-------------------------------------
Sure. I've attached the springcxfserver (maven project) which you can just
build at your end using maven to get a WAR. It contains cxf-beans.xml (imported
by default in application-context.xml) and the cxf-beans_BUS.xml.
For a successful run use {color:#205081}cxf-beans.xml{color} in the
{color:#205081}application-context.xml{color}, and to reproduce the error just
use {color:#205081}cxf-beans_BUS.xml{color} in its place. You can test by
hitting the URL:
[http://localhost:8080/springcxfserver/services/HelloWorldService?wsdl]
(assuming that you're running it on Tomcat 8's port 8080).
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
> named 'cxf' available
> ----------------------------------------------------------------------------------------------
>
> Key: CXF-7785
> URL: https://issues.apache.org/jira/browse/CXF-7785
> Project: CXF
> Issue Type: Bug
> Components: Bus, Integration
> Affects Versions: 3.2.5
> Environment: 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.
> Reporter: Nitin Bhardwaj
> Priority: Minor
> Attachments: application-context.xml, cxf-beans.xml,
> cxf-beans_BUS.xml, dispatcher-servlet.xml, springcxfserver.zip, web.xml
>
>
> 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:
> {color:#205081} <jaxws:endpoint id="helloWorld-ws" {color}
> {color:#205081} implementor="com.nit.ws.service.impl.HelloWorldServiceImpl"
> address="/HelloWorldService">{color}
> {color:#205081} <jaxws:inInterceptors>{color}
> {color:#205081} <ref bean="httpAuthHeaderInterceptor" />{color}
> {color:#205081} </jaxws:inInterceptors>{color}
> {color:#205081} </jaxws:endpoint>{color}
> {color:#205081} <bean id="httpAuthHeaderInterceptor"
> class="com.nit.ws.security.HttpAuthHeaderInterceptor" />{color}
> However, if I try to configure the interceptor using a CXF Bus instead of
> above configuration like below:
> {color:#205081} <jaxws:endpoint id="helloWorld-ws" bus="serverBus" {color}
> {color:#205081} implementor="com.nit.ws.service.impl.HelloWorldServiceImpl"
> address="/HelloWorldService"/>{color}
> {color:#205081} <cxf:bus name="serverBus">{color}
> {color:#205081} <cxf:inInterceptors>{color}
> {color:#205081} <ref bean="httpAuthHeaderInterceptor" />{color}
> {color:#205081} </cxf:inInterceptors>{color}
> {color:#205081} </cxf:bus>{color}
> {color:#205081} <bean id="httpAuthHeaderInterceptor"
> class="com.nit.ws.security.HttpAuthHeaderInterceptor" />{color}
> *Then it throws the following exception in Tomcat 8 server when I hit the
> WSDL([http://localhost:8080/springcxfserver/services/HelloWorldService?wsdl):*]
> {color:#ff0000}*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){color}
> The *HttpAuthHeaderInterceptor* extends
> {color:#205081}org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor{color}
> 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:
> {color:#205081} <!-- Apache CXF Dependencies starts -->{color}
> {color:#205081} <!--
> https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws
> -->{color}
> {color:#205081} <dependency>{color}
> {color:#205081} <groupId>org.apache.cxf</groupId>{color}
> {color:#205081} <artifactId>cxf-rt-frontend-jaxws</artifactId>{color}
> {color:#205081} <version>3.2.5</version>{color}
> {color:#205081} </dependency>{color}
>
> {color:#205081}<dependency>{color}
> {color:#205081} <groupId>org.apache.cxf</groupId>{color}
> {color:#205081} <artifactId>cxf-rt-transports-http</artifactId>{color}
> {color:#205081} <version>3.2.5</version>{color}
> {color:#205081} </dependency>{color}
> {color:#205081} <!-- Apache CXF Dependencies ends -->{color}
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)