Grails单元测试在GGTS 3.1中失败,字节码接口8出现NoClassDefFoundError错误

Grails单元测试在GGTS 3.1中失败,字节码接口8出现NoClassDefFoundError错误,grails,Grails,我将GGST3.1与Grails1.3.7应用程序一起使用。我为服务方法创建了一个单元测试,并成功地运行了它。(它也通过了!)然后我修改了测试中的方法,修改了单元测试,并尝试再次运行它。测试无法使用以下堆栈跟踪运行 java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8 at com.fxpal.querium.QuerySpecService.extractQueryFields(Qu

我将GGST3.1与Grails1.3.7应用程序一起使用。我为服务方法创建了一个单元测试,并成功地运行了它。(它也通过了!)然后我修改了测试中的方法,修改了单元测试,并尝试再次运行它。测试无法使用以下堆栈跟踪运行

java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8
    at com.fxpal.querium.QuerySpecService.extractQueryFields(QuerySpecService.groovy:133)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:266)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:63)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
    at com.fxpal.querium.QuerySpecServiceTests.testExtractQuery(QuerySpecServiceTests.groovy:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at junit.framework.TestCase.runTest(TestCase.java:168)
    at junit.framework.TestCase.runBare(TestCase.java:134)
    at junit.framework.TestResult$1.protect(TestResult.java:110)
    at junit.framework.TestResult.runProtected(TestResult.java:128)
    at junit.framework.TestResult.run(TestResult.java:113)
    at junit.framework.TestCase.run(TestCase.java:124)
    at junit.framework.TestSuite.runTest(TestSuite.java:232)
    at junit.framework.TestSuite.run(TestSuite.java:227)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.BytecodeInterface8
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    ... 30 more
这似乎与我见过的与部署WAR文件相关的其他错误类似,但在我的例子中,我只是通过IDE运行了一个单元测试。(不是
grailstest-app
,而是从上下文菜单中选择
runas/JUnit-test
。)

下一步我应该尝试什么?


我相信这个错误是因为(在war和我们的案例中)有两个groovy版本(console和IDE),它们试图运行相同的测试用例,有时它们会采用彼此的字节码。需要确保的一点是,他们是否没有共享存储字节码的文件夹。

您还可以尝试验证groovy库是否在测试的类路径中,上次我遇到这种情况时,我只是将它们添加到类路径中,它可以正常运行。


Ger

我认为这可能是由于在IDE中使用错误版本的Groovy作为默认版本造成的。