Alfred’s Computing Weblog

Alfred Java-cored Computing Weblog

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>

Written by Alfred

September 14, 2011 at 10:41

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: