使用grails安全插件时出错

使用grails安全插件时出错,grails,plugins,spring-security,Grails,Plugins,Spring Security,我正在使用Grails2.4.2,并且已经安装了grails官方安全插件 compile ':spring-security-core:2.0-RC2' 当我第一次编译应用程序时,它给出了一个错误 | Compiling 183 source files Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. [groovyc] o

我正在使用Grails2.4.2,并且已经安装了grails官方安全插件

compile ':spring-security-core:2.0-RC2'
当我第一次编译应用程序时,它给出了一个错误

| Compiling 183 source files
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] C:\Users\Shanky\Backup\myApp\target\work\plugins\spring-security-core-2.0-RC2\src\groovy\grails\plugin\springsecurity\ReflectionUtils.groovy: 205: Apparent variable 'org' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
[groovyc] You attempted to reference a variable in the binding or an instance variable from a static context.
[groovyc] You misspelled a classname or statically imported field. Please check the spelling.
[groovyc] You attempted to use a method 'org' but left out brackets in a place not allowed by the grammar.
[groovyc]  @ line 205, column 18.
[groovyc]                     application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
[groovyc]                     ^
[groovyc]
[groovyc] 1 error
| Compiling 183 source files.
| Error Compilation error: startup failed:
C:\Users\Shanky\Backup\myApp\target\work\plugins\spring-security-core-2.0-RC2\src\groovy\grails\plugin\springsecurity\ReflectionUtils.groovy: 205: Apparent variable 'org' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable from a static context.
You misspelled a classname or statically imported field. Please check the spelling.
You attempted to use a method 'org' but left out brackets in a place not allowed by the grammar.
@ line 205, column 18.
                    application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
                ^

1 error
然而,当我稍后编译应用程序时,它编译得很好,但在我运行应用程序时出现了错误

| Error Error generating web.xml file (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
 java.lang.NullPointerException
    at grails.plugin.springsecurity.SpringSecurityUtils.mergeConfig(SpringSecurityUtils.java:663)
    at grails.plugin.springsecurity.SpringSecurityUtils.mergeConfig(SpringSecurityUtils.java:643)
    at grails.plugin.springsecurity.SpringSecurityUtils.reloadSecurityConfig(SpringSecurityUtils.java:260)
    at grails.plugin.springsecurity.SpringSecurityUtils.getSecurityConfig(SpringSecurityUtils.java:227)
    at SpringSecurityCoreGrailsPlugin$_closure1.doCall(SpringSecurityCoreGrailsPlugin.groovy:166)
    at _GrailsPackage$_run_closure5.doCall(_GrailsPackage.groovy:74)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    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 org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at _GrailsPackage$_run_closure2.doCall(_GrailsPackage.groovy:58)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    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 org.codehaus.gant.GantMetaClass.processClosure(GantMetaClass.java:81)
    at org.codehaus.gant.GantMetaClass.processArgument(GantMetaClass.java:95)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:128)
    at RunApp$_run_closure1.doCall(RunApp.groovy:28)
    at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
    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$0.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 Error generating web.xml file

最新版本的Spring Security插件
Spring Security core 2.0-RC4
使用
Holder
而不是使用Grails 2.4.x应用程序的折旧
ApplicationHolder
可以正常工作

更新BuildConfig.groovy以使用最新版本:

BuildConfig.groovy

...
plugins {
  ...
  compile ':spring-security-core:2.0-RC4'
  ...
}
...

您的spring security core版本在使用支架时无法正常工作, 更新BuildConfig.groovy以使用最新版本


嗨,沙尚克·戈亚尔。您是否在BuildConfig中添加了这些存储库:“”?您对上一个RC(RC4)有相同的问题吗?添加一些解释和答案,说明此答案如何帮助OP解决当前问题
plugins {
  ...
  compile ':spring-security-core:2.0.0'
  ...
}