« Return to Thread: Grails and Spring AOP

Re: Grails and Spring AOP

by fernando.takai :: Rate this Message:

Reply to Author | View in Thread

I had this kind of problem (object is not an instance of declaring
class) when trying to use Java + Groovy. My solution was creating an interface and implementing it on the Service. Then, i used the interface where should be the service.

On Tue, Sep 23, 2008 at 1:26 PM, Matthias <m.kaeppler@...> wrote:
Hi,

I am desperately trying to make Spring AOP work in my Grails project. I define
an advice on a service method, which works fine, but as soon as the pointcut
matches and the advice is executed, Grails throws an exception:

"java.lang.IllegalArgumentException: object is not an instance of declaring
class"

I guess this has something to do with Groovy and meta objects? Not sure.

Since I have seen Graeme saying on this mailing list that Spring AOP works just
fine in Grails, I am wondering what I am doing wrong.

Thanks,
Matthias

PS:
Here is my resources.xml, it's just for testing purposes right now (MyAspect is
annotated with @Aspect and defines a public method "foo"):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

   <aop:config>

     <aop:aspect id="theAspect" ref="testAspect">

       <aop:pointcut id="exec"
             expression="execution(* org.myapp.services.MyService.*(..))" />

       <aop:before pointcut-ref="exec" method="foo" />

     </aop:aspect>

   </aop:config>

   <bean id="testAspect" class="org.myapp.MyAspect">
   </bean>

</beans>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





--
Fernando "Takai"
http://flickr.com/photos/supeertakai
http://fernandotakai.wordpress.com
http://fernandotakai.jaiku.com

 « Return to Thread: Grails and Spring AOP