java lang ClassNotFoundException org aspectj weaver BCException

java lang ClassNotFoundException org aspectj weaver BCException

If you are getting below exception:

Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/BCException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
    at java.lang.Class.getConstructor0(Class.java:2714)
    at java.lang.Class.getDeclaredConstructor(Class.java:2002)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:63)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948)
    ... 32 more
Caused by: java.lang.ClassNotFoundException: org.aspectj.weaver.BCException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 38 more

 

Solution:

  • If you are using maven project please add below dependency in your pom.xml file:
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.7.4</version>
</dependency>

or you could also check maven dependency and latest version from maven repository here and add accordingly.

  • If you are using eclipse project then add aspectj-weaverXXX.jar or latest version to your lib folder and include in class path.

Leave a Reply

Your email address will not be published. Required fields are marked *

I am not Robot *