Exception java.lang.IncompatibleClassChangeError while running Groovy in Eclipse Juno

心不动则不痛 提交于 2019-11-29 12:23:31

问题


I have recently downloaded Eclipse Juno and installed latest Groovy plugin.

Now here is how my Groovy file looks like.

package groovy_support

class TimePass {
static void main(def args){
    println "Hello World"
}
}

When i run this from either my previous eclipse version (indigo) or from command line, it runs. On Eclipse Juno, however, it complains with following exception on Eclipse console.

Caught: java.lang.IncompatibleClassChangeError: Found class org.objectweb.asm.ClassVisitor, but interface was expected
java.lang.IncompatibleClassChangeError: Found class org.objectweb.asm.ClassVisitor, but interface was expected

Note that "Groovy Libraries" are already on classpath.

Now what am i doing wrong here?


回答1:


Are you on the latest groovy/dependent jars? .

The java.lang.IncompatibleClassChangeError happens due to back ward compatibility issues. The client code needs to be recompiled to resolve it.

The specific error you are seeing is because org.objectweb.asm.ClassVisitor is an Interface in asm 3.2 and a Class in asm 4.0 onwards.




回答2:


I had the same problem using Spring and Groovy in one module. Spring in 3.1.2 still uses older ASM, Groovy uses the one with the class. While it may be possible to adjust some excludes, I bet it's not always an option.

After reading this thread I decided to do with groovy-all.jar instead of the list of all the Groovy needed libs. If that is an option for you, it might be easy way how to avoid any further problems.




回答3:


I have tried many solutions for the below error. java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected. Only the one worked is exclude the groovy artifact from restassured dependency. Please refer to the below link for the complete workaround.

https://blog.jayway.com/2013/04/12/solving-asm-conflicts-after-upgrading-to-groovy-2-1/



来源:https://stackoverflow.com/questions/11738732/exception-java-lang-incompatibleclasschangeerror-while-running-groovy-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!