无法在Windows 7上使用GGTS中的Spring Security Core运行Grails项目

时间:2013-03-29 21:33:30

标签: spring-security grails-plugin grails-2.2

我是Grails的新手,我正在拼命想让Spring Security插件运行。我在项目的BuildConfig.groovy中添加了以下行:

plugins{
    ... 
    compile ":spring-security-core:1.2.7.3" 
    ...
}

然后我尝试通过install-plugin命令安装插件。无论我选择哪种方式,我都无法启动项目,因为我已运行s2-quickstart脚本(creates the Spring Security domain classes and controllers)。

我正在使用PostgreSQL作为数据库并在Windows 7上运行Groovy / Grails Tool Suite,使用Grails版本2.2.1。

这是错误消息:

| Loading Grails 2.2.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 7 source files.....
| Running Grails application

Configuring Spring Security Core ...
... finished configuring Spring Security Core

| Error 2013-03-29 22:15:17,677 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'instanceTagLibraryApi': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi.setGspTagLibraryLookup(org.codehaus.groovy.grails.web.pages.TagLibraryLookup); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.codehaus.groovy.grails.web.mapping.LinkGenerator org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib.linkGenerator; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsLinkGenerator': Post-processing failed of bean type [class org.codehaus.groovy.grails.web.mapping.CachingLinkGenerator] failed; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
Message: Error creating bean with name 'instanceTagLibraryApi': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi.setGspTagLibraryLookup(org.codehaus.groovy.grails.web.pages.TagLibraryLookup); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.codehaus.groovy.grails.web.mapping.LinkGenerator org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib.linkGenerator; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsLinkGenerator': Post-processing failed of bean type [class org.codehaus.groovy.grails.web.mapping.CachingLinkGenerator] failed; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
    Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Could not autowire method: public void org.codehaus.groovy.grails.plugins.web.api.TagLibraryApi.setGspTagLibraryLookup(org.codehaus.groovy.grails.web.pages.TagLibraryLookup); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.codehaus.groovy.grails.web.mapping.LinkGenerator org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib.linkGenerator; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsLinkGenerator': Post-processing failed of bean type [class org.codehaus.groovy.grails.web.mapping.CachingLinkGenerator] failed; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'gspTagLibraryLookup': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.codehaus.groovy.grails.web.mapping.LinkGenerator org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib.linkGenerator; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsLinkGenerator': Post-processing failed of bean type [class org.codehaus.groovy.grails.web.mapping.CachingLinkGenerator] failed; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.codehaus.groovy.grails.web.mapping.LinkGenerator org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib.linkGenerator; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsLinkGenerator': Post-processing failed of bean type [class org.codehaus.groovy.grails.web.mapping.CachingLinkGenerator] failed; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Could not autowire field: private org.codehaus.groovy.grails.web.mapping.LinkGenerator org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib.linkGenerator; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsLinkGenerator': Post-processing failed of bean type [class org.codehaus.groovy.grails.web.mapping.CachingLinkGenerator] failed; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'grailsLinkGenerator': Post-processing failed of bean type [class org.codehaus.groovy.grails.web.mapping.CachingLinkGenerator] failed; nested exception is java.lang.ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
Caused by ClassCastException: com.sun.proxy.$Proxy26 cannot be cast to java.lang.annotation.Annotation
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

修改 使用run-app --verbose --stacktrace运行应用程序会导致服务器成功启动,但该过程无法在后台完成。一段时间后,服务器关闭并显示错误:

run-app --verbose --stacktrace encountered a problem

timelimit was exceeded.

编辑2: grails -noreload run-appgrails clean后跟grails run-app两者都会导致服务器正常启动,但服务器会在短时间后关闭(正如我在第一次编辑中所述):

grails -noreload run-app encountered a problem

当我删除$USER/.grails/中的常春藤缓存时,会发生同样的情况。

有关此错误的信息是控制台输出的副本:

| Loading Grails 2.2.1
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 1 source files
  [groovyc] Compiling 1 source file to C:\Grails\test\target\classes
| Compiling 1 source files.....
| Running Grails application

Configuring Spring Security Core ...
... finished configuring Spring Security Core

| Server running. Browse to http://localhost:9000/test

2 个答案:

答案 0 :(得分:5)

应用启动时是否已禁用重新加载(spring-loaded agent)?

grails -noreloading run-app

Grails Jira报告了类似的问题GRAILS-9952。如果您可以提供可以重现问题的测试应用程序,它将有助于解决问题。请将其附在jira问题上。

答案 1 :(得分:0)

我自己解决了这个问题。当我从cmd运行应用程序时,它似乎工作。造成这种情况的原因是我安装的常规编译器与GGTS正在使用的不匹配。