java.lang.NoSuchMethodError:org.objectweb.asm.ClassWriter

java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter

問題

Hibernate開発では、一般的に次のエラーメッセージが表示されます。

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in ServletContext resource
[/WEB-INF/classes/config/database/spring/HibernateSessionFactory.xml]:
Invocation of init method failed; nested exception is

Caused by: org.hibernate.HibernateException:
Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
    ...
    ...
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    ...
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V
    at net.sf.cglib.core.DebuggingClassWriter.(DebuggingClassWriter.java:47)
    ...

溶液

Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer」は一般的なエラーメッセージであり、さまざまな理由で発生する可能性があります。 そのため、エラーの原因となった最後の行を確認する必要があります。

Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter

主な原因はold asm.jar library(例:「asm-1.5.3.jar」)です。最新バージョンのupgrade the asm libraryだけで、エラーメッセージが削除されます。 e.g, ‘asm-3.1.jar’.