Error : java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V

前端 未结 9 2053
迷失自我
迷失自我 2020-11-27 06:24

I am developing a small Spring application. I have to store the details of the student information in the database. I have developed one SimpleFormController. I have used Ne

相关标签:
9条回答
  • 2020-11-27 06:55

    I found the solution to this problem here: http://www.hildeberto.com/2008/05/hibernate-and-jersey-conflict-on.html

    0 讨论(0)
  • 2020-11-27 06:55

    The NoSuchMethodError javadoc says this:

    Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method.

    Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

    In your case, this Error is a strong indication that your webapp is using the wrong version of the JAR defining the org.objectweb.asm.* classes.

    0 讨论(0)
  • 2020-11-27 06:57

    to resolve this kind of problem you should add two jar in your dependency POM (if use Maven)

    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>3.3.1</version>
    </dependency>
    
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>3.1</version>
    </dependency>
    
    0 讨论(0)
  • 2020-11-27 06:59

    I change my APIs as * cglib --- to ---> cglib-nodep-2.2.jar * cglib-asm --- to ---> cglib-asm.jar (i.e. latest one )

    0 讨论(0)
  • 2020-11-27 07:02

    There is a lot of incompatibility between different versions of cglib and lots of poor advice that can be googled on this subject (use ancient versions of cglib-nodeb, etc). After wrestling with this nonsense for 3 days with an ancient version of Spring (2.5.6)I have discovered:

    • if Spring is throwing exceptions about NoSuchMethodError based on Enhancer from cglib missing setInterceptDuringConstruction(boolean), check your dependencies in maven (Dependency Hierarchy tab should list all the versions of cglib your project is polluted by). You probably have a dependency that is bringing in a pre-2.2 version of cglib, which Spring Cglib2AopProxy will grab Enhancer from to do the proxying. Add 2.2+ version to your dependencies but make sure to put in exclusions for these other versions. If you don't it will just keep blowing up.
    • Make sure you have a high enough version of cglib in the current project's maven dependencies but beware of picking too high a version because then you'll get IncompatibleClassChangeError(s) instead.
    • Verify that your pom changes have made it into the project correctly by doing a maven update on the project in question and then looking at Project > preferences > Java Build Path > Libraries > Maven Dependencies. If you see the wrong cglib versions in there, time to edit the pom again.
    0 讨论(0)
  • 2020-11-27 07:04

    I encountered the same error when added http-builder to dependencies.
    In my case, I could solve by simply excluding asm like this:

    compile('org.codehaus.groovy.modules.http-builder:http-builder:0.7'){
        excludes 'xml-apis'
        exclude(group:'xerces', module: 'xercesImpl')
        excludes 'asm'
    }
    
    0 讨论(0)
提交回复
热议问题