web-dev-qa-db-fra.com

Statut HTTP 500 - org.Apache.jasper.JasperException: Java.lang.NullPointerException

J'ai déployé mon projet sur le serveur de production et j'ai obtenu l'erreur ci-dessous.

C'est un projet réel, donc, après avoir obtenu une erreur, j'ai remplacé ceci par la version précédente qui fonctionnait bien, mais qui lance maintenant la même erreur. S'il vous plaît, suggérez-moi quel pourrait être le problème?

erreur:

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>
5
Nibha Jain

Dans Tomcat, un fichier .Java et .class sera créé pour chaque fichier jsp figurant dans l’application. Le même fichier est disponible dans le chemin ci-dessous, Apache-Tomcat\work\Catalina\localhost\'ApplicationName'\org\Apache\jsp\index_jsp.Java

Dans votre cas, le nom de jsp est error.jsp. Le chemin doit donc être similaire à celui-ci Apache-Tomcat\work\Catalina\localhost\'ApplicationName'\org\Apache\jsp\error_jsp.Java à la ligne no 124, vous essayez d'accéder à un objet null qui aboutit à une exception pointeur null.

7
Samy

NullPointerException avec JSPpeut également se produire si:

Un getter retourne une classe interne non publique .

Ce code échouera si vous supprimez le modificateur d'accès de Getters ou si vous le rendez privé ou protégé.

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>
0
J.M.I. MADISON