[java] HTTP Status 500 - Servlet.init() for servlet Dispatcher threw exception

When I'm trying to run this simple html form:

   <html>
       <head>
        <title>Enter a new Page</title>
       </head>

       <body>

          <div id="editPresPage">
             <form action="editPresPage.do" method="post"> 
            <label>Enter Page ID</label><input type="text" name="page_id"/>
            <label>Enter Header1</label><input type="text" name="h1"/>
            <label>Enter Header2</label><input type="text" name="h2"/>
            <label>Enter Header3</label><input type="text" name="h3"/>
            <label>Enter Header4</label><input type="text" name="h4"/>            
            <label>Enter Page Text</label><input type="text" name="page_text"/>

            <input type="submit" value="Add New Page"/>
         </form>              
          </div>


       </body>
    </html>

I'm getting the error HTTP Status 500 - Servlet.init() for servlet Dispatcher threw exception in my browser.

In my command line window (which opens when I'm running the tomcat's start.batch file) I'm getting the following error:

log4j:WARN No appenders could be found for logger(org.springframework.web.servlet.dispatcherservlet)

My Dispatcher-servlet.xml file:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">       

        <import resource="/application.xml"/>

        <bean name="/editPresPage.do"
                class="my.pack.webTier.control.EditPresPageController" >
            <property name="page_manager_service" ref="page_manager_service"/>
        </bean> 

       <!--  I also tried using with annotations -->    
        <!-- <context:component-scan base-package="my.pack"/> -->        

</beans>

My web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">

    <servlet>
       <servlet-name>Dispatcher</servlet-name>
       <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
       <servlet-name>Dispatcher</servlet-name>
       <url-pattern>*.do</url-pattern>
</servlet-mapping>

    <!-- Tomcat configuration -->
    <Context path="/myWebApp" docBase="../tomcat\work\Catalina\localhost\mywebapptomcat\work\Catalina\localhost\mywebapp">
    <Loader
    loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
    </Context>

</web-app>

And thats my controller:

package my.pack.webTier.control;

import my.pack.dataAccessTier.domain.Presentation_page;
import my.pack.serviceTier.services.Page_manager_service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

//@Controller
public class EditPresPageController {

    //@Autowired
    private Page_manager_service page_manager_service;

    public void setPage_manager_service(Page_manager_service page_manager_service) {
        this.page_manager_service = page_manager_service;
    }

    @RequestMapping("/editPresPage")
    public ModelAndView EditPresPage(@RequestParam("page_id") int page_id,
                                     @RequestParam("h1") String h1_value,
                                     @RequestParam("h2") String h2_value,
                                     @RequestParam("h3") String h3_value,
                                     @RequestParam("h4") String h4_value,
                                     @RequestParam("page_text") String page_text)

    {
        Presentation_page new_page=new Presentation_page(page_id,h1_value,h2_value,
                h3_value,h4_value,page_text);

        page_manager_service.create_new_page(new_page);


        return new ModelAndView("/thanks.html");

    }


}

The stacktrace exception:

javax.servlet.ServletException: Servlet.init() for servlet Dispatcher threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    java.lang.Thread.run(Thread.java:722)

I'm working with spring MVC 3.2, eclipse 3.7, springTomcat/7.0.30 and using ANT in my project.

I've searched for an answer for this requirements - and didn't found one.

This question is related to java spring eclipse spring-mvc tomcat7

The answer is


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>teste4</groupId>
    <artifactId>teste4</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <repositories>
        <repository>
            <id>prime-repo</id>
            <name>PrimeFaces Maven Repository</name>
            <url>http://repository.primefaces.org</url>
            <layout>default</layout>
        </repository>
    </repositories>



    <dependencies>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.4</version>
        </dependency>


        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.4</version>
        </dependency>



        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>4.0</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces.themes</groupId>
            <artifactId>bootstrap</artifactId>
            <version>1.0.9</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.27</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.2.7.Final</version>
        </dependency>

    </dependencies>


</project>

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to spring

Are all Spring Framework Java Configuration injection examples buggy? Two Page Login with Spring Security 3.2.x Access blocked by CORS policy: Response to preflight request doesn't pass access control check Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified Spring Data JPA findOne() change to Optional how to use this? After Spring Boot 2.0 migration: jdbcUrl is required with driverClassName The type WebMvcConfigurerAdapter is deprecated No converter found capable of converting from type to type

Examples related to eclipse

How do I get the command-line for an Eclipse run configuration? My eclipse won't open, i download the bundle pack it keeps saying error log strange error in my Animation Drawable How to uninstall Eclipse? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Class has been compiled by a more recent version of the Java Environment Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory How to downgrade Java from 9 to 8 on a MACOS. Eclipse is not running with Java 9 "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat

Examples related to spring-mvc

Two Page Login with Spring Security 3.2.x ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean Spring 5.0.3 RequestRejectedException: The request was rejected because the URL was not normalized The type WebMvcConfigurerAdapter is deprecated RestClientException: Could not extract response. no suitable HttpMessageConverter found Spring boot: Unable to start embedded Tomcat servlet container UnsatisfiedDependencyException: Error creating bean with name 8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE Error creating bean with name 'entityManagerFactory' defined in class path resource : Invocation of init method failed Difference between the annotations @GetMapping and @RequestMapping(method = RequestMethod.GET)

Examples related to tomcat7

Could not load the Tomcat server configuration INFO: No Spring WebApplicationInitializer types detected on classpath Name [jdbc/mydb] is not bound in this Context I cannot access tomcat admin console? Tomcat 7.0.43 "INFO: Error parsing HTTP request header" jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class Tomcat Server not starting with in 45 seconds HTTP Status 500 - Servlet.init() for servlet Dispatcher threw exception How to fix JSP compiler warning: one JAR was scanned for TLDs yet contained no TLDs? java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver