java.lang.NoClassDefFoundError: org/aspectj/lang/annotation/Aspect
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>
Advertisement