Frage

I would like to use Struts2 convention plugin(2.3.8) together with hibernate(netbeans framework plugin 3.2.5), but there is conflict before two different asm.jar versions.

Hibernate works fine with struts2 fw, but when i add convention plugin, I get error:

java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
  • Hibernate 3.2.5 needs asm.jar
  • Struts2 convention plugin needs asm-3.3.jar

IMHO convention plugin needs class: ClassWriter, which is located in asm-3.3.jar, but looks into asm.jar.

  • tested with maven(there is no conflict, but not running)
  • tested without maven(not running)

Is there any solution to achiev this, when hibernate 3.2.5 cant be changed to higher version?

War es hilfreich?

Lösung

One hack would be update the hibernate plugin library asm.jar and with asm-3.3.jar. You need to check if Hiberate has specific issue using asm-3.3.jar.

If that won't work then few things I can think of

  • Modularize (move hibernate related class as sub project and restrict the library to subproject)
  • If the above is not possible then figure a place within the call stack to manipulate classloader cache (discard the loaded classes and load from specific jar and so on). Personally this would be painful to maintain.

Related post

Andere Tipps

If you can, try to upgrade Hibernate to newest version which uses the same version of asm library as Struts 2.3.8. You can also try to exclude asm library from Hibernate set - with Maven you must add section.

IMHO the problem is not in a library conflict. I'm using Hibernate 3.2.5.ga with Struts 2.3.7 with only an asm library. The libraries I'm using in my project (concerning only Hibernate and Struts) are:

 ├── hibernate
 │   ├── dom4j-1.6.1.jar
 │   ├── ehcache-1.2.3.jar
 │   ├── hibernate3.jar
 │   ├── hibernate-annotations.jar
 │   ├── hibernate-commons-annotations.jar
 │   ├── hibernate-entitymanager.jar
 │   ├── hibernate-tools.jar
 │   ├── javassist.jar
 │   ├── jdbc2_0-stdext.jar
 │   └── jta.jar
 ├── struts-2.3.7
     ├── antlr-2.7.2.jar
     ├── asm-3.3.jar
     ├── asm-commons-3.3.jar
     ├── cglib-nodep-2.2.2.jar
     ├── commons-beanutils-1.8.0.jar
     ├── commons-collections-3.1.jar
     ├── commons-digester-2.0.jar
     ├── commons-fileupload-1.2.2.jar
     ├── commons-io-2.0.1.jar
     ├── commons-lang-2.5.jar
     ├── commons-lang3-3.1.jar
     ├── commons-logging-1.1.1.jar
     ├── freemarker-2.3.19.jar
     ├── ognl-3.0.5.jar
     ├── struts2-convention-plugin-2.3.7.jar
     ├── struts2-core-2.3.7.jar
     ├── struts2-fullhibernatecore-plugin-2.2.2-GA.jar
     ├── struts2-json-plugin-2.3.7.jar
     └── xwork-core-2.3.7.jar
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top