java - HTTP Status 500 - Servlet.init() for servlet Dispatcher threw exception -
when i'm trying run simple html form:
<html> <head> <title>enter 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 error http status 500 - servlet.init() servlet dispatcher threw exception in browser.
in command line window (which opens when i'm running tomcat's start.batch file) i'm getting next error:
log4j:warn no appenders found logger(org.springframework.web.servlet.dispatcherservlet)
that 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> <!-- tried using annotations --> <!-- <context:component-scan base-package="my.pack"/> --> </beans>
that's 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 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); homecoming new modelandview("/thanks.html"); } }
thats stacktrace:
exception
javax.servlet.servletexception: servlet.init() 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 spring mvc 3.2, eclipse 3.7, springtomcat/7.0.30 , using ant in project.
i've searched reply requirements - , didn't found one.
you map dispatcher on *.do:
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>
but controller mapped on url without .do:
@requestmapping("/editprespage")
try changing to:
@requestmapping("/editprespage.do")
java eclipse spring-mvc tomcat7
No comments:
Post a Comment