jsp报错
JasperExceptionClassNotFoundException
最近在部署一个J2EE工程时,报如下异常:
Java代码
org.apache.jasper.JasperException:java.lang.ClassNotFoundException
详细情况如下:
Java代码
(1)org.apache.jasper.JasperException:Theabsoluteuri:http://java.sun.com/jsp/jstl/corecannotberesolvedineitherweb.xmlorthejarfilesdeployedwiththisapplication
(2)九月06,201210:30:42上午org.apache.catalina.core.ApplicationDispatcherinvoke
严重:Servlet.service()forservletjspthrewexception
(3)九月06,201210:30:42上午org.apache.catalina.core.StandardWrapperValveinvoke
严重:Servlet.service()forservlet[default]incontextwithpath[/JetsenPublishNewsServer]threwexception[org.apache.jasper.JasperException:java.lang.ClassNotFoundException:org.apache.jsp.web.main_jsp]withrootcause
项目用的是SSH框架,同样是在SVN上下载的,别人的没问题,在花了半个下午没解决后,后来想想,可能是以下几个原因
(1)配置文件出问题
(2)部分jar包没导进去
(3)tomcat版本问题
在排除了前两个问题之后,今天把tomcat的版本由7.0改成6.0问题居然解决了,可能是7.0的版本有些功能向下不兼容的缘故。
关于org.apache.jasper.JasperException:Theabsoluteuri:http://java.sun.com/jsp/j
SUNJSPJavaJ#Apache
此问题一般是因为jar(jstl.jar,和standard.jar)导致的问题:
第一种:
就是在Eclipse的工程中导入JSTL.jar和standard.jar
第二种:
修改web.xml,加上下面的语句:
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/xml</taglib-uri>
<taglib-location>/WEB-INF/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/sql.tld</taglib-location>
</taglib>
</jsp-config>
org.apache.jasper.JasperException:Theabsoluteuri:http://java.sun.com/jsp/jstl/corecannotberes
org.apache.jasper.JasperException:Theabsoluteuri:http://java.sun.com/jsp/jstl/corecannotberesolvedineitherweb.xmlorthejarfilesdeployedwiththisapplication
atorg.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
atorg.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
atorg.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
atorg.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:316)
atorg.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:149)
atorg.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:386)
atorg.apache.jasper.compiler.Parser.parseDirective(Parser.java:450)
atorg.apache.jasper.compiler.Parser.parseElements(Parser.java:1397)
atorg.apache.jasper.compiler.Parser.parse(Parser.java:130)
atorg.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
atorg.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
atorg.apache.jasper.compiler.Compiler.generateJava(Compiler.java:185)
atorg.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
atorg.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
atorg.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
atorg.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
atorg.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
atorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
atjavax.servlet.http.HttpServlet.service(HttpServlet.java:717)
atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
atjava.lang.Thread.run(Thread.java:595)
解决:web项目出现如上问题,据查是版本问题:
JSTL1.0的声明是:
<%@taglibprefix="c"uri="http://java.sun.com/jstl/core"%>
JSTL1.1的声明是:
<%@taglibprefix="c"uri=http://java.sun.com/jsp/jstl/core%>
项目中,已经是jstl1.2版本了,页面中也全部是用<%@taglibprefix="c"uri=http://java.sun.com/jsp/jstl/core%>这种方式。javaee5之后就只有jstl.jar这一个jar包了,没有standard.jar包,tld文件也打包到jar里面去了,在web.xml文件里配置jsp-config的解决方式也是浮云。
最终解决方法:
jstl.jar包在ide项目中有,但在tomcat发布的应用WEB-INF/lib下没有,这是工具发布项目的问题,复制一个jar包过去问题就解决了。