1
votes

while starting tomcat with maven, getting following error

java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/web_store]] at java.util.concurrent.FutureTask.report(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source)

Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/web_store]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153) ... 6 more

Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name dispatcherServlet-servlet at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3180) at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3159) at org.apache.catalina.startup.ContextConfig.configureContext(ContextConfig.java:1376)

Aug 10, 2016 2:28:01 PM org.apache.catalina.core.ContainerBase startInternal SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]] at java.util.concurrent.FutureTask.report(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source)

I am using maven and getting erroron this project strcture while starting tomcat is running normally but when I run project with tomcat it shows following error

Edit

1 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">
    <display-name>webstore</display-name>
    <welcome-file-list>
        <welcome-file>view/index.html</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcherServlet-servlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app> 

2 dispatcherServlet-servlet.xml

<mvc:annotation-driven />
    <context:component-scan base-package="web_store.*" />
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/view/" />
        <property name="suffix" value=".jsp" />
    </bean>
1
and dispatcherServlet-servlet.xmlNicolas Filotto
@NicolasFilotto , please check I added filesuser6601906
<servlet-name> has to be same in both <servlet> and <servlet-mapping>akgaur

1 Answers

1
votes

Your mistake is here:

<servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcherServlet-servlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

In your servlet mapping, you need to refer to a servlet that has been defined in your web.xml and here only dispatcherServlet has been defined so simply rename dispatcherServlet-servlet into dispatcherServlet in your servlet mapping as next:

<servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>