1.启动tomcat时候抛错
严重: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22) at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52) at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:159) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
原因是:jsp-api.jar加载失败。一般 jsp-api.jar 是不需要自己引入到Eclipse中的,Eclipse会自动引入该文件(tomcat的lib下都会有这个jar文件),如果再自己引入的话就会产生冲突,出现上面的错误。
2.启动tomcat时抛错Error filterStart如下:
2012-9-24 11:26:13 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2012-9-24 11:26:13 org.apache.catalina.core.StandardContext start 严重: Context [/] startup failed due to previous errors 2012-9-24 11:26:13 org.apache.coyote.http11.Http11Protocol start
遇到这种问题的解决方法:
a.web.xml配置是否有问题.
b.把Catalina 底下的所有历史信息去掉
c.查看TOMCAT底下的apache-tomcat-6.0.14\logs\localhost.2012-09-24.log日志文件,根据日志找原因是首选.
最后到apache-tomcat-6.0.14\logs\localhost.2012-09-24.log中发现,原来是在Web.xml的中的filter-class类没有添加jar包!
3.tomcat启动了,但是访问是404,访问tomcat的欢迎页面是可以,可以通过管理页面看到tomcat是否加载了应用,这个时候需要输入用户名和密码,查看apache-tomcat-6.0.14\conf\tomcat-users.xml一个用户都没有,需要添加用户,在配置文件中添加如下:
<role rolename="manager"/> <role rolename="admin"/> <user username="admin" password="123456" roles="admin,manager"/>
然后看到应用并没有被tomcat加载
4.应用没有被tomcat加载,需要在apache-tomcat-6.0.14\conf\server.xml 中加载蓝色背景部分
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/" docBase="D:/workspace/0919/spider/spider/WebContent" debug="0" reloadable="true"/> <!-- SingleSignOn valve, share authentication between web applications Documentation /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> --> </Host>