得到 java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11858339/
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
Got java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
提问by Tom
Got the following exception while executing a java class in a command shelll
在命令 shelll 中执行 java 类时出现以下异常
Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObj
ect
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access##代码##0(URLClassLoader.java:58)
at java.net.URLClassLoader.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Because the code is not written by me, and I am not familiar with groovy, it's difficult to me to investigate where the issue is. Please kindly give me a clue.
因为代码不是我写的,我对groovy不熟悉,所以我很难调查问题出在哪里。请给我一个线索。
PS:I have added groovy-all.jar to my classpath.
PS:我已将 groovy-all.jar 添加到我的类路径中。
回答by Tjad Clark
An issue I ran into was a version mismatch of Groovy. More specifically, it seemed that I was running a compiled groovy class under 2.1.1 where it was compiled under 1.8.6
我遇到的一个问题是 Groovy 的版本不匹配。更具体地说,我似乎在 2.1.1 下运行编译的 groovy 类,它是在 1.8.6 下编译的
Changing the library included on the classpath to 1.8.6 resolved my issue.
将类路径中包含的库更改为 1.8.6 解决了我的问题。