Java 在Grails中构建具有复合键的表时出现NullPointerException

Java 在Grails中构建具有复合键的表时出现NullPointerException,java,oracle,grails,gorm,grails3,Java,Oracle,Grails,Gorm,Grails3,我有一个表(Oracle12CDB),它在Grails(3.3.9)中不包含显式ID列,我想动态地构建它。因此,我尝试创建一个由其所有列组成的复合键(它们都不可为null),因为这是我能够找到的唯一解决方法,因此代码如下所示: class AliasFrequencyDict implements Serializable{ String frequency String unit String description String lang stati

我有一个表(Oracle12CDB),它在Grails(3.3.9)中不包含显式ID列,我想动态地构建它。因此,我尝试创建一个由其所有列组成的复合键(它们都不可为null),因为这是我能够找到的唯一解决方法,因此代码如下所示:

class AliasFrequencyDict implements Serializable{
    String frequency
    String unit
    String description
    String lang

    static constraints = {
        frequency maxSize: 10, sqlType: 'VARCHAR2'
        unit maxSize: 1, sqlType: 'VARCHAR2'
        description maxSize: 30, sqlType: 'VARCHAR2'
        lang maxSize: 2, sqlType: 'VARCHAR2'
    }

    static mapping = {
        sort 'frequency'
        version false
        id composite: ['frequency', 'unit', 'description', 'lang']
    }
}
    Line | Method
->>  473 | createGroovyPageException    in Byte array resource [view:-,-,aliasFrequencyDict:index]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Caused by GrailsTagException: [Byte array resource [view:-,-,aliasFrequencyDict:index]:21] Error executing tag <f:table>: null
->>   21 | throwRootCause               in Byte array resource [view:-,-,aliasFrequencyDict:index]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Caused by NullPointerException: null
->>   35 | <init>                       in org.grails.scaffolding.model.property.DomainPropertyImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     26 | build                        in org.grails.scaffolding.model.property.DomainPropertyFactoryImpl
|    118 | getListOutputProperties . .  in org.grails.scaffolding.model.DomainModelServiceImpl
|    540 | resolvePersistentProperties  in grails.plugin.formfields.FormFieldsTagLib
|    415 | resolvePropertyNames . . . . in     ''
|    402 | resolveProperties            in     ''
|    230 | doCall . . . . . . . . . . . in grails.plugin.formfields.FormFieldsTagLib$_closure4
|    446 | invokeTagLibClosure          in org.grails.gsp.GroovyPage
|    364 | invokeTag . . . . . . . . .  in     ''
|     54 | doCall                       in Byte_array_resource__view_____aliasFrequencyDict_index_$_run_closure2
|    200 | executeClosure . . . . . . . in org.grails.taglib.TagBodyClosure
|    102 | captureClosureOutput         in     ''
|    213 | call . . . . . . . . . . . . in     ''
|     48 | captureTagContent            in org.grails.plugins.web.taglib.SitemeshTagLib
|    156 | doCall . . . . . . . . . . . in org.grails.plugins.web.taglib.SitemeshTagLib$_closure3
|    446 | invokeTagLibClosure          in org.grails.gsp.GroovyPage
|    364 | invokeTag . . . . . . . . .  in     ''
|     72 | run                          in Byte_array_resource__view_____aliasFrequencyDict_index_
|    162 | doWriteTo . . . . . . . . .  in org.grails.gsp.GroovyPageWritable
|     82 | writeTo                      in     ''
|     76 | renderTemplate . . . . . . . in org.grails.web.servlet.view.GroovyPageView
|     71 | renderWithinGrailsWebRequest in org.grails.web.servlet.view.AbstractGrailsView
|     55 | renderMergedOutputModel . .  in     ''
|    303 | render                       in org.springframework.web.servlet.view.AbstractView
|    150 | renderInnerView . . . . . .  in org.grails.web.sitemesh.GrailsLayoutView
|    128 | obtainContent                in     ''
|     63 | renderTemplate . . . . . . . in     ''
|     71 | renderWithinGrailsWebRequest in org.grails.web.servlet.view.AbstractGrailsView
|     55 | renderMergedOutputModel . .  in     ''
|    303 | render                       in org.springframework.web.servlet.view.AbstractView
|   1286 | render . . . . . . . . . . . in org.springframework.web.servlet.DispatcherServlet
|   1041 | processDispatchResult        in     ''
|    984 | doDispatch . . . . . . . . . in     ''
|    901 | doService                    in     ''
|    970 | processRequest . . . . . . . in org.springframework.web.servlet.FrameworkServlet
|    861 | doGet                        in     ''
|    846 | service . . . . . . . . . .  in     ''
|     55 | doFilterInternal             in org.springframework.boot.web.filter.ApplicationContextHeaderFilter
|     77 | doFilterInternal . . . . . . in org.grails.web.servlet.mvc.GrailsWebRequestFilter
|     67 | doFilterInternal             in org.grails.web.filters.HiddenHttpMethodFilter
|   1149 | runWorker . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    624 | run                          in java.util.concurrent.ThreadPoolExecutor$Worker
^    748 | run . . . . . . . . . . . .  in java.lang.Thread
在控制器中,我只需要
静态scaffold=aliasfrequencycdict
。但是,当我尝试访问索引时,我得到了一个
java.lang.NullPointerException
,消息读取
请求处理失败;嵌套异常为org.grails.gsp.groovyPageSexException:处理GroovyPageView时出错:[字节数组资源[view:-,-,aliasFrequencyDict:index]:21]执行标记时出错:null
。stacktrace如下所示:

class AliasFrequencyDict implements Serializable{
    String frequency
    String unit
    String description
    String lang

    static constraints = {
        frequency maxSize: 10, sqlType: 'VARCHAR2'
        unit maxSize: 1, sqlType: 'VARCHAR2'
        description maxSize: 30, sqlType: 'VARCHAR2'
        lang maxSize: 2, sqlType: 'VARCHAR2'
    }

    static mapping = {
        sort 'frequency'
        version false
        id composite: ['frequency', 'unit', 'description', 'lang']
    }
}
    Line | Method
->>  473 | createGroovyPageException    in Byte array resource [view:-,-,aliasFrequencyDict:index]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Caused by GrailsTagException: [Byte array resource [view:-,-,aliasFrequencyDict:index]:21] Error executing tag <f:table>: null
->>   21 | throwRootCause               in Byte array resource [view:-,-,aliasFrequencyDict:index]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Caused by NullPointerException: null
->>   35 | <init>                       in org.grails.scaffolding.model.property.DomainPropertyImpl
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     26 | build                        in org.grails.scaffolding.model.property.DomainPropertyFactoryImpl
|    118 | getListOutputProperties . .  in org.grails.scaffolding.model.DomainModelServiceImpl
|    540 | resolvePersistentProperties  in grails.plugin.formfields.FormFieldsTagLib
|    415 | resolvePropertyNames . . . . in     ''
|    402 | resolveProperties            in     ''
|    230 | doCall . . . . . . . . . . . in grails.plugin.formfields.FormFieldsTagLib$_closure4
|    446 | invokeTagLibClosure          in org.grails.gsp.GroovyPage
|    364 | invokeTag . . . . . . . . .  in     ''
|     54 | doCall                       in Byte_array_resource__view_____aliasFrequencyDict_index_$_run_closure2
|    200 | executeClosure . . . . . . . in org.grails.taglib.TagBodyClosure
|    102 | captureClosureOutput         in     ''
|    213 | call . . . . . . . . . . . . in     ''
|     48 | captureTagContent            in org.grails.plugins.web.taglib.SitemeshTagLib
|    156 | doCall . . . . . . . . . . . in org.grails.plugins.web.taglib.SitemeshTagLib$_closure3
|    446 | invokeTagLibClosure          in org.grails.gsp.GroovyPage
|    364 | invokeTag . . . . . . . . .  in     ''
|     72 | run                          in Byte_array_resource__view_____aliasFrequencyDict_index_
|    162 | doWriteTo . . . . . . . . .  in org.grails.gsp.GroovyPageWritable
|     82 | writeTo                      in     ''
|     76 | renderTemplate . . . . . . . in org.grails.web.servlet.view.GroovyPageView
|     71 | renderWithinGrailsWebRequest in org.grails.web.servlet.view.AbstractGrailsView
|     55 | renderMergedOutputModel . .  in     ''
|    303 | render                       in org.springframework.web.servlet.view.AbstractView
|    150 | renderInnerView . . . . . .  in org.grails.web.sitemesh.GrailsLayoutView
|    128 | obtainContent                in     ''
|     63 | renderTemplate . . . . . . . in     ''
|     71 | renderWithinGrailsWebRequest in org.grails.web.servlet.view.AbstractGrailsView
|     55 | renderMergedOutputModel . .  in     ''
|    303 | render                       in org.springframework.web.servlet.view.AbstractView
|   1286 | render . . . . . . . . . . . in org.springframework.web.servlet.DispatcherServlet
|   1041 | processDispatchResult        in     ''
|    984 | doDispatch . . . . . . . . . in     ''
|    901 | doService                    in     ''
|    970 | processRequest . . . . . . . in org.springframework.web.servlet.FrameworkServlet
|    861 | doGet                        in     ''
|    846 | service . . . . . . . . . .  in     ''
|     55 | doFilterInternal             in org.springframework.boot.web.filter.ApplicationContextHeaderFilter
|     77 | doFilterInternal . . . . . . in org.grails.web.servlet.mvc.GrailsWebRequestFilter
|     67 | doFilterInternal             in org.grails.web.filters.HiddenHttpMethodFilter
|   1149 | runWorker . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor
|    624 | run                          in java.util.concurrent.ThreadPoolExecutor$Worker
^    748 | run . . . . . . . . . . . .  in java.lang.Thread
Line |方法
->>473 |字节数组资源中的createGroovyPageException[view:-,-,aliasFrequencyDict:index]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
由GrailStageException引起:[字节数组资源[view:-,-,aliasFrequencyDict:index]:21]执行标记时出错:null
->>21 |字节数组资源中的throwRootCause[视图:-,-,别名频率dict:index]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
由NullPointerException引起:null
->>35 |在org.grails.scaffolding.model.property.DomainPropertyImpl中
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|26 |内置org.grails.scaffolding.model.property.DomainPropertyFactoryImpl
|118 | getListOutputProperties。在org.grails.scaffolding.model.DomainModelServiceImpl中
|540 | grails.plugin.formfields.FormFieldsTagLib中的resolvePersistentProperties
|415 |解析属性名称。在“
|402 |解析“”中的属性
|230 | doCall。在grails.plugin.formfields.FormFieldsTagLib$\u closure4中
|446 | org.grails.gsp.GroovyPage中的invokeTagLibClosure
|364 |调用标签。在“
|54 | doCall in Byte_array_resource___视图______别名frequencycdict_index_$_run_closure2
|200 |行政公开。在org.grails.taglib.TagBodyClosure中
|102 | captureClosureOutput在“”中
|213 |打电话。在“
|48 | org.grails.plugins.web.taglib.siteMethTaglib中的captureTagContent
|156 | doCall。在org.grails.plugins.web.taglib.SitemeshTagLib$\u closure3中
|446 | org.grails.gsp.GroovyPage中的invokeTagLibClosure
|364 |调用标签。在“
|72 |在字节数组资源视图别名频率索引中运行_
|162 |嫁妆。在org.grails.gsp.GroovyPageWritable中
|82 |写在“”中
|76 |渲染模板。在org.grails.web.servlet.view.GroovyPageView中
|71 | org.grails.web.servlet.view.AbstractGrailsView中的renderWithinGrailsWebRequest
|55 | renderMergedOutputModel。在“
|303 |在org.springframework.web.servlet.view.AbstractView中呈现
|150 | renderInnerView。在org.grails.web.sitemesh.GrailsLayoutView中
|128 |在“”中获取内容
|63 |渲染模板。在“
|71 | org.grails.web.servlet.view.AbstractGrailsView中的renderWithinGrailsWebRequest
|55 | renderMergedOutputModel。在“
|303 |在org.springframework.web.servlet.view.AbstractView中呈现
|1286 |渲染。在org.springframework.web.servlet.DispatcherServlet中
|1041 | processDispatchResult在“”中
|984 | doDispatch。在“
|901 | doService在“”中
|970 |处理请求。在org.springframework.web.servlet.FrameworkServlet中
|861 | doGet in“
|846 |服务。在“
|55 | org.springframework.boot.web.filter.ApplicationContextHeaderFilter中的doFilterInternal
|77 |内部过滤器。在org.grails.web.servlet.mvc.GrailsWebRequestFilter中
|67 | org.grails.web.filters.hiddenhttmpmethodfilter中的doFilterInternal
|1149 |运行工人。在java.util.concurrent.ThreadPoolExecutor中
|624 |在java.util.concurrent.ThreadPoolExecutor$Worker中运行
^748 |运行。在java.lang.Thread中

为什么会这样?如何修复此问题,使脚手架重新开始工作?

在Grails 3.3.11中看到了同样的情况。你找到解决办法了吗?@nickdos遗憾地说,我是为过去的一场演出做的,可惜我早就忘记了:(我甚至不记得我是否找到了解决办法,或者只是一些简单的解决办法,更不用说确切的解决办法了。对不起!