2

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

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

然后我尝试通过install-plugin命令安装插件。无论我选择哪种方式,我都无法启动项目,因为我已经运行了s2-quickstart脚本(它创建了 Spring Security 域类和控制器)。

我使用 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-app然后grails cleangrails 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
4

2 回答 2

5

应用程序是否在禁用重新加载(弹簧加载代理)的情况下启动?

grails -noreloading run-app

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

于 2013-04-03T17:00:01.133 回答
0

我自己解决了这个问题。当我从 cmd 运行应用程序时,它似乎可以工作。原因是我安装的 groovy 编译器和 GGTS 正在使用的编译器不匹配。

于 2013-05-12T22:27:45.403 回答