Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when using AspectJ AOP with Java 7

I've updated Java to version "1.7.0_09-icedtea" (previously it was 1.6) and get the following message:

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate be
an class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error the 
@annotation pointcut expression is only supported at Java 5 compliance level or above

Application had been compiled with java 1.6 and compiler compliance level was set to 1.6 as well. I'm using spring 3.1.0

Has anyone been able to get aspectj working under Java 7?

like image 710
Mikhail.Mamaev Avatar asked Mar 28 '13 09:03

Mikhail.Mamaev


People also ask

How do I enable AspectJ annotations support in Spring AOP?

To enable @AspectJ, spring AOP provides @EnableAspectJAutoProxy annotation which will be annotated in java configuration. To work with spring AOP and @AspectJ support, we need to create a class annotated with @Aspect annotation.

What is the difference between Spring AOP and AspectJ AOP?

Spring AOP aims to provide a simple AOP implementation across Spring IoC to solve the most common problems that programmers face. On the other hand, AspectJ is the original AOP technology which aims to provide complete AOP solution.

What is AOP AspectJ Autoproxy />?

@AspectJAutoProxy. Fashioned after Spring XML's <aop:aspectj-autoproxy> , @AspectJAutoProxy detects any @Aspect beans and generates proxies as appropriate to weave the advice methods in those aspects against other beans in the container.


2 Answers

AspectJ 1.5.4 is not designed to work with Java7. Try upgrading your version of AspectJ to 1.7.0 or higher (latest was 1.7.2 as of this writing).

(I had AspectJ/Java7 issues before, too)

like image 135
Jason Avatar answered Oct 05 '22 09:10

Jason


If you are getting this error. just compile your program with jdk 1.6 and run it with jre 6. It will resolve your problem

like image 41
deepesh17feb Avatar answered Oct 05 '22 10:10

deepesh17feb