2014-09-06 58 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