HTTP Status 500 - Servlet.init() for servlet dispatcherServlet threw exception
type Exception report
message Servlet.init() for servlet dispatcherServlet threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet dispatcherServlet threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;
org.springframework.web.servlet.DispatcherServlet.getDefaultStrategies(DispatcherServlet.java:617)
org.springframework.web.servlet.DispatcherServlet.getDefaultStrategy(DispatcherServlet.java:591)
org.springframework.web.servlet.DispatcherServlet.initLocaleResolver(DispatcherServlet.java:397)
org.springframework.web.servlet.DispatcherServlet.initFrameworkServlet(DispatcherServlet.java:352)
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:221)
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:112)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.62 logs.
Apache Tomcat/7.0.62
工程目录:
1.HelloWorld.java
package com.hxzy.action;
public class HelloWorld {
private String msg = null;
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
}
2.HelloWorldAction.java
package com.hxzy.action;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
public class HelloWorldAction extends SimpleFormController {
//
private Logger logger = Logger.getLogger(this.getClass().getName());
private String viewPage;
//重写,覆写
public ModelAndView onSubmit(Object command) throws Exception {
HelloWorld helloWorld = (HelloWorld) command;
System.out.println("helloWorld.getMsg() : " + helloWorld.getMsg());
Map model = new HashMap();
model.put("helloWorld", helloWorld.getMsg());
System.out.println("helloWorld.getMsg() : " + helloWorld.getMsg());
return new ModelAndView(getViewPage(), model);
}
public void setViewPage(String viewPage) {
this.viewPage = viewPage;
}
public String getViewPage() {
return viewPage;
}
}
3.WebContent/WEB-INF/jsp/show.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
MVC instance
<%
String str = (String) request.getAttribute("helloWorld");
%>
4.WebContent/WEB-INF/dispatcherServlet-servlet.xml
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
helloWorldAction
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
org.springframework.web.servlet.view.InternalResourceView
/WEB-INF/jsp/
.jsp
com.hxzy.action.HelloWorld
show
5.WebContent/WEB-INF/web.xml
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
dispatcherServlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/dispatcherServlet-servlet.xml
1
dispatcherServlet
*.do
input.jsp
6.WebContent/input.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
MVC instance
7.log4.properites
log4j.rootLogger=DEBUG,stdout,R
log4j.logger.org=ERROR, A1
log4j.logger.com.gc.action=DEBUG,A2
log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=org.log
log4j.appender.A1.MaxFileSize=500KB
log4j.appender.A1.MaxBackupIndex=50
log4j.appender.A1.Append=true
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} - [%p] [%C{1}] - %m%n
log4j.appender.A2=org.apache.log4j.RollingFileAppender
log4j.appender.A2.File=gc.log
log4j.appender.A2.MaxFileSize=500KB
log4j.appender.A2.MaxBackupIndex=50
log4j.appender.A2.Append=true
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d{ISO8601} - [%p] [%C{1}] - %m%n
#--------------------stdout--------------------------------
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss} %c - %m%n
#--------------------R--------------------------------
#log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
#this log file will be stored in web server's /bin directory,modify to your path which want to store.
log4j.appender.R.File=gf.log
#log4j.appender.R.datePattern='.'yyyy-MM-dd-HH-mm
log4j.appender.R.datePattern='.'yyyy-MM-dd
log4j.appender.R.append=true
## Keep one backup file
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss} %c - %m%n
#[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
8.jar包如下:
cglib-nodep-2.1_3.jar
commons-logging-1.1.1.jar
commons-logging.jar
jakarta-oro-2.0.8.jar
jstl.jar
log4j-1.2.9.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE.jar
spring-expression-4.0.0.RELEASE.jar
spring.jar
standard.jar
经过多方查找,stackOverFlow csdn等论坛,猜测是jar包添加冲突问题,逐个删除jar包,发现无效。最后全部删除。换上
commons-logging.jar
jstl.jar
log4j-1.2.9.jar
spring.jar
standard.jar
问题解决