org.apache.jsp.index_jsp._jspInit上的java.lang.NullPointerException [英] java.lang.NullPointerException at org.apache.jsp.index_jsp._jspInit

查看:82
本文介绍了org.apache.jsp.index_jsp._jspInit上的java.lang.NullPointerException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行在tomcat内部署的项目时,出现类似

When i try to run project deployed inside tomcat i get error like

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.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:859)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
    at java.lang.Thread.run(Thread.java:619)

我对此进行了搜索,发现这可能是servlet-api.jar和jsp-api.jar的问题,但是我将两者从tomcat复制到了项目的类路径中,但仍然遇到相同的错误.

I have searched regarding that and found that it might be problem of servlet-api.jar and jsp-api.jar but i have copied both from tomcat to my project's classpath still i am getting the same error.

Jsp:

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
     <base href="<%=basePath%>">

    <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    --> 
  </head>

  <body>
    <%--<a href="login.iface">Click Here</a> --%>
  </body>
</html>

classpath包含以下jar列表

classpath contain following list of jar

antlr-2.7.6
commons-beanutils
commons-collections
commons-collections-3.1
commons-digester
commons-logging
commons-logging-1.1
dom4j-1.6.1
ejb3-persistence
hibernate3
hibernate-annotations
hibernate-commons-annotations
icefaces-1.8.2
icefaces-comps-1.8.2
javassist-3.9.0.GA
jsf-api
jsf-facelets
jsf-impl
mysql-connector-java-3.1.8-bin
slf4j-api-1.5.11
slf4j-simple-1.5.11

推荐答案

我对此进行了搜索,发现这可能是servlet-api.jar和jsp-api.jar的问题,但我已将两者从tomcat复制到了我项目的类路径中

您似乎误解了答案.将它们放在您的Web应用程序的运行时类路径(WEB-INF/lib)中 就是造成此问题的全部原因!摆脱它们.

It look like that you misunderstood the answers. Having them in your webapp's runtime classpath (WEB-INF/lib) is the whole cause of this problem! Get rid of them.

servlet容器本身已经已经附带了这些库.从可能具有不同版本/版本的任意容器中提供随机下载的库以及webapp只会导致此类问题.如果这样做是为了修复" webapp项目中的编译错误,则应该以不同的方式解决它.有关如何操作,请参见以下链接:

The servletcontainer itself already ships with those libraries out the box. Providing randomly downloaded libraries from an arbitrary container of a possibly different make/version along with the webapp would only lead to this kind of problems. If you did this in order to "fix" compilation errors in your webapp project, then you should have solved it differently. See the below links for the how:

  • java.lang.NullPointerException at org.apache.jsp.foo_jsp._jspInit(foo_jsp.java:22)
  • How do I import the javax.servlet API in my Eclipse project?

这篇关于org.apache.jsp.index_jsp._jspInit上的java.lang.NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆