Grails Aspectj Load Time Weaving with embedded Tomcat and Webphere

124 views
Skip to first unread message

Rushi Desai

unread,
Dec 16, 2014, 6:39:45 PM12/16/14
to grails-de...@googlegroups.com
Hi,

I am trying to get Load Time Weaving using Spring for my grails project.

Details of my environment are as follows.

grails version : 2.4.2
Server :  1. Embedded Tomcat for local development
             2. WebSphere 8.0.4 for higher environments.

I have attached the SampleAspect.groovy that I am using to weave specific aspect.

From what I understand to enable LoadTimeWeaving for Spring this is all we need to do :

<context:spring-configured />
<context:load-time-weaver aspectj-weaving="autodetect"/>

So I have place this in my applicationContext.xml in my grails project.

I set this argument while running run-app


-javaagent:path/to/spring-instrument.jar

If i just do this much as mentioned above I get this.


Caused by IllegalStateException: ClassLoader [org.grails.plugins.tomcat.ParentDelegatingClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar


So From this :

http://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/aop.html#aop-aj-ltw-environment-generic

I need to put this in 'server.xml' of my tomcat :

<Context path="/myWebApp" docBase="/my/webApp/location"> <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/> </Context>

Problem :


In grails I cannot have access to my server.xml (According to Graeme Rocher : http://grails.1312388.n4.nabble.com/Where-do-I-look-for-server-xml-with-embedded-Tomcat-td1461189.html)

So given this how do I put the above configuration ?

Any help would be appreciated !!

Thanks.


SampleAspect.groovy

Christian Knoblauch

unread,
Dec 17, 2014, 9:10:18 AM12/17/14
to grails-de...@googlegroups.com
Rushi,

There's a blog post linked from the mailing list you sent where it describes how to set up a a WebappLoader with a specific classloader. Maybe it will do what you want.

    Christian

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/0eb536df-458e-498b-aae7-0d6c6f3fc379%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages