如何解决 grails 引导执行错误“postProcessBeanDefinitionRegistry 已调用此后处理器”?

发布于 2024-09-25 18:44:20 字数 2973 浏览 0 评论 0原文

我正在构建一个 Grails (1.3.4) 应用程序,配置了 grails 插件 tomcat-1.3.4 并使用 Spring (3.0.3RELEASE),但重用了现有的 Spring applicationContext.xml 文件。我将旧文件的相关部分复制到 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"/>

/Update

通过调试器进行跟踪,我注意到它发生在启动期间刷新 applicationContext 期间(DefaultRuntimeSpringConfiguration:154)。

如果相关的话,我正在使用 IntelliJ IDEA 9,它在 run-app 命令之前处理所有 jar 插入。

感谢您的帮助。

I'm building a Grails (1.3.4) app configured with the grails plugin tomcat-1.3.4 and using Spring (3.0.3RELEASE) but reusing an existing Spring applicationContext.xml file. I copied the relevant portions of the old file into the one generated by Grails (just below the characterEncodingFilter bean). After making sure that all the required jars were on the classpath, and that there was no conflict in bean names (I found out that dataSource was already used if the DataSource.groovy file exists, so I deleted it to resolve that), I am faced with an IllegalStateException. The stacktrace and a bit of the debug log leading it is as follows:

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)

Update:
If I comment out the following lines at the top of my applicationContext.xml, it goes into an infinite loop.

<context:annotation-config/>
<context:property-placeholder location="WEB-INF/config.properties"/>

If I also comment out my import lines, it runs as expected. The import lines are:

<import resource="conf/membershipData.xml"/>
<import resource="conf/membershipServices.xml"/>

/Update

Tracing down through the debugger, I noticed that it occurs during a refresh of the applicationContext during start up (DefaultRuntimeSpringConfiguration:154).

In case it is relevant, I'm using IntelliJ IDEA 9, which is handling all of the jar insertions before the run-app command.

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

走走停停 2024-10-02 18:44:20

您不应该触摸 applicationContext.xml - 这是“父”应用程序上下文。将您的 beans 复制到 grails-app/conf/spring 下的 resources.xml 中。默认情况下不再创建此文件,因为首选方法是在 resources.groovy 中使用 Spring bean DSL,但 resources.xml 的格式只是标准 Spring bean xml,因此您可能只需将 xml 文件复制到此处并将其重命名为 resources.xml。

You shouldn't touch applicationContext.xml - that's for the "parent" application context. Copy your beans into resources.xml under grails-app/conf/spring. This file is no longer created by default since the preferred approach is to use the Spring bean DSL in resources.groovy, but the format of resources.xml is just the standard Spring bean xml, so you could probably just copy your xml file there and rename it to resources.xml.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文