1. ホーム
  2. java

[解決済み] HTTPステータス 500 - org.apache.jasper.JasperException: java.lang.NullPointerException

2022-02-03 13:07:22

質問

本番サーバーにプロジェクトをデプロイしたところ、以下のエラーが発生しました。

それはライブプロジェクトなので、エラーが発生した後、私はこれを以前のバージョンに置き換え、正常に実行されていたが、今はそれも同じエラーを投げている。何が問題なのか私に示唆してください?

というエラーが発生します。

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:[email protected]?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="[email protected]?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>

解決方法は?

Tomcatでは、アプリケーション内の各jspファイルに対して.javaと.classファイルが作成され、同じものが以下のパスにあります。 Apache-Tomcat\work\Catalina\localhost\'ApplicationName'\org\apache\jsp\index_jsp.java

あなたの場合、jsp名はerror.jspなので、パスは以下のようになるはずです。 Apache-Tomcat\work\Catalina\localhost\'ApplicationName'\org\apache\jsp\error_jsp.java 124行目では、NULLオブジェクトにアクセスしようとしているため、NULLポインタ例外が発生します。