我正在使用grails 2.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
然而,当我在一段时间后编译应用程序时,它编译得很好,但是当我运行App时出错了
| 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
答案 0 :(得分:2)
最新版本的Spring Security插件spring-security-core 2.0-RC4
使用Holders
而不是Grails 2.4.x应用程序的折旧ApplicationHolder
正常工作。
更新BuildConfig.groovy以使用最新版本:
<强> BuildConfig.groovy 强>
...
plugins {
...
compile ':spring-security-core:2.0-RC4'
...
}
...
答案 1 :(得分:0)
使用Holders,您的spring-security-core版本无法正常工作 更新BuildConfig.groovy以使用Spring Security Core Plugin
中的最新版本plugins {
...
compile ':spring-security-core:2.0.0'
...
}