Cannot proxy target class because CGLIB2 is not available Solution

(177 Views)


When you make a Spring AOP project and run it, you might face this error "org.springframework.aop. framework.AopConfigException:". Let's see what this error is and how to solve this error.

Caused by: org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces at org.springframework.aop.framework.DefaultAopProxyFactory.createAopProxy(DefaultAopProxyFactory.java:67) at org.springframework.aop.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:106) at org.springframework.aop.framework.ProxyFactoryBean.getSingletonInstance(ProxyFactoryBean.java:317) at org.springframework.aop.framework.ProxyFactoryBean.getObject(ProxyFactoryBean.java:243) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:121) ... 9 more

In above exception stack trace it is saying that spring container Cannot proxy target class because CGLIB2 is not available in the classpath

Solution

In Spring AOP, we have to include the cglib library into our build path to get rid of the "Cannot proxy target class because CGLIB2 is not available" error message.

Add CGLIB 2 jars in your application's classpath

  1. Download CGLIB2 jars from sourceforge and put it in application classpath download cglib
  2. Add Maven Dependency
  3. <!-- https://mvnrepository.com/artifact/cglib/cglib --> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.2.2</version> </dependency>

If we run your AOP application after doing certain changes , then our project will run without any exception.

If you have any other doubt, feel free to ask us in the comments section, we will try to solve it too.

Solution Worked 0 UpvotesUpvote

        

Solution Didn't Worked 0 DownvotesDownvote



Comments



Search




Search Tags