Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc Tomcat7部署失败:org.apache.catalina.LifecycleException:无法启动组件/w org.springframework.web.servlet.DispatcherServlet_Spring Mvc_Maven 3_Tomcat7_Web.xml_Eclipse Juno - Fatal编程技术网

Spring mvc Tomcat7部署失败:org.apache.catalina.LifecycleException:无法启动组件/w org.springframework.web.servlet.DispatcherServlet

Spring mvc Tomcat7部署失败:org.apache.catalina.LifecycleException:无法启动组件/w org.springframework.web.servlet.DispatcherServlet,spring-mvc,maven-3,tomcat7,web.xml,eclipse-juno,Spring Mvc,Maven 3,Tomcat7,Web.xml,Eclipse Juno,下面是一个非常简单的web.xml示例: 问题是…如果我删除org.springframework.web.servlet.DispatcherServlet部分,我就可以成功地在Tomcat7中将我的项目部署为一个简单的JSP servlet应用程序。但是,一旦使用Spring MVC,我的部署将失败-遇到异常org.apache.catalina.LifecycleException:无法启动组件[StandardEngine[catalina].StandardHost[localhost

下面是一个非常简单的web.xml示例:

问题是…如果我删除org.springframework.web.servlet.DispatcherServlet部分,我就可以成功地在Tomcat7中将我的项目部署为一个简单的JSP servlet应用程序。但是,一旦使用Spring MVC,我的部署将失败-遇到异常org.apache.catalina.LifecycleException:无法启动组件[StandardEngine[catalina].StandardHost[localhost].StandardContext[/WebMVCProj2]]

如何修复此错误

    <?xml version="1.0" encoding="UTF-8"?>

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id=“WebApp\u id”version=“3.0”> SpringWebMVC应用程序

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>

<servlet>
    <servlet-name>Hello</servlet-name>
    <servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Hello</servlet-name>
    <url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>

<!-- I can remove the part below to make deployment successful -->
<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
你好
你好世界
你好
/HelloServlet
春天
org.springframework.web.servlet.DispatcherServlet
1.
春天
*.html

我从企业包存储库(EBR)中添加了Spring MVC依赖项。我还使用了Eclipse Dynamic Web Module 3.0,Tomcat7应该支持它。我的jre是Tomcat和我的项目使用的1.6.x 64位。我还在Eclipse中使用Web部署程序集

以下是我的完全例外:

严重:部署web应用程序存档时出错E:\MyServers\apache-tomcat-7.0.30\webapps\WebMVCProj2.war java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:未能启动组件[StandardEngine[catalina].StandardHost[localhost].StandardContext[/WebMVCProj2]] 位于org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904) 位于org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) 位于org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618) 位于org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963) 位于org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600) 位于java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) 位于java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 位于java.util.concurrent.FutureTask.run(FutureTask.java:138) 位于java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
在java.lang.Thread.run(Thread.java:662)

中,您应该在web inf文件夹中有applicationContext.xml,或者必须在web.xml中定义contextConfigLocation

<!-- Spring Context -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/application-contexts/*.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

上下文配置位置
类路径:/application contexts/*.xml
org.springframework.web.context.ContextLoaderListener

如果您可以发布异常跟踪,这将更有帮助。

您可以检查您的servlet类是否有任何类似@WebServlet(“。我通过删除servlet类中的注释解决了类似的问题。

我希望我可以发布图像来描述我的项目和war结构…以使我的问题更清楚。你创建了spring-servlet.xml文件吗?谢谢你,我在上面发布了我的异常。我有WEB-INF\spring-servlet.xml作为spring应用程序上下文。自spring…在我的Web.xml中,所以我想Spring会在Web-INF文件夹下找到我的应用程序上下文,默认名称为Spring-servlet.xml。好的。请告诉我“原因:错误stacktraceIt的一节自从我最终发现Spring在我的pom文件中需要一个外部依赖项以来一直存在。
commons logging commons logging 1.1.1
添加此依赖项后,我的web应用可以在Tomcat中成功部署和运行。再次感谢您的帮助。:)