Question

I am trying to get Load Time Weaving working with my Tomcat 7 webapp, in order to weave a class from an external jar file (located in WEB-INF/lib).

I have done the following:

  1. Started Tomcat with the following parameters: -javaagent:/path/aspectjweaver-1.7.0.jar -classpath /path/aspectjrt-1.7.0.jar:etc

  2. Placed aop.xml into WAR_ROOT/META-INF/, WEB-INF/lib/META_INF, WEB-INF/lib and WEB-INF/

aop.xml:

<aspectj>
 <aspects>
   <aspect name="ca.gc.agr.agrishare.web.jsf.chartlet.AgriShareGanttRendererAspect"/>
 </aspects>
 <weaver options="-verbose -debug -XnoInline">
    <include within="org.jfree..*"/>
    <dump within="org.jfree..*" />
 </weaver>
</aspectj>

No matter where I place the file, my target class is not woven, and I keep seeing errors like this:

[WebappClassLoader@495b317b] error can't determine implemented interfaces of missing type javax.validation.ValidatorFactory
when weaving type org.hibernate.cfg.beanvalidation.TypeSafeActivator
when weaving classes 
when weaving 
 [Xlint:cantFindType]

The fact that it is trying to weave a class outside of the package I specified, and considering that server startup time quadrupled, I think that it is trying to weave all classes.

What am I missing?

Was it helpful?

Solution

Figured it out.

WAR_ROOT/META-INF/ is the webapp metadata, looked up by servletContext.getResource("/META-INF/bla").

WAR_ROOT/WEB-INF/classes/META-INF is java classes metadata, looked up by getContextClassLoader().getResource("/META-INF/bla").

I created META-INF/aop.xml in my Config project (which is on the classpath), and everything is working properly now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top