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

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

Problème

Dans le développement Hibernate, il est courant de voir le message d'erreur suivant.

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

Solution

Le «Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer» est un message d'erreur générique, il peut être causé par de nombreuses raisons. Donc, vous devez regarder la dernière ligne qui a provoqué l'erreur.

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

La cause principale est leold asm.jar library, par exemple «asm-1.5.3.jar», seuls lesupgrade the asm library vers la version la plus récente éliminent le message d’erreur. e.g, ‘asm-3.1.jar’.