akhikhl / gretty

Advanced gradle plugin for running web-apps on jetty and tomcat.
MIT License
657 stars 173 forks source link

How can I pass javaagent (aspectjweaver) to tomcat? #143

Open magx2 opened 9 years ago

magx2 commented 9 years ago

I'm trying to run Tomcat 7 with -javaagent:/full/path/aspectjweaver-${aspectVersion}.jar. I'm doing this in gretty.jvmArgs. My code from build.gradle:

gretty {
    jvmArgs = [ "-javaagent:/home/mgrzeslo/git/euro/tools/lib/aspectjweaver-${aspectVersion}.jar" ]
    servletContainer = 'tomcat7'
}
import org.akhikhl.gretty.AppStartTask
task runB24 (type: AppStartTask, dependsOn: copyPropertiesForTomcat) {}

When running gradlew runB24 I get this error:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateConfigurationAspect' defined in ServletContext resource [/WEB-INF/ac-b24v2-config.xml]: No matching factory method found: factory method 'aspectOf()'. Check that a method with the specified name exists and that it is static.

What is the solution for this problem?

You can see more on my StackOverflow question: http://stackoverflow.com/questions/28701098/aspectjweaver-not-working-with-gretty-in-gradle

magx2 commented 9 years ago

I found that jvmArgs are not pushed to Grettys Tomcat.

TomDmitriev commented 9 years ago

Any update on the issue? I'm experiencing the same problem. jvmArgs are picked up by jetty but not by tomcat.

TomDmitriev commented 9 years ago

Does anybody know a work-around?

TomDmitriev commented 9 years ago

Apparently jvmArgs are passed in to tomcat but weaving does not happen which may have something to do with the order in which the classes are loaded.