Ok, I solved it using a @Qualifier annotation:
@Autowired
@Qualifier("javax.xml.ws.WebServiceContext")
private WebServiceContext wsContext;
This works because the id of a bean is used as a fallback if no qualifier
is defined.
But nevertheless I would like to know whether the second bean definition
was introduced by intention and using Autowired/Qualifier is the official
way to go now.
Maybe someone can add an explicit qualifier to the bean definitions in
'cxf-extension-jaxws.xml' or add 'autowire="byName"' (and use short ids)?
Robin Sander wrote:
Hi,
after an update to CXF 2.1.3 (from 2.1.2) a JAX-WS web service resource
does
not get injected anymore. I'm using Spring 2.5.6 and Tomcat 6.0.18 and
really
want to stick to Spring 2.5, so I would rather downgrade to CXF 2.1.2 if
there
is no solution to this issue (before this question gets raised...)
Before the update the field was injected using Spring's @Autowired
annotation
(by type), the definition was as follows:
@Autowired
private WebServiceContext wsContext;
With a @Resource annotation it also worked but I changed everything to
@Autowired
for a couple of reasons.
After the update to 2.1.3 Spring complains about having two candidates
for the
Autowired field and I think this is due to 'cxf-extension-jaxws.xml'
defining two
beans of class 'org.apache.cxf.jaxws.context.WebServiceContextImpl' now:
<bean class="org.apache.cxf.jaxws.context.WebServiceContextImpl"
id="org.apache.cxf.jaxws.context.WebServiceContextImpl"
lazy-init="true"/>
<bean class="org.apache.cxf.jaxws.context.WebServiceContextImpl"
id="javax.xml.ws.WebServiceContext" lazy-init="true"/>
So I changed back to @Resource and even tried @Resource(name =
"org.apache.cxf.jaxws.context.WebServiceContextImpl") as Daniel Kulp
suggested
in another thread (for a different problem) but the field is always null
now!
So it seems that CXF 2.1.3 and Spring 2.5.6 can not work together can they?
Why was the second bean definition added to cxf-extension-jaxws.xml?
Can I simply remove it or was there a specific reason?
My Web-Services are configured as proxies to Spring managed beans, like
this:
<context:annotation-config/>
<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-jaxws.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<!-- Java first -->
<bean id="firstService" lazy-init="true" scope="session"
class="com.impl.FirstServiceImpl">
<aop:scoped-proxy proxy-target-class="true" />
</bean>
<jaxws:endpoint id="first" implementor="#firstService"
implementorClass="com.impl.FirstServiceImpl"
address="/first">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
</jaxws:endpoint>
regards,
Robin.