圣杯 / 戈尔姆 / 线程中的异常 "Thread-8" 错误!源单元中阶段 'semantic analysis' 中的异常



在带有Grails 3.3.2的Gorm 6.1中获取此异常:

    Exception in thread "Thread-8" BUG! exception in phase 'semantic analysis' in source unit '/Users/emmanuj/projects/cleena/demo/src/main/groovy/com/emmanuj/cleena/UserService.groovy' unexpected NullpointerException
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1070)
            at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
            at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
            at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
            at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:537)
            at grails.boot.GrailsApp.compileGroovyFile(GrailsApp.groovy:313)
            at grails.boot.GrailsApp.recompile(GrailsApp.groovy:299)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
            at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
            at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
            at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
            at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
            at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
            at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
            at grails.boot.GrailsApp$_enableDevelopmentModeWatch_closure1.doCall(GrailsApp.groovy:240)
            at grails.boot.GrailsApp$_enableDevelopmentModeWatch_closure1.doCall(GrailsApp.groovy)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
            at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
            at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
            at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
            at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
            at groovy.lang.Closure.call(Closure.java:414)
            at groovy.lang.Closure.call(Closure.java:408)
            at groovy.lang.Closure.run(Closure.java:495)
            at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.NullPointerException
            at org.grails.datastore.gorm.services.implementers.AbstractDetachedCriteriaServiceImplementor.doImplement(AbstractDetachedCriteriaServiceImplementor.groovy:79)
            at org.grails.datastore.gorm.services.implementers.AbstractReadOperationImplementer.implement(AbstractReadOperationImplementer.groovy:62)
            at org.grails.datastore.gorm.services.transform.ServiceTransformation.visitAfterTraitApplied(ServiceTransformation.groovy:278)
            at org.grails.datastore.gorm.transform.AbstractTraitApplyingGormASTTransformation.visit(AbstractTraitApplyingGormASTTransformation.groovy:52)
            at org.grails.datastore.gorm.transform.AbstractTraitApplyingGormASTTransformation.visit(AbstractTraitApplyingGormASTTransformation.groovy:42)
            at org.grails.datastore.gorm.transform.AbstractGormASTTransformation.visit(AbstractGormASTTransformation.groovy:59)
            at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134)
            at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178)
            at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065)
            ... 34 more

重现步骤

  1. 创建一个新的Grails 3.3.2项目
  2. 创建一个名为 User 的域类,如下所示:

    import grails.compiler.GrailsCompileStatic
    @GrailsCompileStatic
    class User {
        String name
        static constraints = {
        }
    }
    
  3. 以及以下 Gorm 数据服务接口和类:

    package com.emmanuj.cleena
    /**
     * DataService interface for user domain
     */
    interface IUserService {
        User get(Serializable id)
        List<User> list(Map args)
        Long count()
        void delete(Serializable id)
        User save(User user)
    }
    

还有一个抽象的类实现:

    @Slf4j
    @Service(User)
    abstract class UserService implements IUserService {
        def grailsApplication
        List<User> search(User currentUser, long radius, int offset, int max){
            return []
        }
        def getZipcodes(String zipCode, long radius) {
            return []
        }
    }
  1. 从交互式提示运行您的圣杯应用程序。
  2. 对用户服务进行更改
  3. 重新编译期间异常/崩溃。

时髦版本是 2.4.13

我在 github 存储库上打开了一个问题。看起来像一个GORM冬眠错误:https://github.com/grails/gorm-hibernate5/issues/72。但他们已将其关闭为"无法修复"。不知道为什么...

重新启动Grails服务器解决了这个问题。

以下是实际解释——

我创建了一个工作正常的类,然后将其更新为关联另一个依赖类,Grails 抛出了此错误。该错误仅意味着当服务器运行时需要创建更多对象时,它无法编译已编译的类。

相关内容

  • 没有找到相关文章

最新更新