无法初始化上下文,因为已经存在根应用程序上下文

发布于 2024-12-21 06:11:29 字数 8230 浏览 2 评论 0原文

我的项目使用tapestry 5.3.0,spring 3.0.6.RELEASE,hibernate 3.6.8.FINAL和maven。When 我指示 jetty 使用 mvn jetty:run 启动项目,我得到以下信息:

2011-12-13 16:15:42.947:WARN::failed app: java.lang.RuntimeException: Exception     constructing service 'ApplicationContext': Cannot initialize context because there is  already a root application context present - check whether you have multiple ContextLoader*  definitions in your web.xml!
2011-12-13 16:15:42.948:WARN::Failed startup of context  org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@98062f{/projektni,/home/borislav/eclipse_ workspace/web_apps/projektni/src/main/webapp}
java.lang.RuntimeException: Exception constructing service 'ApplicationContext': Cannot  initialize context because there is already a root application context present - check  whether you have multiple ContextLoader* definitions in your web.xml!
at  org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(J ustInTimeObjectCreator.java:78)
at   org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeOb jectCreator.java:56)
at $ConfigurableWebApplicationContext_10f23e440970.delegate(Unknown Source)
at $ConfigurableWebApplicationContext_10f23e440970.getBeanDefinitionCount(Unknown  Source)
at  org.apache.tapestry5.spring.SpringModule$1.initializeApplication(SpringModule.java:58)
at $ApplicationInitializer_10f23e440987.initializeApplication(Unknown Source)
at  org.apache.tapestry5.services.TapestryModule$39.initializeApplication(TapestryModule.java:25 55)
at $ApplicationInitializer_10f23e440987.initializeApplication(Unknown Source)
at $ApplicationInitializer_10f23e440983.initializeApplication(Unknown Source)
at  org.apache.tapestry5.services.TapestryModule$ServletApplicationInitializerTerminator.initial izeApplication(TapestryModule.java:411)
at $ServletApplicationInitializer_10f23e440969.initializeApplication(Unknown Source)
at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:102)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
at  org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:11 5)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at  org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156 )
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:454)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:396)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
at    org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java :107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuild er.java:84)
at  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuild er.java:59)
at  org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.ja va:183)
at  org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
2011-12-13 16:15:43.009:INFO::Started [email protected]:8080[INFO] 
Started Jetty Server

Web.xml 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>projektni Tapestry 5 Application</display-name>

<context-param>
    <!-- The only significant configuration for Tapestry 5, this informs Tapestry 
        of where to look for pages, components and mixins. -->
    <param-name>tapestry.app-package</param-name>
    <param-value>org.prikic.projektni</param-value>
</context-param>
<!-- Specify some additional Modules for two different execution modes: 
    development and qa. Remember that the default execution mode is production -->
<context-param>
    <param-name>tapestry.development-modules</param-name>
    <param-value>
        org.prikic.projektni.services.DevelopmentModule
    </param-value>
</context-param>
<context-param>
    <param-name>tapestry.qa-modules</param-name>
    <param-value>
        org.prikic.projektni.services.QaModule
    </param-value>
</context-param>


<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>

        <!-- /WEB-INF/application_context_dao.xml -->
        <!--  /WEB-INF/application_context*.xml -->
        classpath:application_context*.xml

    </param-value>
</context-param>

<filter>
    <filter-name>app</filter-name>
    <!-- Special filter that adds in a T5 IoC module derived from the Spring 
        WebApplicationContext. -->
    <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>app</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

<!-- <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>  -->

<welcome-file-list>
    <welcome-file>Index</welcome-file>
</welcome-file-list>

如果您需要任何其他源代码文件,请告诉我,我将发布它们的

想法,有人吗?

My project uses tapestry 5.3.0,spring 3.0.6.RELEASE,hibernate 3.6.8.FINAL and maven.When
I intruct jetty to start the project with mvn jetty:run, I get the following:

2011-12-13 16:15:42.947:WARN::failed app: java.lang.RuntimeException: Exception     constructing service 'ApplicationContext': Cannot initialize context because there is  already a root application context present - check whether you have multiple ContextLoader*  definitions in your web.xml!
2011-12-13 16:15:42.948:WARN::Failed startup of context  org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@98062f{/projektni,/home/borislav/eclipse_ workspace/web_apps/projektni/src/main/webapp}
java.lang.RuntimeException: Exception constructing service 'ApplicationContext': Cannot  initialize context because there is already a root application context present - check  whether you have multiple ContextLoader* definitions in your web.xml!
at  org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(J ustInTimeObjectCreator.java:78)
at   org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeOb jectCreator.java:56)
at $ConfigurableWebApplicationContext_10f23e440970.delegate(Unknown Source)
at $ConfigurableWebApplicationContext_10f23e440970.getBeanDefinitionCount(Unknown  Source)
at  org.apache.tapestry5.spring.SpringModule$1.initializeApplication(SpringModule.java:58)
at $ApplicationInitializer_10f23e440987.initializeApplication(Unknown Source)
at  org.apache.tapestry5.services.TapestryModule$39.initializeApplication(TapestryModule.java:25 55)
at $ApplicationInitializer_10f23e440987.initializeApplication(Unknown Source)
at $ApplicationInitializer_10f23e440983.initializeApplication(Unknown Source)
at  org.apache.tapestry5.services.TapestryModule$ServletApplicationInitializerTerminator.initial izeApplication(TapestryModule.java:411)
at $ServletApplicationInitializer_10f23e440969.initializeApplication(Unknown Source)
at org.apache.tapestry5.TapestryFilter.init(TapestryFilter.java:102)
at org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:713)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1282)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:518)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:499)
at  org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:11 5)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at  org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156 )
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:454)
at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:396)
at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
at    org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java :107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuild er.java:84)
at  org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuild er.java:59)
at  org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.ja va:183)
at  org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
2011-12-13 16:15:43.009:INFO::Started [email protected]:8080[INFO] 
Started Jetty Server

Web.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>projektni Tapestry 5 Application</display-name>

<context-param>
    <!-- The only significant configuration for Tapestry 5, this informs Tapestry 
        of where to look for pages, components and mixins. -->
    <param-name>tapestry.app-package</param-name>
    <param-value>org.prikic.projektni</param-value>
</context-param>
<!-- Specify some additional Modules for two different execution modes: 
    development and qa. Remember that the default execution mode is production -->
<context-param>
    <param-name>tapestry.development-modules</param-name>
    <param-value>
        org.prikic.projektni.services.DevelopmentModule
    </param-value>
</context-param>
<context-param>
    <param-name>tapestry.qa-modules</param-name>
    <param-value>
        org.prikic.projektni.services.QaModule
    </param-value>
</context-param>


<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>

        <!-- /WEB-INF/application_context_dao.xml -->
        <!--  /WEB-INF/application_context*.xml -->
        classpath:application_context*.xml

    </param-value>
</context-param>

<filter>
    <filter-name>app</filter-name>
    <!-- Special filter that adds in a T5 IoC module derived from the Spring 
        WebApplicationContext. -->
    <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>app</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>


<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 

<!-- <servlet>
    <servlet-name>context</servlet-name>
    <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>  -->

<welcome-file-list>
    <welcome-file>Index</welcome-file>
</welcome-file-list>

If you need anything else of the source code files,tell me and I'll post them

Ideas,anyone?

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

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

发布评论

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

评论(1

岁月如刀 2024-12-28 06:11:29

您应该从 web.xml 中删除 ContextLoaderListener。以下内容来自 Tapestry Spring 集成 页面。

请省略有关创建 ContextLoaderListener 的部分:这现在由 Tapestry 自动完成。

You should remove the ContextLoaderListener from the web.xml. The following is from the Tapestry Spring integration page.

Please omit the part about creating a ContextLoaderListener: this is now done automatically by Tapestry.

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