1

我通过执行以下操作将我的 Grails 1.3.7 应用程序升级到 Grails 2.2

  1. GRAILS_HOME变量设置为 Grails 2.2 的位置
  2. 编辑了指向此位置的路径
  3. grails upgrade
  4. 编辑application.properties删除所有插件引用
  5. 编辑Build.config创建一个plugins闭包来引用我的插件
  6. grails clean
  7. grails compile

步骤 7 失败并出现以下错误:

C:\code\querium\AppServer-grails-2>grails compile --stacktrace
| Compiling 98 source files
| Warning The [executeSafely] action accepts a parameter of type [groovy.lang.Closure] which has not been marked with @V
alidateable.  Data binding will still be applied to this command object but the instance will not be validateable.

       def executeSafely(Closure c) {
       ^
| Warning The [executeSafely] action accepts a parameter of type [groovy.lang.Closure] which has not been marked with @V
alidateable.  Data binding will still be applied to this command object but the instance will not be validateable.

        def executeSafely(Closure c) {
    ^
| Warning The [increment] action accepts a parameter of type [java.util.Map] which has not been marked with @Validateabl
e.  Data binding will still be applied to this command object but the instance will not be validateable.

        def increment(Map map, String t, int index) {
    ^
| Compiling 98 source files.
| Error Fatal error during compilation org.apache.tools.ant.BuildException: Compilation Failed (NOTE: Stack trace has be
en filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.codehaus.gant.GantBuilder.invokeMethod(GantBuilder.java:99)
        at _GrailsCompile_groovy$_run_closure2_closure6_closure7.doCall(_GrailsCompile_groovy:48)
        at _GrailsCompile_groovy$_run_closure2_closure6_closure7.doCall(_GrailsCompile_groovy)
        at _GrailsCompile_groovy.withCompilationErrorHandling(_GrailsCompile_groovy:69)
        at _GrailsCompile_groovy.this$4$withCompilationErrorHandling(_GrailsCompile_groovy)
        at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
        at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:168)
        at _GrailsCompile_groovy$_run_closure2_closure6.doCall(_GrailsCompile_groovy:47)
        at _GrailsCompile_groovy$_run_closure2_closure6.doCall(_GrailsCompile_groovy)
        at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
        at _GrailsCompile_groovy$_run_closure2.doCall(_GrailsCompile_groovy:46)
        at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
        at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:1
85)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
        at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
        at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
        at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
        at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
        at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
        at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:427)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:415)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.executeTargets(Gant.groovy:591)
        at gant.Gant.executeTargets(Gant.groovy:590)
| Error Fatal error during compilation org.apache.tools.ant.BuildException: Compilation Failed

我不确定真正的错误在哪里,以及如何纠正它。我很乐意忽略这些警告,除非有充分的理由来修复它们。(如果有,怎么做?)

4

1 回答 1

2

我不确定 NPE,但警告是由于控制器中的公共方法引起的。控制器不能从应用程序代码中调用,所以公共方法没有意义。在 2.0+ 中,动作现在可以是除了闭包之外的方法,因此您的辅助方法被误解为控制器动作。将它们设为私有,警告就会消失,幸运的是,NPE 也会消失。

顺便说一句,文档中有升级信息:)

于 2012-12-25T03:14:43.410 回答