在 Eclipse Juno 中运行 Groovy 时出现异常 java.lang.IncompatibleClassChangeError

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11738732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:42:37  来源:igfitidea点击:

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

eclipsegroovyeclipse-juno

提问by user898535

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

我最近下载了 Eclipse Juno 并安装了最新的 Groovy 插件。

Now here is how my Groovy file looks like.

现在这是我的 Groovy 文件的样子。

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.

当我从以前的 eclipse 版本(indigo)或命令行运行它时,它会运行。但是,在 Eclipse Juno 上,它在 Eclipse 控制台上抱怨以下异常。

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.

请注意,“Groovy 库”已经在类路径中。

Now what am i doing wrong here?

现在我在这里做错了什么?

回答by Ajay George

Are you on the latest groovy/dependent jars? .

你在使用最新的 groovy/dependent jars 吗?.

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

java.lang.IncompatibleClassChangeError发生这种情况是由于向后兼容性问题。客户端代码需要重新编译才能解决。

The specific error you are seeing is because org.objectweb.asm.ClassVisitoris an Interfacein asm 3.2 and a Classin asm 4.0 onwards.

您看到的具体错误是因为org.objectweb.asm.ClassVisitor是asm 3.2 中的接口和asm 4.0 及更高版本中的

回答by virgo47

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.

我在一个模块中使用 Spring 和 Groovy 时遇到了同样的问题。3.1.2 中的 Spring 仍然使用较旧的 ASM,Groovy 使用带有类的那个。虽然可以调整一些排除项,但我敢打赌这并不总是一种选择。

After reading this threadI 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.

阅读完这篇文章后,我决定使用 groovy-all.jar 而不是所有 Groovy 所需库的列表。如果这对您来说是一个选择,那么避免任何进一步的问题可能是一种简单的方法。

回答by S.Roshanth

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.

对于以下错误,我尝试了许多解决方案。java.lang.IncompatibleClassChangeError:找到接口 org.objectweb.asm.MethodVisitor,但需要类。只有一个有效的方法是从放心的依赖项中排除 groovy 工件。请参阅以下链接以获取完整的解决方法。

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

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