HTTP状态500 - org.apache.jasper.JasperException:java.lang.NullPointerException

时间:2013-10-09 06:41:23

标签: java jsp nullpointerexception tomcat6

我在生产服务器上部署了我的项目,并收到以下错误。

这是一个真实的项目,所以,在收到错误后,我用之前运行正常的版本替换了它,但现在这也是同样的错误。请告诉我可能是什么问题?

错误:

HTTP Status 500 - org.apache.jasper.JasperException: java.lang.NullPointerException

--------------------------------------------------------------------------------

type Exception report

message org.apache.jasper.JasperException: java.lang.NullPointerException

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

exception 

org.apache.jasper.JasperException: org.apache.jasper.JasperException: java.lang.NullPointerException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
    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)


root cause 

org.apache.jasper.JasperException: java.lang.NullPointerException
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
    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)
    org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:709)
    org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:680)
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
    org.apache.jsp.LPSSuppIndex_jsp._jspService(LPSSuppIndex_jsp.java:393)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    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)


root cause 

java.lang.NullPointerException
    org.apache.jsp.error_jsp._jspService(error_jsp.java:124)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    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)
    org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:709)
    org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:680)
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
    org.apache.jsp.LPSSuppIndex_jsp._jspService(LPSSuppIndex_jsp.java:393)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    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)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.36 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.36

IndexPage.jsp:

<%@ page errorPage="error.jsp"%>
<%@ page import="java.util.*" %>
<%@ page import = "jdbc.RetrieveLangList,lang.MessageGetter" %>
<%!
    HashMap<String, String> langListMap = new HashMap<String, String>();
%>
<%
        //Retrieving language MAP
        RetrieveLangList objList = new RetrieveLangList();
        langListMap = objList.LangList();
        Set s = langListMap.entrySet(); // Get hashmap in Set interface to get key and value
        Iterator it = s.iterator(); // Move next key and value of HashMap by iterator

        String suppLang = "en_US";
        suppLang = request.getParameter("suppLanguage");
        if (suppLang == null || suppLang.equalsIgnoreCase(""))
            suppLang = "en_US";
%>
<html>
<HEAD>
<TITLE> Welcome to  </TITLE>
<link rel="SHORTCUT ICON" href="image/H.ico"/>
<LINK href="image/css/Rcontent.css" type="text/css" rel="stylesheet">
</HEAD>
<script language="JavaScript">
function loadPage(list)
{
  location.href=list.options[list.selectedIndex].value;
}
</script>
<SCRIPT language="Javascript">
    function ValidateForm()
    {
    //Supplier Number Validation
    var supp_number =document.loginForm.uname;

    if((supp_number.value=="su")||(supp_number.value=="SU"))
        {
            return true;
        }

    var stripped = supp_number.value.replace(/[\(\)\.\-\ ]/g, ''); 
    if((supp_number.value==null)||(supp_number.value==""))
        {
        alert("<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "Enter_User_ID")%>");
        supp_number.focus();
        return false;
        }
    else if (isNaN(parseInt(stripped))) {
        alert("<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "Invalid_User_ID")%>");
        supp_number.focus();
        return false;
         }

        //Password Validation
        var supp_pass =document.loginForm.pass;
    if((supp_pass.value==null)||(supp_pass.value==""))
        {
        alert("<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "Enter_Password")%>");
        //alert("Please Enter Password");
        supp_pass.focus();
        return false;
        }
    return true;
    }
</SCRIPT>
<BODY bgcolor="#C7CACF">
<center>
<table border = "0" bordercolor = "black" style="background-image:url('image/backgroundIndex.jpg');background-repeat:no-repeat" width="1000" HEIGHT = "700" >
<tr height = "60">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="2">
    <form name="form1" >
    <TABLE border="0" width = "610">
    <TR>
       <td width="300" align="right" height="40">
            <select name="file" size="1" onchange="loadPage(this.form.elements[0])" target="_parent._top"  onmouseclick="this.focus()" style="background-color: #ffffff;width:150px;"> <!-- This is language selection box -->
            <%
            while (it.hasNext())
            {
                Map.Entry m = (Map.Entry) it.next(); // key=value separator this by Map.Entry to get key and value
                //System.out.println("value : "+m.getValue()+" key : "+m.getKey());
                if(suppLang.equals(m.getKey()))
                {
            %>
            <option value="LPSSuppIndex.jsp?suppLanguage=<%= m.getKey()%>" selected="selected"><%= m.getValue()%></option>
            <%
                }
                else
                {
            %>
            <option value="LPSSuppIndex.jsp?suppLanguage=<%= m.getKey()%>"><%= m.getValue()%></option>
            <%
                }
            }
            %>
            </select>
         </td>
         <td width = "300px" align="right"><a HREF="mailto:?subject=<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "sub_contact")%>&body=<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line1_contact")%>, %0D%0D%0D<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line2_contact")%>, %0D%0D%0D<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line3_contact")%>%0D%0D%0D"><font color="#73767B" size="2"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "contact")%></font></a><font color="#73767B"><B> |</B></font><a href="http://www..com/en/service/imprint-legal-issues.html"><font color="#73767B" size="2"> <%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "imprint_legel_issue")%></font></a><font color="#73767B"><B> | </B></font><a href="http://www..com/en/service/sitemap.html"><font color="#73767B" size="2"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "sitemap")%></font></a></td>
    </TR>
    <TR height="12px">
        <TD colspan="2">&nbsp;</TD>
    </TR>
    </TABLE>
    </form>
    </td>
</tr>

<tr>
     <td height = "240px" valign="top">
        <TABLE border="0" width = "195">
        <TR>
            <TD height="40" width="155" align="left"><div style="position:relative;left: 20px;"><a href="LPSSuppIndex.jsp"><font color="#73767B" size="3"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "home")%></font></a></div></TD>
        </TR>
        <TR>
            <TD height="37" align="left"><div style="position:relative;left: 20px;"><A HREF="mailto:er_Admin@de..com?subject=<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "sub_contact")%>&body=<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line1_contact")%>, %0D%0D%0D<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line2_contact")%>, %0D%0D%0D<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line3_contact")%>%0D%0D%0D"><font color="#73767B"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "contact")%></font></a></div></TD>
        </TR>
        <TR>
            <TD height="35" align="left"><div style="position:relative;left: 20px;"><a href="LPSSuppIndex.jsp"><font color="#73767B" size="3"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "log_in")%></font></a></div></TD>
        </TR>
        <TR>
            <TD height="34" align="left">&nbsp;&nbsp;&nbsp;<a href="http://wwwcom"><font color="white" style="font-family:Arial, Helvetica, sans-serif;font-size: 10pt; font-weight: bold"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "tportal")%></font></a></TD>
        </TR>
        <TR>
            <TD height = "32" align="center">&nbsp;</TD>
        </TR>
        <TR>
            <TD height = "43px" colspan="2" align="center">&nbsp;</TD>
        </TR>

        </TABLE>
    </td>

    <td colspan="2">&nbsp;</td>
    <td rowspan="3" valign="top">
        <table border="0px" >
            <tr height="139px"><td>&nbsp;</td><td>&nbsp;</td></tr>
            <tr height="431px">
                <td valign="top" width="8px"><div class="vertical-line" style="position:relative;left:27px;top:0px;"></div></td>
                <td valign="top">
                    <!-- START RIGHT CONTENT  -->

                    <DIV class="cntr_cnt_gradbox" style="position: relative;left: 15px;top: -5px;">
                    <DIV class="cntr_head"><font size="2%"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "PDF_download")%>&nbsp;</font></DIV>
                    <DIV class="cntr_cnt_gradbox_inner">
                        <DIV class="cntr_frame" style="height: 60px;">
                            <DIV style="FLOAT: left;height: 50px;" >
                                <IMG src="image/PDF_Thumbnail_50x50.gif" border="0">
                            </DIV>
                            <DIV class="cntr_dl_cnt" style="MARGIN-LEFT: 55px;">
                                <A class="cntr_lnk" href="PDF/User Maner_EN.pdf" target="_blank"><font color="#73767B" size="2%"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "manual_en")%></font></A>
                            </DIV>&nbsp;
                            <BR class="clr">
                        </DIV>
                        <BR class="clr">
                        <DIV class="cntr_frame" style="height: 60px;">
                            <DIV style="FLOAT: left;height: 50px;" >
                                <IMG src="image/PDF_Thumbnail_50x50.gif" border="0">
                            </DIV>
                            <DIV class="cntr_dl_cnt" style="MARGIN-LEFT: 55px;">
                                <A class="cntr_lnk" href="PDF/Benutzerhl Printer_DE.pdf" target="_blank"><font color="#73767B" size="2%"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "manual_de")%></font></A>
                            </DIV>&nbsp;
                            <BR class="clr">
                        </DIV>
                        <BR class="clr">
                        <DIV class="cntr_frame" style="height: 60px;">
                            <DIV style="FLOAT: left;height: 50px;" >
                                <IMG src="image/PDF_Thumbnail_50x50.gif" border="0">
                            </DIV>
                            <DIV class="cntr_dl_cnt" style="MARGIN-LEFT: 55px;">
                                <A class="cntr_lnk" href="PDF/Print_Specification.pdf" target="_blank" title="<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "printHelp_tip")%>"><font color="#73767B" size="2%"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "printHelp")%></font></A>
                            </DIV>
                            <BR class="clr">
                        </DIV>
                        <DIV class="cntr_frame1" style="height: 30px;">
                             <div style="margin-left: 30px;"> <A class="cntr_lnk" href="PDF/quick_guide_en.pdf" target="_blank"><font color="#73767B" size="2%"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "one_point_lessons")%> - EN</font></A></div>
                        </DIV>

                        <DIV class="cntr_frame1" style="height: 30px;">
                             <div style="margin-left: 30px;"> <A class="cntr_lnk" href="PDF/quick_guide_de.pdf" target="_blank"><font color="#73767B" size="2%"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "one_point_lessons")%> - DE</font></A></div>
                        </DIV>
                        <DIV style="height: 30px;vertical-align: middle;">
                             <div style="margin-left: 30px;"> <A class="cntr_lnk" href="PDF/FAQ.pdf" target="_blank"><font color="#73767B" size="2%">FAQ</font></A></div>
                        </DIV>
                        </DIV>
                    </DIV>
                </td>
            </tr>
        </table>
    </td>
</tr>

<tr height = "210">
    <td>&nbsp;</td>
     <td>&nbsp;</td>
     <td>
     <form method="post" name="loginForm" action="./loginServlet" onsubmit="return ValidateForm()">
     <input type="hidden" name="selectedLang" value="<%=suppLang%>" >
     <TABLE border="0" bordercolor="black" width="370">
     <tr><td rowspan="6" width = "30">&nbsp;</td></tr>

     <TR height="45">
        <td width="110" ><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "user_id")%> : </td><!-- This is Supplier Number(User ID) entry field. -->
     <td width="230" align="center"><input type="text" size="25" name="uname" style="border-color: #529DFA;" maxlength="10"></td>
     </TR>
     <TR>
     <td height="45"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "Password")%> : </td><!-- This is Password entry field. -->
      <td align="center"><input type="password" size="25" name="pass" style="border-color: #529DFA;"></td>
     </TR>
     <TR height="40">
     <td>&nbsp;</td>
     <td align ="center" height="40"><A HREF="mailto_Printer_Admin@de.h.com?subject=<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "sub_forget_password")%>&body=<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line1_forget_password")%>, %0D%0D%0D<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "body_line2_forget_password")%>%0D%0D%0D"><%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "forget_password")%></A>
    </td>
     </TR>
     <TR>   
     <td height="40" align="right"><input type="Submit" value="<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "log_in")%>" /> </td>
     <td align="center"><input type="button" onClick="location.href='register/suppRegistration.jsp?selectedLang=<%=suppLang%>'" value="<%=MessageGetter.getMessage("lang.MessagesBundle", suppLang, "new_user")%>" /></td>
     </TR>
     </TABLE></form>
     </td>
</tr>

<tr height = "114">
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
</tr>

<tr>
    <td width = "200">&nbsp;</td>
    <td width="170">&nbsp;</td>
    <td width="380">&nbsp;</td>
    <td width="230" align="center">&nbsp;</td>
</tr>
</table>
</center>
</BODY>
</HTML>

2 个答案:

答案 0 :(得分:8)

在Tomcat中,将为应用程序中的每个jsp文件创建一个.java和.class文件,并且可以从下面的路径中找到相同的文件。 Apache-Tomcat\work\Catalina\localhost\'ApplicationName'\org\apache\jsp\index_jsp.java

在你的情况下,jsp名称是error.jsp,所以路径应该如下所示 在第124行中Apache-Tomcat\work\Catalina\localhost\'ApplicationName'\org\apache\jsp\error_jsp.java,您试图访问一个空对象,导致空指针异常。

答案 1 :(得分:0)

如果出现 ,则也会发生JSP

NullPointerException:

吸气剂返回非公开内部类

如果您删除 Getters 的访问修饰符或将其设为私有或受保护,则此代码将失败。

JAVA:

package com.myPackage;
public class MyClass{ 
    //: Must be public or you will get:
    //: org.apache.jasper.JasperException: 
    //: java.lang.NullPointerException
    public class Getters{
        public String 
        myProperty(){ return(my_property); }
    };;

    //: JSP EL can only access functions:
    private Getters _get;
    public  Getters  get(){ return _get; }

    private String 
    my_property;

    public MyClass(String my_property){
        super();
        this.my_property    = my_property;
        _get = new Getters();
    };;
};;

JSP

<%@ taglib uri   ="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page import="com.myPackage.MyClass" %>
<%
    MyClass inst = new MyClass("[PROP_VALUE]");
    pageContext.setAttribute("my_inst", inst ); 
%><html lang="en"><body>
    ${ my_inst.get().myProperty() }
</body></html>