Robin,
The second bean definition was added because in one of the Spring versions
that we were using (2.5.4 I think, maybe 2.5.2), it couldn't find the bean to
inject. The injector was just doing field.getClass().getName() to determine
the bean name. We didn't have a bean of that name and thus nothing got
injected.
The @Resource definitely should work. Not sure why that didn't work.
Hmm..... Not good.
At one point for 2.1.3, I actually added the bean:
<bean
class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/>
to the META-INF/cxf/cxf.xml file and ran all the tests to make sure CXF would
work properly letting Spring do all the injection. Nothing failed so I kind
of assumed it was working fine. Any chance you could create a small test
project (maven based would be awesome :-) to show the issue? Definitely
easier to debug then. Maybe add a bunch of WebServiceContext fields with
different annotations to show what works and doesn't work. That would be
great.
Dan
On Friday 07 November 2008 4:22:26 am Robin Sander wrote:
> 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.
--
Daniel Kulp
[EMAIL PROTECTED]
http://dankulp.com/blog