You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "D'Arcy, Hamlet B" <Ha...@Pearson.com> on 2009/04/09 20:43:12 UTC
Tomcat + CXF + Spring 2.5 @Configurable silently failing
I've been trying for a long time to get the Spring 2.5 @Configurable
annotation to work with a CXF 2.2 service in Tomcat 6.0.18. I have no
idea why it is not working.
Here is what I'm trying to do:
I have a bean named example.User that is meant to be marshalled and
unmarshalled by the service. That bean needs to have a dependency
injected by Spring at runtime.
package example;
@Configurable
public class User {
@Autowired private MyDependency bean;
...
}
My service class uses the User class:
package example;
@WebService
public class UserService {
@WebMethod public void createUser(User spec) {
... Need to have User injected with dependencies after JAX-B
creats it
}
}
My unit test that uses the @RunWith(SpringJUnit4ClassRunner.class)
annotation runs just fine, and Spring applies the AOP injection just
fine:
package example;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "applicationContext.xml" })
public class SpringConfigTest {
@Test public void testAop() {
Assert.assertTrue("Spring @Configured injection broken", new
User().hasDatasource());
}
}
But it doesn't work in Tomcat. I feel like I've tried everything. Here
is my tomcat config:
$tomcat/lib/spring-agent.jar
$tomcat/lib/aspectjweaver.jar
$tomcat/conf/context.xml
$tomcat/CxfPrototype/META-INF/aop.xml
$tomcat/CxfPrototype/WEB-INF/web.xml (contains typical
servlet-mapping)
$tomcat/CxfPrototype/WEB-INF/lib (contains all Spring jars +
spring-tomcat-weaver.jar)
$tomcat/CxfPrototype/WEB-INF/classes/... (contains all class files and
cxf.xml)
I wired in the TomcatInstrumentalClassLoader in context.xml:
<Context>
<Loader
loaderClass="org.springframework.instrument.classloading.tomcat.TomcatIn
strumentableClassLoader"
useSystemClassLoaderAsParent="false" />
</Context>
I wired in the Spring aspects in aop.xml:
<aspectj>
<weaver options="-verbose -showWeaveInfo">
<include within="example..*" />
</weaver>
<aspects>
<aspect
name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurer
Aspect" />
</aspects>
</aspectj>
And I told cxf.xml to be aware of the annotations:
<context:annotation-config/>
<context:spring-configured/>
<context:load-time-weaver/>
<context:component-scan base-package="example"/>
Lastly, I started Tomcat with the agent:
-javaagent:$tomcat\lib\spring-agent.jar
Does anyone have any idea why the load time weaving would simply not
happen? I feel like I've tried everything!
--
Hamlet D'Arcy
hamlet.darcy@pearson.com
Re: Tomcat + CXF + Spring 2.5 @Configurable silently failing
Posted by Daniel Kulp <dk...@apache.org>.
On Fri April 10 2009 9:46:57 am D'Arcy, Hamlet B wrote:
> > Basically, define the implemenation as a spring bean and
> > spring will create it
> > and inject everything. If you just pass us a class, we just do
> > class.forName(...).newInstance() and it won't get springified.
>
> This fixes my problem, but I don't understand why.
I'm really not 100% sure why. I THINK that when you let spring create the
service impl with the load time stuff setup, it MAY be setting up a new
classloader or something that would intercept the reflection type calls to
create the beans so it can do the injection. When we just do
Class.forName(...), we just get it from the current context classloader or
something that doesn't have that setup.
I wish I knew more about it to give a better answer. :-(
Dan
>
> It is not my service/implementor class that I want Spring to dependency
> inject... it is the JAX-B serialized domain classes that are passed to
> the service as parameters.
>
> When I mark my domain class as @Configurable, I want Spring's Load Time
> Weaving to autowire the bean after JAX-B invokes the no-arg constructor.
> Why is this related to how my service/implementor class is created?
>
> Thank you for the help, your advice was perfect. Any help understanding
> why the advice worked is appreciated.
>
> --
> Hamlet D'Arcy
> hamlet.darcy@pearson.com
> +1(952)681-3636
>
> > -----Original Message-----
> > From: Daniel Kulp [mailto:dkulp@apache.org]
> > Sent: Thursday, April 09, 2009 2:59 PM
> > To: users@cxf.apache.org
> > Cc: D'Arcy, Hamlet B
> > Subject: Re: Tomcat + CXF + Spring 2.5 @Configurable silently failing
> >
> >
> >
> > Change the jaxws:endpoint thing to look something like:
> >
> >
> > <bean id="impl" class="example.UserService"/>
> >
> > <jaxws:endpoint id="user"
> > implementor="#impl"
> > address="/UserService">
> > </jaxws:endpoint>
> >
> >
> > Basically, define the implemenation as a spring bean and
> > spring will create it
> > and inject everything. If you just pass us a class, we just do
> > class.forName(...).newInstance() and it won't get springified.
> >
> > Dan
> >
> > On Thu April 9 2009 3:48:50 pm D'Arcy, Hamlet B wrote:
> > > It looks exactly like this:
> > >
> > >
> > > <beans xmlns="http://www.springframework.org/schema/beans"
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > xmlns:jaxws="http://cxf.apache.org/jaxws"
> > > xmlns:context="http://www.springframework.org/schema/context"
> > > xmlns:cxf="http://cxf.apache.org/core"
> > >
> > > 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
> > > http://www.springframework.org/schema/context
> > > http://www.springframework.org/schema/context/spring-context.xsd
> > > http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
> > >
> > > <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"/>
> > >
> > >
> > > <context:annotation-config/>
> > > <context:spring-configured/>
> > > <context:load-time-weaver/>
> > > <context:component-scan base-package="example"/>
> > >
> > > <jaxws:endpoint id="user"
> > > implementor="example.UserService"
> > > address="/UserService">
> > > </jaxws:endpoint>
> > > </beans>
> > >
> > > > -----Original Message-----
> > > > From: Daniel Kulp [mailto:dkulp@apache.org]
> > > > Sent: Thursday, April 09, 2009 2:37 PM
> > > > To: users@cxf.apache.org
> > > > Cc: D'Arcy, Hamlet B
> > > > Subject: Re: Tomcat + CXF + Spring 2.5 @Configurable
> >
> > silently failing
> >
> > > > What does your applicationContext.xml file look like? In
> > > > particular, the
> > > > jaxws:endpoint definition and related beans?
> > > >
> > > > Dan
> > > >
> > > > On Thu April 9 2009 2:43:12 pm D'Arcy, Hamlet B wrote:
> > > > > I've been trying for a long time to get the Spring 2.5
> >
> > @Configurable
> >
> > > > > annotation to work with a CXF 2.2 service in Tomcat 6.0.18.
> > > >
> > > > I have no
> > > >
> > > > > idea why it is not working.
> > > > >
> > > > > Here is what I'm trying to do:
> > > > >
> > > > > I have a bean named example.User that is meant to be
> >
> > marshalled and
> >
> > > > > unmarshalled by the service. That bean needs to have a
> >
> > dependency
> >
> > > > > injected by Spring at runtime.
> > > > >
> > > > > package example;
> > > > >
> > > > > @Configurable
> > > > > public class User {
> > > > > @Autowired private MyDependency bean;
> > > > > ...
> > > > > }
> > > > >
> > > > > My service class uses the User class:
> > > > >
> > > > > package example;
> > > > >
> > > > > @WebService
> > > > > public class UserService {
> > > > > @WebMethod public void createUser(User spec) {
> > > > > ... Need to have User injected with dependencies
> >
> > after JAX-B
> >
> > > > > creats it
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > > My unit test that uses the
> >
> > @RunWith(SpringJUnit4ClassRunner.class)
> >
> > > > > annotation runs just fine, and Spring applies the AOP
> >
> > injection just
> >
> > > > > fine:
> > > > >
> > > > > package example;
> > > > >
> > > > > @RunWith(SpringJUnit4ClassRunner.class)
> > > > > @ContextConfiguration(locations = {
> >
> > "applicationContext.xml" })
> >
> > > > > public class SpringConfigTest {
> > > > >
> > > > > @Test public void testAop() {
> > > > > Assert.assertTrue("Spring @Configured injection
> >
> > broken", new
> >
> > > > > User().hasDatasource());
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > > But it doesn't work in Tomcat. I feel like I've tried
> > > >
> > > > everything. Here
> > > >
> > > > > is my tomcat config:
> > > > >
> > > > > $tomcat/lib/spring-agent.jar
> > > > > $tomcat/lib/aspectjweaver.jar
> > > > > $tomcat/conf/context.xml
> > > > > $tomcat/CxfPrototype/META-INF/aop.xml
> > > > > $tomcat/CxfPrototype/WEB-INF/web.xml (contains typical
> > > > > servlet-mapping)
> > > > > $tomcat/CxfPrototype/WEB-INF/lib (contains all
> >
> > Spring jars +
> >
> > > > > spring-tomcat-weaver.jar)
> > > > > $tomcat/CxfPrototype/WEB-INF/classes/... (contains all
> > > >
> > > > class files and
> > > >
> > > > > cxf.xml)
> > > > >
> > > > > I wired in the TomcatInstrumentalClassLoader in context.xml:
> > > > >
> > > > > <Context>
> > > > > <Loader
> > > >
> > > > loaderClass="org.springframework.instrument.classloading.tomca
> > > > t.TomcatIn
> > > >
> > > > > strumentableClassLoader"
> > > > > useSystemClassLoaderAsParent="false" />
> > > > > </Context>
> > > > >
> > > > > I wired in the Spring aspects in aop.xml:
> > > > >
> > > > > <aspectj>
> > > > > <weaver options="-verbose -showWeaveInfo">
> > > > > <include within="example..*" />
> > > > > </weaver>
> > > > > <aspects>
> > > > > <aspect
> > > >
> > > > name="org.springframework.beans.factory.aspectj.AnnotationBean
> > > > Configurer
> > > >
> > > > > Aspect" />
> > > > > </aspects>
> > > > > </aspectj>
> > > > >
> > > > > And I told cxf.xml to be aware of the annotations:
> > > > >
> > > > > <context:annotation-config/>
> > > > > <context:spring-configured/>
> > > > > <context:load-time-weaver/>
> > > > > <context:component-scan base-package="example"/>
> > > > >
> > > > > Lastly, I started Tomcat with the agent:
> > > > >
> > > > > -javaagent:$tomcat\lib\spring-agent.jar
> > > > >
> > > > > Does anyone have any idea why the load time weaving
> >
> > would simply not
> >
> > > > > happen? I feel like I've tried everything!
> > > > >
> > > > >
> > > > > --
> > > > > Hamlet D'Arcy
> > > > > hamlet.darcy@pearson.com
> > > >
> > > > --
> > > > Daniel Kulp
> > > > dkulp@apache.org
> > > > http://www.dankulp.com/blog
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
RE: Tomcat + CXF + Spring 2.5 @Configurable silently failing
Posted by "D'Arcy, Hamlet B" <Ha...@Pearson.com>.
> Basically, define the implemenation as a spring bean and
> spring will create it
> and inject everything. If you just pass us a class, we just do
> class.forName(...).newInstance() and it won't get springified.
This fixes my problem, but I don't understand why.
It is not my service/implementor class that I want Spring to dependency
inject... it is the JAX-B serialized domain classes that are passed to
the service as parameters.
When I mark my domain class as @Configurable, I want Spring's Load Time
Weaving to autowire the bean after JAX-B invokes the no-arg constructor.
Why is this related to how my service/implementor class is created?
Thank you for the help, your advice was perfect. Any help understanding
why the advice worked is appreciated.
--
Hamlet D'Arcy
hamlet.darcy@pearson.com
+1(952)681-3636
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Thursday, April 09, 2009 2:59 PM
> To: users@cxf.apache.org
> Cc: D'Arcy, Hamlet B
> Subject: Re: Tomcat + CXF + Spring 2.5 @Configurable silently failing
>
>
>
> Change the jaxws:endpoint thing to look something like:
>
>
> <bean id="impl" class="example.UserService"/>
>
> <jaxws:endpoint id="user"
> implementor="#impl"
> address="/UserService">
> </jaxws:endpoint>
>
>
> Basically, define the implemenation as a spring bean and
> spring will create it
> and inject everything. If you just pass us a class, we just do
> class.forName(...).newInstance() and it won't get springified.
>
> Dan
>
>
>
> On Thu April 9 2009 3:48:50 pm D'Arcy, Hamlet B wrote:
> > It looks exactly like this:
> >
> >
> > <beans xmlns="http://www.springframework.org/schema/beans"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xmlns:jaxws="http://cxf.apache.org/jaxws"
> > xmlns:context="http://www.springframework.org/schema/context"
> > xmlns:cxf="http://cxf.apache.org/core"
> >
> > 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
> > http://www.springframework.org/schema/context
> > http://www.springframework.org/schema/context/spring-context.xsd
> > http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
> >
> > <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"/>
> >
> >
> > <context:annotation-config/>
> > <context:spring-configured/>
> > <context:load-time-weaver/>
> > <context:component-scan base-package="example"/>
> >
> > <jaxws:endpoint id="user"
> > implementor="example.UserService"
> > address="/UserService">
> > </jaxws:endpoint>
> > </beans>
> >
> > > -----Original Message-----
> > > From: Daniel Kulp [mailto:dkulp@apache.org]
> > > Sent: Thursday, April 09, 2009 2:37 PM
> > > To: users@cxf.apache.org
> > > Cc: D'Arcy, Hamlet B
> > > Subject: Re: Tomcat + CXF + Spring 2.5 @Configurable
> silently failing
> > >
> > >
> > > What does your applicationContext.xml file look like? In
> > > particular, the
> > > jaxws:endpoint definition and related beans?
> > >
> > > Dan
> > >
> > > On Thu April 9 2009 2:43:12 pm D'Arcy, Hamlet B wrote:
> > > > I've been trying for a long time to get the Spring 2.5
> @Configurable
> > > > annotation to work with a CXF 2.2 service in Tomcat 6.0.18.
> > >
> > > I have no
> > >
> > > > idea why it is not working.
> > > >
> > > > Here is what I'm trying to do:
> > > >
> > > > I have a bean named example.User that is meant to be
> marshalled and
> > > > unmarshalled by the service. That bean needs to have a
> dependency
> > > > injected by Spring at runtime.
> > > >
> > > > package example;
> > > >
> > > > @Configurable
> > > > public class User {
> > > > @Autowired private MyDependency bean;
> > > > ...
> > > > }
> > > >
> > > > My service class uses the User class:
> > > >
> > > > package example;
> > > >
> > > > @WebService
> > > > public class UserService {
> > > > @WebMethod public void createUser(User spec) {
> > > > ... Need to have User injected with dependencies
> after JAX-B
> > > > creats it
> > > > }
> > > > }
> > > >
> > > >
> > > > My unit test that uses the
> @RunWith(SpringJUnit4ClassRunner.class)
> > > > annotation runs just fine, and Spring applies the AOP
> injection just
> > > > fine:
> > > >
> > > > package example;
> > > >
> > > > @RunWith(SpringJUnit4ClassRunner.class)
> > > > @ContextConfiguration(locations = {
> "applicationContext.xml" })
> > > > public class SpringConfigTest {
> > > >
> > > > @Test public void testAop() {
> > > > Assert.assertTrue("Spring @Configured injection
> broken", new
> > > > User().hasDatasource());
> > > > }
> > > > }
> > > >
> > > >
> > > > But it doesn't work in Tomcat. I feel like I've tried
> > >
> > > everything. Here
> > >
> > > > is my tomcat config:
> > > >
> > > > $tomcat/lib/spring-agent.jar
> > > > $tomcat/lib/aspectjweaver.jar
> > > > $tomcat/conf/context.xml
> > > > $tomcat/CxfPrototype/META-INF/aop.xml
> > > > $tomcat/CxfPrototype/WEB-INF/web.xml (contains typical
> > > > servlet-mapping)
> > > > $tomcat/CxfPrototype/WEB-INF/lib (contains all
> Spring jars +
> > > > spring-tomcat-weaver.jar)
> > > > $tomcat/CxfPrototype/WEB-INF/classes/... (contains all
> > >
> > > class files and
> > >
> > > > cxf.xml)
> > > >
> > > > I wired in the TomcatInstrumentalClassLoader in context.xml:
> > > >
> > > > <Context>
> > > > <Loader
> > >
> > > loaderClass="org.springframework.instrument.classloading.tomca
> > > t.TomcatIn
> > >
> > > > strumentableClassLoader"
> > > > useSystemClassLoaderAsParent="false" />
> > > > </Context>
> > > >
> > > > I wired in the Spring aspects in aop.xml:
> > > >
> > > > <aspectj>
> > > > <weaver options="-verbose -showWeaveInfo">
> > > > <include within="example..*" />
> > > > </weaver>
> > > > <aspects>
> > > > <aspect
> > >
> > > name="org.springframework.beans.factory.aspectj.AnnotationBean
> > > Configurer
> > >
> > > > Aspect" />
> > > > </aspects>
> > > > </aspectj>
> > > >
> > > > And I told cxf.xml to be aware of the annotations:
> > > >
> > > > <context:annotation-config/>
> > > > <context:spring-configured/>
> > > > <context:load-time-weaver/>
> > > > <context:component-scan base-package="example"/>
> > > >
> > > > Lastly, I started Tomcat with the agent:
> > > >
> > > > -javaagent:$tomcat\lib\spring-agent.jar
> > > >
> > > > Does anyone have any idea why the load time weaving
> would simply not
> > > > happen? I feel like I've tried everything!
> > > >
> > > >
> > > > --
> > > > Hamlet D'Arcy
> > > > hamlet.darcy@pearson.com
> > >
> > > --
> > > Daniel Kulp
> > > dkulp@apache.org
> > > http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
Re: Tomcat + CXF + Spring 2.5 @Configurable silently failing
Posted by Daniel Kulp <dk...@apache.org>.
Change the jaxws:endpoint thing to look something like:
<bean id="impl" class="example.UserService"/>
<jaxws:endpoint id="user"
implementor="#impl"
address="/UserService">
</jaxws:endpoint>
Basically, define the implemenation as a spring bean and spring will create it
and inject everything. If you just pass us a class, we just do
class.forName(...).newInstance() and it won't get springified.
Dan
On Thu April 9 2009 3:48:50 pm D'Arcy, Hamlet B wrote:
> It looks exactly like this:
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:jaxws="http://cxf.apache.org/jaxws"
> xmlns:context="http://www.springframework.org/schema/context"
> xmlns:cxf="http://cxf.apache.org/core"
>
> 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
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context.xsd
> http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
>
> <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"/>
>
>
> <context:annotation-config/>
> <context:spring-configured/>
> <context:load-time-weaver/>
> <context:component-scan base-package="example"/>
>
> <jaxws:endpoint id="user"
> implementor="example.UserService"
> address="/UserService">
> </jaxws:endpoint>
> </beans>
>
> > -----Original Message-----
> > From: Daniel Kulp [mailto:dkulp@apache.org]
> > Sent: Thursday, April 09, 2009 2:37 PM
> > To: users@cxf.apache.org
> > Cc: D'Arcy, Hamlet B
> > Subject: Re: Tomcat + CXF + Spring 2.5 @Configurable silently failing
> >
> >
> > What does your applicationContext.xml file look like? In
> > particular, the
> > jaxws:endpoint definition and related beans?
> >
> > Dan
> >
> > On Thu April 9 2009 2:43:12 pm D'Arcy, Hamlet B wrote:
> > > I've been trying for a long time to get the Spring 2.5 @Configurable
> > > annotation to work with a CXF 2.2 service in Tomcat 6.0.18.
> >
> > I have no
> >
> > > idea why it is not working.
> > >
> > > Here is what I'm trying to do:
> > >
> > > I have a bean named example.User that is meant to be marshalled and
> > > unmarshalled by the service. That bean needs to have a dependency
> > > injected by Spring at runtime.
> > >
> > > package example;
> > >
> > > @Configurable
> > > public class User {
> > > @Autowired private MyDependency bean;
> > > ...
> > > }
> > >
> > > My service class uses the User class:
> > >
> > > package example;
> > >
> > > @WebService
> > > public class UserService {
> > > @WebMethod public void createUser(User spec) {
> > > ... Need to have User injected with dependencies after JAX-B
> > > creats it
> > > }
> > > }
> > >
> > >
> > > My unit test that uses the @RunWith(SpringJUnit4ClassRunner.class)
> > > annotation runs just fine, and Spring applies the AOP injection just
> > > fine:
> > >
> > > package example;
> > >
> > > @RunWith(SpringJUnit4ClassRunner.class)
> > > @ContextConfiguration(locations = { "applicationContext.xml" })
> > > public class SpringConfigTest {
> > >
> > > @Test public void testAop() {
> > > Assert.assertTrue("Spring @Configured injection broken", new
> > > User().hasDatasource());
> > > }
> > > }
> > >
> > >
> > > But it doesn't work in Tomcat. I feel like I've tried
> >
> > everything. Here
> >
> > > is my tomcat config:
> > >
> > > $tomcat/lib/spring-agent.jar
> > > $tomcat/lib/aspectjweaver.jar
> > > $tomcat/conf/context.xml
> > > $tomcat/CxfPrototype/META-INF/aop.xml
> > > $tomcat/CxfPrototype/WEB-INF/web.xml (contains typical
> > > servlet-mapping)
> > > $tomcat/CxfPrototype/WEB-INF/lib (contains all Spring jars +
> > > spring-tomcat-weaver.jar)
> > > $tomcat/CxfPrototype/WEB-INF/classes/... (contains all
> >
> > class files and
> >
> > > cxf.xml)
> > >
> > > I wired in the TomcatInstrumentalClassLoader in context.xml:
> > >
> > > <Context>
> > > <Loader
> >
> > loaderClass="org.springframework.instrument.classloading.tomca
> > t.TomcatIn
> >
> > > strumentableClassLoader"
> > > useSystemClassLoaderAsParent="false" />
> > > </Context>
> > >
> > > I wired in the Spring aspects in aop.xml:
> > >
> > > <aspectj>
> > > <weaver options="-verbose -showWeaveInfo">
> > > <include within="example..*" />
> > > </weaver>
> > > <aspects>
> > > <aspect
> >
> > name="org.springframework.beans.factory.aspectj.AnnotationBean
> > Configurer
> >
> > > Aspect" />
> > > </aspects>
> > > </aspectj>
> > >
> > > And I told cxf.xml to be aware of the annotations:
> > >
> > > <context:annotation-config/>
> > > <context:spring-configured/>
> > > <context:load-time-weaver/>
> > > <context:component-scan base-package="example"/>
> > >
> > > Lastly, I started Tomcat with the agent:
> > >
> > > -javaagent:$tomcat\lib\spring-agent.jar
> > >
> > > Does anyone have any idea why the load time weaving would simply not
> > > happen? I feel like I've tried everything!
> > >
> > >
> > > --
> > > Hamlet D'Arcy
> > > hamlet.darcy@pearson.com
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
RE: Tomcat + CXF + Spring 2.5 @Configurable silently failing
Posted by "D'Arcy, Hamlet B" <Ha...@Pearson.com>.
It looks exactly like this:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cxf="http://cxf.apache.org/core"
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
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<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"/>
<context:annotation-config/>
<context:spring-configured/>
<context:load-time-weaver/>
<context:component-scan base-package="example"/>
<jaxws:endpoint id="user"
implementor="example.UserService"
address="/UserService">
</jaxws:endpoint>
</beans>
> -----Original Message-----
> From: Daniel Kulp [mailto:dkulp@apache.org]
> Sent: Thursday, April 09, 2009 2:37 PM
> To: users@cxf.apache.org
> Cc: D'Arcy, Hamlet B
> Subject: Re: Tomcat + CXF + Spring 2.5 @Configurable silently failing
>
>
> What does your applicationContext.xml file look like? In
> particular, the
> jaxws:endpoint definition and related beans?
>
> Dan
>
>
> On Thu April 9 2009 2:43:12 pm D'Arcy, Hamlet B wrote:
> > I've been trying for a long time to get the Spring 2.5 @Configurable
> > annotation to work with a CXF 2.2 service in Tomcat 6.0.18.
> I have no
> > idea why it is not working.
> >
> > Here is what I'm trying to do:
> >
> > I have a bean named example.User that is meant to be marshalled and
> > unmarshalled by the service. That bean needs to have a dependency
> > injected by Spring at runtime.
> >
> > package example;
> >
> > @Configurable
> > public class User {
> > @Autowired private MyDependency bean;
> > ...
> > }
> >
> > My service class uses the User class:
> >
> > package example;
> >
> > @WebService
> > public class UserService {
> > @WebMethod public void createUser(User spec) {
> > ... Need to have User injected with dependencies after JAX-B
> > creats it
> > }
> > }
> >
> >
> > My unit test that uses the @RunWith(SpringJUnit4ClassRunner.class)
> > annotation runs just fine, and Spring applies the AOP injection just
> > fine:
> >
> > package example;
> >
> > @RunWith(SpringJUnit4ClassRunner.class)
> > @ContextConfiguration(locations = { "applicationContext.xml" })
> > public class SpringConfigTest {
> >
> > @Test public void testAop() {
> > Assert.assertTrue("Spring @Configured injection broken", new
> > User().hasDatasource());
> > }
> > }
> >
> >
> > But it doesn't work in Tomcat. I feel like I've tried
> everything. Here
> > is my tomcat config:
> >
> > $tomcat/lib/spring-agent.jar
> > $tomcat/lib/aspectjweaver.jar
> > $tomcat/conf/context.xml
> > $tomcat/CxfPrototype/META-INF/aop.xml
> > $tomcat/CxfPrototype/WEB-INF/web.xml (contains typical
> > servlet-mapping)
> > $tomcat/CxfPrototype/WEB-INF/lib (contains all Spring jars +
> > spring-tomcat-weaver.jar)
> > $tomcat/CxfPrototype/WEB-INF/classes/... (contains all
> class files and
> > cxf.xml)
> >
> > I wired in the TomcatInstrumentalClassLoader in context.xml:
> >
> > <Context>
> > <Loader
> >
> loaderClass="org.springframework.instrument.classloading.tomca
> t.TomcatIn
> > strumentableClassLoader"
> > useSystemClassLoaderAsParent="false" />
> > </Context>
> >
> > I wired in the Spring aspects in aop.xml:
> >
> > <aspectj>
> > <weaver options="-verbose -showWeaveInfo">
> > <include within="example..*" />
> > </weaver>
> > <aspects>
> > <aspect
> >
> name="org.springframework.beans.factory.aspectj.AnnotationBean
> Configurer
> > Aspect" />
> > </aspects>
> > </aspectj>
> >
> > And I told cxf.xml to be aware of the annotations:
> >
> > <context:annotation-config/>
> > <context:spring-configured/>
> > <context:load-time-weaver/>
> > <context:component-scan base-package="example"/>
> >
> > Lastly, I started Tomcat with the agent:
> >
> > -javaagent:$tomcat\lib\spring-agent.jar
> >
> > Does anyone have any idea why the load time weaving would simply not
> > happen? I feel like I've tried everything!
> >
> >
> > --
> > Hamlet D'Arcy
> > hamlet.darcy@pearson.com
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>
Re: Tomcat + CXF + Spring 2.5 @Configurable silently failing
Posted by Daniel Kulp <dk...@apache.org>.
What does your applicationContext.xml file look like? In particular, the
jaxws:endpoint definition and related beans?
Dan
On Thu April 9 2009 2:43:12 pm D'Arcy, Hamlet B wrote:
> I've been trying for a long time to get the Spring 2.5 @Configurable
> annotation to work with a CXF 2.2 service in Tomcat 6.0.18. I have no
> idea why it is not working.
>
> Here is what I'm trying to do:
>
> I have a bean named example.User that is meant to be marshalled and
> unmarshalled by the service. That bean needs to have a dependency
> injected by Spring at runtime.
>
> package example;
>
> @Configurable
> public class User {
> @Autowired private MyDependency bean;
> ...
> }
>
> My service class uses the User class:
>
> package example;
>
> @WebService
> public class UserService {
> @WebMethod public void createUser(User spec) {
> ... Need to have User injected with dependencies after JAX-B
> creats it
> }
> }
>
>
> My unit test that uses the @RunWith(SpringJUnit4ClassRunner.class)
> annotation runs just fine, and Spring applies the AOP injection just
> fine:
>
> package example;
>
> @RunWith(SpringJUnit4ClassRunner.class)
> @ContextConfiguration(locations = { "applicationContext.xml" })
> public class SpringConfigTest {
>
> @Test public void testAop() {
> Assert.assertTrue("Spring @Configured injection broken", new
> User().hasDatasource());
> }
> }
>
>
> But it doesn't work in Tomcat. I feel like I've tried everything. Here
> is my tomcat config:
>
> $tomcat/lib/spring-agent.jar
> $tomcat/lib/aspectjweaver.jar
> $tomcat/conf/context.xml
> $tomcat/CxfPrototype/META-INF/aop.xml
> $tomcat/CxfPrototype/WEB-INF/web.xml (contains typical
> servlet-mapping)
> $tomcat/CxfPrototype/WEB-INF/lib (contains all Spring jars +
> spring-tomcat-weaver.jar)
> $tomcat/CxfPrototype/WEB-INF/classes/... (contains all class files and
> cxf.xml)
>
> I wired in the TomcatInstrumentalClassLoader in context.xml:
>
> <Context>
> <Loader
> loaderClass="org.springframework.instrument.classloading.tomcat.TomcatIn
> strumentableClassLoader"
> useSystemClassLoaderAsParent="false" />
> </Context>
>
> I wired in the Spring aspects in aop.xml:
>
> <aspectj>
> <weaver options="-verbose -showWeaveInfo">
> <include within="example..*" />
> </weaver>
> <aspects>
> <aspect
> name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurer
> Aspect" />
> </aspects>
> </aspectj>
>
> And I told cxf.xml to be aware of the annotations:
>
> <context:annotation-config/>
> <context:spring-configured/>
> <context:load-time-weaver/>
> <context:component-scan base-package="example"/>
>
> Lastly, I started Tomcat with the agent:
>
> -javaagent:$tomcat\lib\spring-agent.jar
>
> Does anyone have any idea why the load time weaving would simply not
> happen? I feel like I've tried everything!
>
>
> --
> Hamlet D'Arcy
> hamlet.darcy@pearson.com
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog