Tomcat7 deploy Fail: org.apache.catalina.LifecycleException: Failed to start component / w org.springframework.web.servlet.DispatcherServlet

I have a very simple web.xml example written below:

The problem is ... If I delete the org.springframework.web.servlet.DispatcherServlet section, I can successfully deploy my project to Tomcat7 as a simple JSP servlet application. However, as soon as I use Spring MVC, my deployment will be FAIL - The exception org.apache.catalina.LifecycleException is thrown: Failed to start component [StandardEngine [Catalina] .StandardHost [localhost] .StandardContext [/ WebMVCProj2]]

How can I fix this error?

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

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "id =" WebApp_ID "version =" 3.0 "> Spring Web MVC Application

 <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> 

I am adding a Spring MVC dependency from the Enterprise Bundle repository (EBR). I also use the Eclipse Dynamic Web Module 3.0, which should support Tomcat7. My jre is 1.6.x 64 bit used by Tomcat and my project. I also use the web deployment build in Eclipse.

Here is my complete exception:

SEVERE: error while deploying web application archive E: \ MyServers \ apache-tomcat-7.0.30 \ webapps \ WebMVCProj2.war java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: failed to start component [StandardEngine [Catalina] .StandardHost [localhost] .StandardContext [/ WebMVCProj2]] at org.apache.catalina.core.ContainerBase.addChildInternal (ContainerBase.java:904) at org.apache.catalina.core.ContainerBaseadd ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild (StandardHost.java:618) at org.apache.catalina.startup.HostConfig.deployWAR (HostConfig.java:963) at org.apache.catalina .startup.HostConfig $ DeployWar.run (HostConfig.java:1600) in java.util.concurrent.Executors $ RunnableAdapter.call (Executors.java:441) in java.util.concurrent.FutureTask $ Sync.innerRun (FutureTask.java : 303) in java.util.concurrent.FutureTask.run (FutureTask.ja va: 138) in java.util.concurrent.ThreadPoolExecutor $ Worker.runTask (ThreadPoolExecutor.java:886) in java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:908) in java.lang.Thread.run (Thread.java:662)

+4
source share
1 answer

You must have applicationContext.xml in the web-inf folder or you need to define contextConfigLocation in your web.xml

 <!-- 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> 

It would be more useful if you could post an exception trace.

+2
source

Source: https://habr.com/ru/post/1436741/


All Articles