How to resolve java.lang.NoClassDefFoundError: org / aopalliance / aop / Advice error?

I am trying to use the spring AOP framework. The code compiled without errors. When I tried to run it, I got the exception above. I am using netbeans IDE 8.0.1. I have the following libraries and jar files.

1) Spring Framework 4.0.1 2) aspectjrt.jar 3) aspectjweaver.jar 4) aopalliance-alpha1.jar 5) asm-5.03.jar 6) cglib-3.1.jar 

Here is my spring.xml configuration file

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd "> <aop:aspectj-autoproxy/> <bean name="triangle" class="springaop.Triangle"> <property name="name" value="My Triangle" /> </bean> <bean name="circle" class="springaop.Circle"> <property name="name" value="My Circle" /> </bean> <bean name="shapeService" class="springaop.ShapeService" autowire="byName" > </bean> <bean name="loginAspect" class="springaop.LoginAspect" /> </beans> 

These are the latest jar files available from each publisher. I have not seen the Advice class anywhere in the aopalliance bank. I was looking for this problem. It seems that the Advice class can be removed from the aopalliance jar. I could not find him. Does anyone know how to solve this problem other than telling me to use Maven :)?

+5
source share
3 answers

I do not know what aopalliance-alpha1 . You need aopalliance , which is in version 1.0. You can get it here . (Download the JAR if you are not using Maven.)

+8
source

I had the same error as I added aopalliance-alpha1.jar instead of aopalliance.jar. I added the right jar and it started working.

+1
source

I also got the same error in my eclipse eclipse.

Cause. To work with spring aop examples from the network, I downloaded the files "aopalliance-.jar.zip", "aspectj-1.6.9.jar.zip", "aspectjrt.jar.zip", 'aspectj-weaver.jar.zip' and included it directly in the java build path. The error I made here was that I did not extract the jar files from the zip file, but instead directly added the .jar.zip file to the java build path.

Fix: Extract the jar files from the above .jar.zip files and at the eclipse point into jar files instead of zip files, then it will start working.

-2
source

Source: https://habr.com/ru/post/1208462/


All Articles