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’.