Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Load-time weaving of a web-application in Tomcat

I have not been successful in load-time weaving a web-application deployed in Tomcat 5.5 using JAR file with aspects either in /common/lib or /shared/lib directory. I'd like to separate aspects from my web-application. Here's what I have:
 
myaspect.jar
    com\my\package\MyAspect.class
    META_INF\aop.xml
 
MyAspect.aj
 
package com.aspects.package;
 
import com.weaved.application.package.MyWeavedClass;
 
public aspect MyAspect {
 
 pointcut initialize(com.weaved.application.package.MyWeavedClass weavedInstance) :
  target(weavedInstance) &&
  execution(* *initialize());
 
 before(com.weaved.application.package.MyWeavedClass weavedInstance) :
  initialize(weavedInstance)
 {
      weavedInstance.initialize();
 }
 
}
 
MyWeavedClass.java in web application
 
package com.weaved.application.package.;
 
public class MyWeavednClass
{
    public void initialize() {}
}
 
<aspectj>
 <aspects>
  <aspect name="com.aspects.package.MyAspect"/>
     <weaver options="-verbose -debug -showWeaveInfo -Xlint:default">
      <include within="com.aspects.package.*"/>
    </weaver>  
 </aspects>
</aspectj>
 
Everything seems to work until actual execution:
 
[WebappClassLoader@1554233] info register classloader org.apache.catalina.loader.WebappClassLoader@1554233
[WebappClassLoader@1554233] info using configuration file:/C:/tomcat55/shared/lib/myaspect.jar!/META-INF/aop.xml
[WebappClassLoader@1554233] info register aspect com.aspects.package.MyAspect
....
[WebappClassLoader@1554233] debug weaving 'com.weaved.application.package.MyWeavedClass'
[WebappClassLoader@1554233] weaveinfo Join point 'method-execution(void com.weaved.application.package.MyWeavedClass.initialize())' in Type 'com.weaved.application.package.MyWeavedClass'(MyWeavedClass.java:153) advised by before advice from 'com.aspects.package.MyAspect' (MyAspect .aj:11)
 
....
 
java.lang.NoClassDefFoundError: com/weaved/application/MyWeavedClass
 at com.aspects.package.MyAspect.ajc$before$com_aspect_package_MyAspect$1$5d8f1ad6(MyAspect.aj:14)
 at com.weaved.application.package.MyWeavedClass.initialize(MyWeavedClass.java:153)
 
Within eclipse I created Aspect project and used Export... to export JAR file with AspectJ support. What am I doing wrong?
Any help greatly appreciated.
 
Andre Piwoni

------------------------------------------------------------------------------

This email is confidential and may be legally privileged.

It is intended solely for the addressee. Access to this email by anyone else, unless expressly approved by the sender or an authorized addressee, is unauthorized.

If you are not the intended recipient, any disclosure, copying, distribution or any action omitted or taken in reliance on it, is prohibited and may be unlawful. If you believe that you have received this email in error, please contact the sender, delete this e-mail and destroy all copies.

==============================================================================


Back to the top