首页 > 代码库 > The server encountered an internal error () that prevented it from fulfilling this request.

The server encountered an internal error () that prevented it from fulfilling this request.

这是我今天遇到的一个最棘手的问题,耗费了一下午的时间终于解决了。

不知道为什么,今天做这个web项目时突然遇到下面这样一个错误:

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:536)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:368)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    cn.jilin.eletric.filter.EncodingFilter.doFilter(EncodingFilter.java:28)
    cn.jilin.eletric.filter.LoginFilter.doFilter(LoginFilter.java:39)
root cause
java.lang.NullPointerException
    org.apache.jsp.admin.login_jsp._jspInit(login_jsp.java:22)
    org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:338)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    cn.jilin.eletric.filter.EncodingFilter.doFilter(EncodingFilter.java:28)
    cn.jilin.eletric.filter.LoginFilter.doFilter(LoginFilter.java:39)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.

我百度了很长时间,也没发现解决这类问题的具体方法。其实这个问题不难解决:就是  jar文件  的问题,但是要具体问题具体分析。

具体是什么问题要看root cause部分,比如我这里显示的错误如下:

root cause
java.lang.NullPointerException
    org.apache.jsp.admin.login_jsp._jspInit(login_jsp.java:22)
    org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:52)
    org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:164)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:338)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    cn.jilin.eletric.filter.EncodingFilter.doFilter(EncodingFilter.java:28)
    cn.jilin.eletric.filter.LoginFilter.doFilter(LoginFilter.java:39)

说明我的项目里缺少jsp-api.jar文件我只需要在项目中加上这个文件即可。而有的项目显示数据库连接问题,一般是缺少数据库连接驱动,同样,加上相应的jar文件即可。

注意:只是将jar文件放在web-infor下的lib包下是不够的。jar文件的添加方式是:在项目上右键->Build Path->Configer Build Path->Libraries 添加相应的jar文件即可。