用MyEclipse做了一个app,在其自带的Tomcat里运行正常,做成war后却出现如下错误:
[ServletException in:/page/jsp/template/block.jsp] org.apache.jsp.page.jsp.template.block_jsp' java.lang.ClassNotFoundException: org.apache.jsp.page.jsp.template.block_jsp at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:143) at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:172) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544) at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954) at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:652) at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:138) at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:152) at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:138) at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:756) at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:881) at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:473) at org.apache.jsp.page.jsp.user.login.index_jsp._jspx_meth_tiles_005finsert_005f0(index_jsp.java:132) at org.apache.jsp.page.jsp.user.login.index_jsp._jspService(index_jsp.java:77) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
以上错误密密麻麻的,让人心惊,仔细一看吧,还看不出头绪。心一急就有点乱投医的意思了,发帖,网上搜,没找到对症的。
后来想想,是不是用了STURTS的TILES的问题,找了个基本是固定信息的近静态页面,问题还是差不多。
觉得奇怪,打开一看,静态页面里除了一句<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>就没有其它非HTML代码了,难道这句话在作怪。
于是,用VI删掉这句话,再输入静态网页URL,正常显示了!!
再找了/page/jsp/template/block.jsp,也删掉这句话,它也正常了。这证明STURTS的TILES没有问题。
本地一查,大约四分之一的页面都有<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>这句话,但实际上我是没有用JSTL的,页面除了HTML就是JS。于是全删掉。
再运行,所有页面都正常了。这证明MyEclipse的导出war包也是可以信赖的。
究其原因,这四分之一的页面估计都是一个母本,这个母本又是用MyEclipse生成的,生成时就带了<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>这句话。首页又在这四分之一里面,出的错又没点中要害,所以一开始让人丈二和尚摸不着头脑。后来从静态页面测试起是走在正道上了,在浏览器的地址栏输入jsp地址,先从最简页面开始,逐渐测试复杂的页面,最后查清确认了真相。
<完>