Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

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


Problem

In Hibernate development, it’s common to hits the following error message.

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.<init>(I)V
at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:47)
...

Solution

The “Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer” is a generic error message, it may caused by many reasons. So, you have to look at the last line that caused the error.

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

The main cause is the old asm.jar library e.g ‘asm-1.5.3.jar’, just upgrade the asm library to the most recent version will get rid of the error message. e.g, ‘asm-3.1.jar’.

Reference

  1. ASM library offcial website

  maven_hibernate_mysql
  maven_hibernate_annonation_mysql
  load_hibernate_cfg_xml_from_different_directory
  add_hibernate_xml_mapping_file_hbm_xml
  c3p0_connection_pool_hibernate
  hibernate_dialect_collection
  configure_log4j_hibernate_project
  hibernate_sql_format_sql
  hibernate_one_relationship
  hibernate_one_to_many_relationship
  hibernate_many_to_many_relationship
  inverse_true__explanation
  hibernate_cascade
  different_between_cascade_and_inverse
  cascade_jpa_hibernate_annotation_common_mistake
  hibernate_query_examples_hql
  hibernate_parameter_binding
  embed_oracle_hints_in_hibernate_query
  hibernate_criteria
  hibernate_native_sql_queries
  hibernate_named_query
  hibernate_transaction_handle
  hibernate_data_annotation
  Hibernate_interceptor
  hibernate_dynamic_insert_attribute
  maven_spring_hibernate_mysql
  maven_spring_hibernate_annotation
  hibernate_sql_parameter_solution
  hibernate_sql_parameter_log4j
  store_procedure_hibernate
  database_reserved_keyword_hibernate
  hibernate_save_image_into_database
  install_hibernate_tools_in_eclipse_ide
  generate_code_hibernate_tools
  hibernate-dynamic-update-attribute-example
  hibernate-mutable-example-class-and-collection
  hibernate-fetching-strategies-examples
  different-between-session-get-and-session-load
  struts-hibernate-integration-example
  struts-spring-hibernate-integration-example
  maven-spring-hibernate-mysql-example
  maven-spring-hibernate-annotation-mysql-example
  how-to-display-hibernate-sql-parameter-values-solution
  how-to-display-hibernate-sql-parameter-values-log4j
  how-to-call-store-procedure-in-hibernate
  how-to-use-database-reserved-keyword-in-hibernate
  hibernate-save-image-into-database
  how-to-install-hibernate-tools-in-eclipse-ide
  how-to-generate-code-with-hibernate-tools
  remember-that-ordinal-parameters-are-1-based-hibernatetemplate
  org-hibernate-annotationexception-unknown-id-generator
  hibernate-error-an-annotationconfiguration-instance-is-required-to-use
  hibernate-error-initial-sessionfactory-creation-failed-java-lang-noclassdeffounderror-orgdom4jdocumentexception
  hibernate-error-initial-sessionfactory-creation-failed-java-lang-noclassdeffounderror-orgapachecommonslogginglogfactory
  hibernate-error-initial-sessionfactory-creation-failed-java-lang-noclassdeffounderror-orgapachecommonscollectionssequencedhashmap
  hibernate-error-initial-sessionfactory-creation-failed-java-lang-noclassdeffounderror-netsfcglibproxycallbackfilter
  hibernate-errorinitial-sessionfactory-creation-failed-java-lang-noclassdeffounderror-commchangev2c3p0datasources
  hibernate-error-initial-sessionfactory-creation-failed-java-lang-noclassdeffounderror-orghibernateannotationscommonreflectionreflectionmanager
  hibernate-error-exception-in-thread-main-java-lang-noclassdeffounderror-antlrantlrexception
  hibernate-error-java-lang-noclassdeffounderror-javaxtransactionsynchronization
  java-lang-classformaterror-absent-code-attribute-in-method-that-is-not-native-or-abstract-in-class-file
  java-lang-nosuchmethoderror-org-objectweb-asm-classwriter
  java-lang-classnotfoundexception-javax-persistence-entity
  java-lang-classnotfoundexception-javax-transaction-transactionmanager
  why-i-choose-hibernate-for-my-project




affiliate_link