You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by HamletDRC <ha...@gmail.com> on 2009/09/25 18:39:40 UTC

Can't get simple Spring AOP example to work in CXF

Does anyone have any ideas about why my Spring AOP example doesn't work with
CXF? I've tried quite a few different approaches, this one seems the
simplest, but none worked. 

1. I defined a service interface
2. I defined a service implementation
3. I defined a class to provide before method advice
4. I declared the service in my cxf.xml
5. I declared the aspect pointcut
6. I ran tomcat and got this error: java.lang.IllegalStateException:
Post-processor tried to replace bean instance of type
[vue.tcsm.services.SystemParameterService] with (proxy) object of type
[$Proxy42] - not supported for aspect-configured classes!


1. Service interface is simple: 
@WebService(serviceName = "SystemParameterService")
public interface ISystemParameterService {
	@WebMethod()
	SystemParameterListDTO getSystemParameter(@WebParam()SystemParameterListDTO
requests); 
}

2. Implementation is simple: 

@WebService(endpointInterface = "vue.tcsm.services.ISystemParameterService")
public class SystemParameterService implements ISystemParameterService {
  ...
}

3. Defined aop Pojo: 

public class ProxyExample {
	public void beforeMethod() {
		System.out.println("Before method call");
	}

4. I declared the service in my cxf.xml

	<jaxws:endpoint id="systemParameter"
					implementor="#systemParameterService"
					implementorClass="vue.tcsm.services.ISystemParameterService"
					address="/SystemParameterService">
	</jaxws:endpoint>
	<bean id="systemParameterService"
class="vue.tcsm.services.SystemParameterService"/>
	<bean id="profiler" class="vue.tcsm.interceptors.ProxyExample"/>


5. I declared the aspect pointcut

	<aop:config>
		<aop:aspect ref="profiler">
			<aop:pointcut id="aopbeforeMethod"
						  expression="execution(*
vue.tcsm.services.ISystemParameterService.*(..))"/>
			<aop:before pointcut-ref="aopbeforeMethod"
					   method="beforeMethod"/>
		</aop:aspect>
	</aop:config>


Any ideas on what could be wrong? 


-----
--
Hamlet D'Arcy

-- 
View this message in context: http://www.nabble.com/Can%27t-get-simple-Spring-AOP-example-to-work-in-CXF-tp25615235p25615235.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Can't get simple Spring AOP example to work in CXF

Posted by Daniel Kulp <dk...@apache.org>.
On Mon September 28 2009 11:58:11 am Stevo Slavić wrote:
> Should implementorClass point to interface or to the implementation? In CXF
> FAQ "Spring Related" example ( http://cxf.apache.org/faq.html )
> implementation is used, while I see Hamlet is referring to the interface as
> implementorClass.

That's probably it.   We need the actual impl class that would have the 
@WebService annotation on it.  From there, we can get the endpointInterface 
class that has the other annotations on it.

Dan


> 
> Regards,
> Stevo.
> 
> On Mon, Sep 28, 2009 at 3:38 PM, Daniel Kulp <dk...@apache.org> wrote:
> > On Mon September 28 2009 9:26:19 am HamletDRC wrote:
> > > Can someone confirm that Spring AOP before advice /should/ work with
> > > CXF?
> > >
> > > This is supported, correct?
> >
> > Yes.   This definitely SHOULD work and we've had several reports of
> > people using it, especially for things like spring security and such.  
> > Not sure what
> > would be going on.
> >
> > Dan
> >
> > > --
> > > Hamlet
> > >
> > > HamletDRC wrote:
> > > > Does anyone have any ideas about why my Spring AOP example doesn't
> > > > work with CXF? I've tried quite a few different approaches, this one
> > > > seems
> >
> > the
> >
> > > > simplest, but none worked.
> > > >
> > > > 1. I defined a service interface
> > > > 2. I defined a service implementation
> > > > 3. I defined a class to provide before method advice
> > > > 4. I declared the service in my cxf.xml
> > > > 5. I declared the aspect pointcut
> > > > 6. I ran tomcat and got this error: java.lang.IllegalStateException:
> > > > Post-processor tried to replace bean instance of type
> > > > [vue.tcsm.services.SystemParameterService] with (proxy) object of
> > > > type [$Proxy42] - not supported for aspect-configured classes!
> > > >
> > > >
> > > > 1. Service interface is simple:
> > > > @WebService(serviceName = "SystemParameterService")
> > > > public interface ISystemParameterService {
> > > >     @WebMethod()
> > > >     SystemParameterListDTO
> > > > getSystemParameter(@WebParam()SystemParameterListDTO requests);
> > > > }
> > > >
> > > > 2. Implementation is simple:
> > > >
> > > > @WebService(endpointInterface =
> > > > "vue.tcsm.services.ISystemParameterService")
> > > > public class SystemParameterService implements
> > > > ISystemParameterService
> >
> > {
> >
> > > >   ...
> > > > }
> > > >
> > > > 3. Defined aop Pojo:
> > > >
> > > > public class ProxyExample {
> > > >     public void beforeMethod() {
> > > >             System.out.println("Before method call");
> > > >     }
> > > >
> > > > 4. I declared the service in my cxf.xml
> > > >
> > > >     <jaxws:endpoint id="systemParameter"
> >
> > implementor="#systemParameterService"
> >
> > implementorClass="vue.tcsm.services.ISystemParameterService"
> >
> > > >                                    
> > > > address="/SystemParameterService"> </jaxws:endpoint>
> > > >     <bean id="systemParameterService"
> > > > class="vue.tcsm.services.SystemParameterService"/>
> > > >     <bean id="profiler" class="vue.tcsm.interceptors.ProxyExample"/>
> > > >
> > > >
> > > > 5. I declared the aspect pointcut
> > > >
> > > >     <aop:config>
> > > >             <aop:aspect ref="profiler">
> > > >                     <aop:pointcut id="aopbeforeMethod"
> > > >                                               expression="execution(*
> > > > vue.tcsm.services.ISystemParameterService.*(..))"/>
> > > >                     <aop:before pointcut-ref="aopbeforeMethod"
> > > >                                        method="beforeMethod"/>
> > > >             </aop:aspect>
> > > >     </aop:config>
> > > >
> > > >
> > > > Any ideas on what could be wrong?
> > >
> > > -----
> > > --
> > > Hamlet D'Arcy
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Can't get simple Spring AOP example to work in CXF

Posted by Stevo Slavić <ss...@gmail.com>.
Should implementorClass point to interface or to the implementation? In CXF
FAQ "Spring Related" example ( http://cxf.apache.org/faq.html )
implementation is used, while I see Hamlet is referring to the interface as
implementorClass.

Regards,
Stevo.

On Mon, Sep 28, 2009 at 3:38 PM, Daniel Kulp <dk...@apache.org> wrote:

>
> On Mon September 28 2009 9:26:19 am HamletDRC wrote:
> > Can someone confirm that Spring AOP before advice /should/ work with CXF?
> >
> > This is supported, correct?
>
> Yes.   This definitely SHOULD work and we've had several reports of people
> using it, especially for things like spring security and such.   Not sure
> what
> would be going on.
>
> Dan
>
>
> >
> > --
> > Hamlet
> >
> > HamletDRC wrote:
> > > Does anyone have any ideas about why my Spring AOP example doesn't work
> > > with CXF? I've tried quite a few different approaches, this one seems
> the
> > > simplest, but none worked.
> > >
> > > 1. I defined a service interface
> > > 2. I defined a service implementation
> > > 3. I defined a class to provide before method advice
> > > 4. I declared the service in my cxf.xml
> > > 5. I declared the aspect pointcut
> > > 6. I ran tomcat and got this error: java.lang.IllegalStateException:
> > > Post-processor tried to replace bean instance of type
> > > [vue.tcsm.services.SystemParameterService] with (proxy) object of type
> > > [$Proxy42] - not supported for aspect-configured classes!
> > >
> > >
> > > 1. Service interface is simple:
> > > @WebService(serviceName = "SystemParameterService")
> > > public interface ISystemParameterService {
> > >     @WebMethod()
> > >     SystemParameterListDTO
> > > getSystemParameter(@WebParam()SystemParameterListDTO requests);
> > > }
> > >
> > > 2. Implementation is simple:
> > >
> > > @WebService(endpointInterface =
> > > "vue.tcsm.services.ISystemParameterService")
> > > public class SystemParameterService implements ISystemParameterService
> {
> > >   ...
> > > }
> > >
> > > 3. Defined aop Pojo:
> > >
> > > public class ProxyExample {
> > >     public void beforeMethod() {
> > >             System.out.println("Before method call");
> > >     }
> > >
> > > 4. I declared the service in my cxf.xml
> > >
> > >     <jaxws:endpoint id="systemParameter"
> > >
> implementor="#systemParameterService"
> > >
> implementorClass="vue.tcsm.services.ISystemParameterService"
> > >                                     address="/SystemParameterService">
> > >     </jaxws:endpoint>
> > >     <bean id="systemParameterService"
> > > class="vue.tcsm.services.SystemParameterService"/>
> > >     <bean id="profiler" class="vue.tcsm.interceptors.ProxyExample"/>
> > >
> > >
> > > 5. I declared the aspect pointcut
> > >
> > >     <aop:config>
> > >             <aop:aspect ref="profiler">
> > >                     <aop:pointcut id="aopbeforeMethod"
> > >                                               expression="execution(*
> > > vue.tcsm.services.ISystemParameterService.*(..))"/>
> > >                     <aop:before pointcut-ref="aopbeforeMethod"
> > >                                        method="beforeMethod"/>
> > >             </aop:aspect>
> > >     </aop:config>
> > >
> > >
> > > Any ideas on what could be wrong?
> >
> > -----
> > --
> > Hamlet D'Arcy
> >
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: Can't get simple Spring AOP example to work in CXF

Posted by Daniel Kulp <dk...@apache.org>.
On Mon September 28 2009 9:26:19 am HamletDRC wrote:
> Can someone confirm that Spring AOP before advice /should/ work with CXF?
> 
> This is supported, correct?

Yes.   This definitely SHOULD work and we've had several reports of people 
using it, especially for things like spring security and such.   Not sure what 
would be going on.

Dan


> 
> --
> Hamlet
> 
> HamletDRC wrote:
> > Does anyone have any ideas about why my Spring AOP example doesn't work
> > with CXF? I've tried quite a few different approaches, this one seems the
> > simplest, but none worked.
> >
> > 1. I defined a service interface
> > 2. I defined a service implementation
> > 3. I defined a class to provide before method advice
> > 4. I declared the service in my cxf.xml
> > 5. I declared the aspect pointcut
> > 6. I ran tomcat and got this error: java.lang.IllegalStateException:
> > Post-processor tried to replace bean instance of type
> > [vue.tcsm.services.SystemParameterService] with (proxy) object of type
> > [$Proxy42] - not supported for aspect-configured classes!
> >
> >
> > 1. Service interface is simple:
> > @WebService(serviceName = "SystemParameterService")
> > public interface ISystemParameterService {
> > 	@WebMethod()
> > 	SystemParameterListDTO
> > getSystemParameter(@WebParam()SystemParameterListDTO requests);
> > }
> >
> > 2. Implementation is simple:
> >
> > @WebService(endpointInterface =
> > "vue.tcsm.services.ISystemParameterService")
> > public class SystemParameterService implements ISystemParameterService {
> >   ...
> > }
> >
> > 3. Defined aop Pojo:
> >
> > public class ProxyExample {
> > 	public void beforeMethod() {
> > 		System.out.println("Before method call");
> > 	}
> >
> > 4. I declared the service in my cxf.xml
> >
> > 	<jaxws:endpoint id="systemParameter"
> > 					implementor="#systemParameterService"
> > 					implementorClass="vue.tcsm.services.ISystemParameterService"
> > 					address="/SystemParameterService">
> > 	</jaxws:endpoint>
> > 	<bean id="systemParameterService"
> > class="vue.tcsm.services.SystemParameterService"/>
> > 	<bean id="profiler" class="vue.tcsm.interceptors.ProxyExample"/>
> >
> >
> > 5. I declared the aspect pointcut
> >
> > 	<aop:config>
> > 		<aop:aspect ref="profiler">
> > 			<aop:pointcut id="aopbeforeMethod"
> > 						  expression="execution(*
> > vue.tcsm.services.ISystemParameterService.*(..))"/>
> > 			<aop:before pointcut-ref="aopbeforeMethod"
> > 					   method="beforeMethod"/>
> > 		</aop:aspect>
> > 	</aop:config>
> >
> >
> > Any ideas on what could be wrong?
> 
> -----
> --
> Hamlet D'Arcy
> 

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Can't get simple Spring AOP example to work in CXF

Posted by HamletDRC <ha...@gmail.com>.
Can someone confirm that Spring AOP before advice /should/ work with CXF? 

This is supported, correct? 

--
Hamlet




HamletDRC wrote:
> 
> Does anyone have any ideas about why my Spring AOP example doesn't work
> with CXF? I've tried quite a few different approaches, this one seems the
> simplest, but none worked. 
> 
> 1. I defined a service interface
> 2. I defined a service implementation
> 3. I defined a class to provide before method advice
> 4. I declared the service in my cxf.xml
> 5. I declared the aspect pointcut
> 6. I ran tomcat and got this error: java.lang.IllegalStateException:
> Post-processor tried to replace bean instance of type
> [vue.tcsm.services.SystemParameterService] with (proxy) object of type
> [$Proxy42] - not supported for aspect-configured classes!
> 
> 
> 1. Service interface is simple: 
> @WebService(serviceName = "SystemParameterService")
> public interface ISystemParameterService {
> 	@WebMethod()
> 	SystemParameterListDTO
> getSystemParameter(@WebParam()SystemParameterListDTO requests); 
> }
> 
> 2. Implementation is simple: 
> 
> @WebService(endpointInterface =
> "vue.tcsm.services.ISystemParameterService")
> public class SystemParameterService implements ISystemParameterService {
>   ...
> }
> 
> 3. Defined aop Pojo: 
> 
> public class ProxyExample {
> 	public void beforeMethod() {
> 		System.out.println("Before method call");
> 	}
> 
> 4. I declared the service in my cxf.xml
> 
> 	<jaxws:endpoint id="systemParameter"
> 					implementor="#systemParameterService"
> 					implementorClass="vue.tcsm.services.ISystemParameterService"
> 					address="/SystemParameterService">
> 	</jaxws:endpoint>
> 	<bean id="systemParameterService"
> class="vue.tcsm.services.SystemParameterService"/>
> 	<bean id="profiler" class="vue.tcsm.interceptors.ProxyExample"/>
> 
> 
> 5. I declared the aspect pointcut
> 
> 	<aop:config>
> 		<aop:aspect ref="profiler">
> 			<aop:pointcut id="aopbeforeMethod"
> 						  expression="execution(*
> vue.tcsm.services.ISystemParameterService.*(..))"/>
> 			<aop:before pointcut-ref="aopbeforeMethod"
> 					   method="beforeMethod"/>
> 		</aop:aspect>
> 	</aop:config>
> 
> 
> Any ideas on what could be wrong? 
> 
> 


-----
--
Hamlet D'Arcy

-- 
View this message in context: http://www.nabble.com/Can%27t-get-simple-Spring-AOP-example-to-work-in-CXF-tp25615235p25645178.html
Sent from the cxf-user mailing list archive at Nabble.com.