问题描述
- 我用springMVC写了一个web项目,加载到tomcat8上后启动出现此异常,请懂得的来帮忙看下
-
异常信息如下:
严重: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/spring_mvc]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1071)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1722)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Unknown Source)
at java.lang.Class.getDeclaredFields(Unknown Source)
at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:258)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:137)
at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:331)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:770)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:302)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5083)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 10 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
... 24 more
十一月 12, 2015 8:46:14 下午 org.apache.catalina.startup.HostConfig deployDirectory
严重: Error deploying web application directory F:BaiduYunDownloadapache-tomcat-8.0.9webappsspring_mvc
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/spring_mvc]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:727)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1071)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1722)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)web.xml 配置文件如下:<?xml version="1.0" encoding="UTF-8"?>
spring_mvc
springmvc
org.springframework.web.servlet.DispatcherServlet
<!-- 加载springmvc的配置文件 -->contextConfigLocation
classpath:springmvc.xml1
springmvc
*.htmindex.html
index.htm
index.jsp
default.html
default.htm
default.jspspring的bean配置文件内容如下
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- 第一种方式 -->
<!-- 根据请求的URL去寻找相应的控制器 -->
解决方案
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
缺jar包了吧 看看WEB-INF/lib下有没有commons logging包
解决方案二:
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
少导包了。apache的commons包
解决方案三:
上一个问题以解决,谢谢两位的指点。但是tomcat启动正常了,访问首页面也成功,可是我从首页面跳转到其他页面怎么会报”404“啊?
网页错误信息如下:
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
Apache Tomcat/8.0.9
页面配置如下:
首页<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
My JSP 'index.jsp' starting page
用户名: | |
密 码: | |
登录成功和失败页面:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
登陆成功页面
登陆成功
${message }
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
登录失败
登录失败
${message }
controller类文件内容:
public class Logincontroller implements Controller{
private Loginservice ls;
public Loginservice getLs() {
return ls;
}
public void setLs(Loginservice ls) {
this.ls = ls;
}
@Override
public ModelAndView handleRequest(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
// TODO Auto-generated method stub
String username=arg0.getParameter("username");
String password=arg0.getParameter("password");
boolean flag=ls.login(username, password);
ModelAndView mv=new ModelAndView();
if(flag){
//往ModelAndView添加共享变量
mv.addObject("message", "恭喜,你赢啦!");
//设置响应的视图名字
mv.setViewName("success");
}else {
mv.addObject("messege", "抱歉,认证失败");
mv.setViewName("fail");
}
return mv;
}
}
public class Accountcontroller implements Controller{
@Override
public ModelAndView handleRequest(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
ModelAndView mav=new ModelAndView();
mav.setViewName("success");
return mav;
}
}
service类文件内容:
public class Loginservice {
public boolean login(String username,String password){
boolean flase=false;
if(username.equals("admin")&&password.equals("admin")){
flase=true;
}
return flase;
}
}
web.xml和spring的xml文件的配置内容和上一个错误发送的相同,请各位帮忙看下啦!