运行测试期间Grails NoClassDefFoundError BuildableCriteria

时间:2017-10-29 17:00:05

标签: grails grails-plugin grails-2.0

我有关于grails 2.3.9的项目,我已将此项目升级为grails 2.5.6,java 8 我已经成功升级了这个,但在测试用例中遇到错误(grails test-app)

java.lang.NoClassDefFoundError: org/grails/datastore/mapping/query/api/BuildableCriteria
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetPublicMethods(Class.java:2902)
    at java.lang.Class.getMethods(Class.java:1615)
    at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1336)
    at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1197)
    at java.beans.Introspector.getBeanInfo(Introspector.java:426)
    at java.beans.Introspector.getBeanInfo(Introspector.java:173)
    at grails.test.mixin.domain.TestGormEnhancer.getStaticApi(DomainClassUnitTestMixin.groovy:188)
    at org.grails.datastore.gorm.GormEnhancer.addStaticMethods(GormEnhancer.groovy:118)
    at org.grails.datastore.gorm.GormEnhancer.enhance(GormEnhancer.groovy:112)
    at org.grails.datastore.gorm.GormEnhancer.enhance(GormEnhancer.groovy:95)
    at grails.test.mixin.domain.DomainClassUnitTestMixin.mockDomains(DomainClassUnitTestMixin.groovy:99)
    at org.spockframework.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:153)
    at org.spockframework.runtime.model.MethodInfo.invoke(MethodInfo.java:84)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:88)
    at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37)
    at grails.test.runtime.TestRuntimeJunitAdapter$1$2.evaluate(TestRuntimeJunitAdapter.groovy:49)
    at org.spockframework.runtime.extension.builtin.TestRuleInterceptor.intercept(TestRuleInterceptor.java:38)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:88)
    at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37)
    at grails.test.runtime.TestRuntimeJunitAdapter$3$4.evaluate(TestRuntimeJunitAdapter.groovy:76)
    at org.spockframework.runtime.extension.builtin.ClassRuleInterceptor.intercept(ClassRuleInterceptor.java:38)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)
Caused by: java.lang.ClassNotFoundException: org.grails.datastore.mapping.query.api.BuildableCriteria
    at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:179)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:151)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

我还添加了数据存储区测试支持依赖项,但遇到了同样的问题: 测试“org.grails:grails-datastore-test-support:1.0-grails-2.4” 它与grails 2.3.9一起工作得很好。

请在这里帮忙

谢谢!

1 个答案:

答案 0 :(得分:0)

org.grails.datastore.mapping.query.api.BuildableCriteria接口包含在grails-datastore-core-3.1.5.RELEASE.jar中,默认情况下会将其作为org.grails.plugins:hibernate4:4.3.10插件的传递依赖项提取到Grails 2.5.6中。我会验证您是否已在BuildConfig.groovy

中表达了对此的依赖
grails.project.dependency.resolution = {
    // ...
    plugins {
        // ...
        runtime ":hibernate4:4.3.10"
        // ...
    }
}