LOADING STUFF...

java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit(index_jsp.ja

–>

2019独角兽企业重金招聘Python工程师标准>>>

 

环境:Tomcat6 + jdk6

Tomcat服务启动成功,但访问index.jsp出错,Tomcat报错如下:

严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
    at org.apache.jsp.index_jsp._jspInit(index_jsp.java:23)
    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:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    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:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
    at java.lang.Thread.run(Thread.java:619)

 

最后找到原因:jsp-api.jar冲突。

jsp-api.jar冲突会造成jsp页面无法解析。

写自定义标签的时候请注意,在工程编译的时候可以引用jsp-api.jar,但发布的时候工程不要包含此包,因为Tomcat已包含。

 

用于开发,而不用于发布

解决方法1:User Library

选中项目-->右击-->properties-->Java Build Path --> Add Library --> 选中 User Liberary -->

Next --> User Libraries… --> New -->如下一定要选中:口 System Library…. (作为系统库像JDK一样)

--> Add Jars -->导入 与Tomcat冲突jar --> 选中jsp-jar OK

解决方法2:修改配置

打开项目目录,编辑.classpath文件

将:<classpathentry kind=”lib” path=”/…………/jsp-jar”/>

改:<classpathentry kind=”con” path=”/…………/jsp-jar”/>

刷新项目OK

 

结果导入的jar包显示为系统库:

 

 

转载于:https://my.oschina.net/91jason/blog/396983

本文来源 互联网收集,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源,如您发现有涉嫌抄袭侵权的内容,请联系本站核实处理。

© 版权声明

相关文章