When you are working with java libraries which internally depends on cglib, then its very normal to encounter the below error:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at net.sf.cglib.core.DebuggingClassWriter.toByteArray(DebuggingClassWriter.java:73) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:26) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104) at net.sf.cglib.proxy.Enhancer.(Enhancer.java:69)
This error is due to incompatible version of cglib with additional jar files in you project, such as asm. I encountered it when writing my experiment relted to lazy loading in iBatis.

Solution
Solution is very easy. Just place the suitable version of cglib in your class path.
A correct dependency will look like this:
<dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>asm</groupId> <artifactId>asm-util</artifactId> <version>3.3.1</version> </dependency>
Happy Learning !!
Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.
Hi, I need help to solve the problem.
Even am also facing the issue while starting of Tomcat 8.5.24 server and received the below error. Can you suggest exact solution for this?
Thanks, it’s working
I am facing the issue while starting of Tomcat 7 server and received the below error. I have tried the suggestion provided by you but it is not working.
Can you please help on priority basis? Thanks
Thanks Lokesh! I was struggling for the jars version mismatch.
Have you tried the solution suggested in post?
hi
i chaged a class file which is a part of jar file.
It was compiled and running succesfully in my local but when we deployed from server end it was throwing the below exception.
Can you be specific what change you made? It can be triggered for many reasons such as changing static variable to non-static or vice-versa; declaring a new field which hides any super class field and things like that. Please note that it may trigger even when JVM versions at your local and prod are different.
I am getting this
Problem solved or still facing issue after trying the fix provided in post??
Hi I need help!!!!!! My problem is
I see this for the first time in my life!! Can you help me please?
Check if you configured something like this: https://stackoverflow.com/questions/5714053/how-can-we-redirect-a-java-program-console-output-to-multiple-files