我正在构建一个使用 grails 插件 tomcat-1.3.4 配置并使用 Spring (3.0.3RELEASE) 但重用现有 Spring applicationContext.xml 文件的 Grails (1.3.4) 应用程序。我将旧文件的相关部分复制到 Grails 生成的文件中(就在 characterEncodingFilter bean 的下方)。在确保所有必需的 jar 都在类路径上,并且 bean 名称没有冲突之后(如果 DataSource.groovy 文件存在,我发现 dataSource 已经被使用,所以我删除它来解决这个问题),我面临 IllegalStateException。堆栈跟踪和一些引导它的调试日志如下:
2010-09-30 15:29:36,131 [main] DEBUG xml.DefaultDocumentLoader - Using JAXP provider [com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl]
2010-09-30 15:29:36,143 [main] DEBUG support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'grailsApplication'
2010-09-30 15:29:36,149 [main] ERROR context.GrailsContextLoader - Error executing bootstraps: postProcessBeanDefinitionRegistry already called for this post-processor
java.lang.IllegalStateException: postProcessBeanDefinitionRegistry already called for this post-processor
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:164)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
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.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:590)
at gant.Gant.executeTargets(Gant.groovy:589)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
更新:如果我在 applicationContext.xml 的顶部注释掉以下行,它将进入无限循环。
<context:annotation-config/>
<context:property-placeholder location="WEB-INF/config.properties"/>
如果我还注释掉我的导入行,它会按预期运行。导入行是:
<import resource="conf/membershipData.xml"/>
<import resource="conf/membershipServices.xml"/>
/更新
通过调试器跟踪,我注意到它发生在启动期间刷新 applicationContext 期间(DefaultRuntimeSpringConfiguration:154)。
如果相关,我使用的是 IntelliJ IDEA 9,它在 run-app 命令之前处理所有 jar 插入。
谢谢你的帮助。