2014-09-06 83 views
1

我使用的Grails 2.4.2,并且已安装Grails的官方安全插件使用错误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 
+0

嗨Shashank Goyal。您是否在BuildConfig中添加了这些存储库:“http://repo.spring.io/milestone/”“http://repo.grails.org/grails/core”?你是否与上次RC(RC4)有同样的问题? – Abincepto 2014-09-06 15:09:30

回答

2

最新版本o f 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' 
    ... 
} 
... 
0

你的春季安全内核的版本不使用支架正常工作, 更新BuildConfig.groovy使用最新版本Spring Security Core Plugin

plugins { 
    ... 
    compile ':spring-security-core:2.0.0' 
    ... 
} 
+0

添加一些解释和回答这个答案如何帮助OP在解决当前问题 – 2017-01-17 11:22:40