java.lang.nosuchmethoderror org.objectweb.asm.classwriter
I was working on a RESTFul Service based project. Recently I migrated the plain JDBC DAO layer to the hibernate based orm layer. As a first step I migrated one of the DAO class. When I deployed the complete solution in Tomcat, I faced the following error
asm-3.1.jar
spring-asm-3.0.5.RELEASE.jarSo the guess was that since Spring uses CGLIG library ("cglib-2.1_3.jar" in my case) and CGLIB used ASM library in turn, there may be a conflict due to version difference.
So I replaced the CGLIB jar with the "cglib-nodep-2.1_3.jar" from the following location
http://www.findjar.com/jar/cglib/jars/cglib-nodep-2.1_3.jar.html;jsessionid=849E2D3B53A5EF3A214600DEABCCBF7B
This library contains all the dependencies and is not dependent on external dependency.
----------------------------------------------------------------------------------------------------
In case you are using maven to build then you can also try the following dependency :
Make the following changes where you are specifying hibernate annotation dependency (in case you have)
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.When I looked in the project library repository realized there are 2 library of ASM, One from the Hibernate and Spring Integration module and other from the RESTFul Service implementation.(Z)V
at net.sf.cglib.core.DebuggingClassWriter.(Debu ggingClassWriter.java:47)
at net.sf.cglib.core.DefaultGeneratorStrategy.getClas sWriter(DefaultGeneratorStrategy.java:30)
at net.sf.cglib.core.DefaultGeneratorStrategy.generat e(DefaultGeneratorStrategy.java:24)
at net.sf.cglib.core.AbstractClassGenerator.create(Ab stractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyF actory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.jav a:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.jav a:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.jav a:104)
at net.sf.cglib.proxy.Enhancer.(Enhancer.java :69)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.springframework.aop.framework.DefaultAopProxyF actory.(DefaultAopProxyFactory.java:57)
asm-3.1.jar
spring-asm-3.0.5.RELEASE.jarSo the guess was that since Spring uses CGLIG library ("cglib-2.1_3.jar" in my case) and CGLIB used ASM library in turn, there may be a conflict due to version difference.
So I replaced the CGLIB jar with the "cglib-nodep-2.1_3.jar" from the following location
http://www.findjar.com/jar/cglib/jars/cglib-nodep-2.1_3.jar.html;jsessionid=849E2D3B53A5EF3A214600DEABCCBF7B
This library contains all the dependencies and is not dependent on external dependency.
----------------------------------------------------------------------------------------------------
In case you are using maven to build then you can also try the following dependency :
<dependency>
<groupid>cglib</groupid>
<artifactid>cglib-nodep</artifactid>
<version>2.1_3</version>
</dependency>
Make the following changes where you are specifying hibernate annotation dependency (in case you have)
<dependency>And following changes where you are specifying hibernate core dependency:
<groupid>org.hibernate</groupid>
<artifactid>hibernate-annotations</artifactid>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupid>cglib</groupid>
<artifactid>cglib</artifactid>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupid>org.hibernate</groupid>
<artifactid>hibernate-core</artifactid>
<version>${hibernate.version}</version>
<exclusions>
<exclusion>
<groupid>asm</groupid>
<artifactid>asm</artifactid>
</exclusion>
<exclusion>
<groupid>asm</groupid>
<artifactid>asm-attrs</artifactid>
</exclusion>
<exclusion>
<groupid>cglib</groupid>
<artifactid>cglib</artifactid>
</exclusion>
</exclusions>
</dependency>
I have exactly the same problem. Thanks for the great solution!!!
ReplyDeleteI am glad that I could be of any help
ReplyDeleteAwesome contribution my man!... I hope you're still around keeping up your work. Best regards!
ReplyDeleteIt worked for me too... Thanks
ReplyDeleteIt worked for me...Thanks a lot..
ReplyDeleteReally great work,It helped me to solve my issue.
ReplyDelete