Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

Posts Tagged ‘aspectjrt

java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect

leave a comment »

ERROR:
Hits the error java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect when I try to start a webapp in tomcat.

STORY:
I was trying to add AOP to an existing web application. The AOP configuration I added is:

<aop:aspectj-autoproxy />

SOLUTION:
Add the AspectJ library to the classpath. The required AspectJ library are:
1. aspectjrt
2. aspectjweaver

My webapps is using Maven, so I added the dependencies to pom.xml as below:

<!-- AspectJ -->
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.6.11</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.6.11</version>
</dependency>
Advertisements

Written by Alfred

September 14, 2011 at 10:41