2014-09-27 46 views
0

請幫助解決下面的問題。Spring MVC上的NullPointerException ApplicationMap

我已經完成了一個簡單的Spring MVC JSP應用程序,並且在中間點擊下面的空指針異常,但是當我重新運行應用程序或有時它需要我的管理服務重啓時,這個異常將被清除,請指教。

我只是試圖從jsp提交我的登錄表單並獲取此錯誤。

java.lang.NullPointerException 
at com.sun.faces.context.ApplicationMap.get(ApplicationMap.java:97) 
at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:51) 
at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81) 
at org.springframework.web.jsf.el.SpringBeanFacesELResolver.getWebApplicationContext(SpringBeanFacesELResolver.java:90) 
at org.springframework.web.jsf.el.SpringBeanFacesELResolver.getBeanFactory(SpringBeanFacesELResolver.java:78) 
at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:50) 
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) 
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) 
at com.sun.faces.el.ChainTypeCompositeELResolver.getValue(ChainTypeCompositeELResolver.java:94) 
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188) 
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188) 
at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:103) 
at com.sun.el.parser.AstEmpty.getValue(AstEmpty.java:66) 
at com.sun.el.parser.AstNot.getValue(AstNot.java:63) 
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224) 
at weblogic.servlet.jsp.ELHelper.evaluate(ELHelper.java:32) 
at jsp_servlet._web_45_inf._jsp.__usertodolist._jspService(__usertodolist.java:175) 
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34) 
.......... 

UserToDoList_jsp.java 公共最終類UserToDoList_jsp延伸org.apache.jasper.runtime.HttpJspBase 實現org.apache.jasper.runtime.JspSourceDependent {

 private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory(); 

     private static java.util.List<String> _jspx_dependants; 

     private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_c_forEach_var_items; 
     private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_select_tabindex_path_onchange; 
     private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_c_set_value_target_property_nobody; 
     private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_form_name_modelAttribute_method_action; 
     private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_option_value_label_nobody; 
     private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_c_if_test; 
     private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_option_value_nobody; 

     private org.glassfish.jsp.api.ResourceInjector _jspx_resourceInjector; 

     public java.util.List<String> getDependants() { 
      return _jspx_dependants; 
     } 

     public void _jspInit() { 
      _jspx_tagPool_c_forEach_var_items = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); 
      _jspx_tagPool_form_select_tabindex_path_onchange = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); 
      _jspx_tagPool_c_set_value_target_property_nobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); 
      _jspx_tagPool_form_form_name_modelAttribute_method_action = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); 
      _jspx_tagPool_form_option_value_label_nobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); 
      _jspx_tagPool_c_if_test = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); 
      _jspx_tagPool_form_option_value_nobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig()); 
     } 

     public void _jspDestroy() { 
      _jspx_tagPool_c_forEach_var_items.release(); 
      _jspx_tagPool_form_select_tabindex_path_onchange.release(); 
      _jspx_tagPool_c_set_value_target_property_nobody.release(); 
      _jspx_tagPool_form_form_name_modelAttribute_method_action.release(); 
      _jspx_tagPool_form_option_value_label_nobody.release(); 
      _jspx_tagPool_c_if_test.release(); 
      _jspx_tagPool_form_option_value_nobody.release(); 
     } 

     public void _jspService(HttpServletRequest request, HttpServletResponse response) 
       throws java.io.IOException, ServletException { 

      PageContext pageContext = null; 
      HttpSession session = null; 
      ServletContext application = null; 
      ServletConfig config = null; 
      JspWriter out = null; 
      Object page = this; 
      JspWriter _jspx_out = null; 
      PageContext _jspx_page_context = null; 

      try { 
      response.setContentType("text/html;charset=UTF-8"); 
      pageContext = _jspxFactory.getPageContext(this, request, response, 
         null, true, 8192, true); 
      _jspx_page_context = pageContext; 
      application = pageContext.getServletContext(); 
      config = pageContext.getServletConfig(); 
      session = pageContext.getSession(); 
      out = pageContext.getOut(); 
      _jspx_out = out; 
      _jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector"); 

      out.write("\n"); 
      out.write("\n"); 
      out.write("\n"); 
      out.write("\n"); 
      out.write("\n"); 
      out.write("\n"); 
      out.write("\n"); 
      out.write("\n"); 
      out.write("\n"); 
      out.write("<!DOCTYPE html>\n"); 
      out.write("<html>\n"); 
      out.write(" <head>\n"); 
      out.write("  <title>Home</title>\n"); 
      out.write(" <div class=\"inset\">\n"); 
      out.write("  "); 
      out.print(session.getAttribute("dateTime")); 
      out.write("\n"); 
      out.write("  <h2> TO DO LIST </h2>  \n"); 
      out.write("  "); 
      out.print(session.getAttribute("user")); 
      out.write("\n"); 
      out.write("  <!-- <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>\n"); 
      out.write("  -->\n"); 
      out.write("  <script type=\"text/javascript\">\n"); 
      out.write("\n"); 
      out.write("   function changeFunc($i) {\n"); 
      out.write("    alert($i \"Please select Approve or Reject\");\n"); 
      out.write("   }\n"); 
      out.write("  </script>  \n"); 
      out.write(" </head> \n"); 
      out.write(" <body>\n"); 
      out.write("  <form action=\"logout\" method=\"POST\">\n"); 
      out.write("   <button type=\"submit\">Logout</button> \n"); 
      out.write("  </form>  \n"); 
      out.write("\n"); 
      out.write("  <form name=\"Add\" action=\"Adduser\" method=\"post\">\n"); 
      out.write("   <button type=\"submit\">ADD</button> \n"); 
      out.write("\n"); 
      out.write("  </form>\n"); 
      out.write("  <form name=\"Modify\" action=\"Modifyuser\" method=\"post\">\n"); 
      out.write("   <button type=\"submit\">Modify</button> \n"); 
      out.write("\n"); 
      out.write("  </form>\n"); 
      out.write("  "); 
      // form:form 
      org.springframework.web.servlet.tags.form.FormTag _jspx_th_form_form_0 = (org.springframework.web.servlet.tags.form.FormTag) _jspx_tagPool_form_form_name_modelAttribute_method_action.get(org.springframework.web.servlet.tags.form.FormTag.class); 
      _jspx_th_form_form_0.setPageContext(_jspx_page_context); 
      _jspx_th_form_form_0.setParent(null); 
      _jspx_th_form_form_0.setMethod("POST"); 
      _jspx_th_form_form_0.setName("TransactionAction"); 
      _jspx_th_form_form_0.setModelAttribute("action"); 
      _jspx_th_form_form_0.setAction("transactionAction"); 
      int[] _jspx_push_body_count_form_form_0 = new int[] { 0 }; 
      try { 
       int _jspx_eval_form_form_0 = _jspx_th_form_form_0.doStartTag(); 
       if (_jspx_eval_form_form_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { 
       do { 
        out.write("\n"); 
        out.write("   "); 
        // c:if 
        org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_if_0 = (org.apache.taglibs.standard.tag.rt.core.IfTag) _jspx_tagPool_c_if_test.get(org.apache.taglibs.standard.tag.rt.core.IfTag.class); 
        _jspx_th_c_if_0.setPageContext(_jspx_page_context); 
        _jspx_th_c_if_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_form_form_0); 
        _jspx_th_c_if_0.setTest(((java.lang.Boolean) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${not empty ToDoList}", java.lang.Boolean.class, (PageContext)_jspx_page_context, null)).booleanValue()); 
        int _jspx_eval_c_if_0 = _jspx_th_c_if_0.doStartTag(); 
        if (_jspx_eval_c_if_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { 
        do { 
         out.write("\n"); 
         out.write("\n"); 
         out.write("    <table>\n"); 
         out.write("\n"); 
         out.write("     <tr> <th>ID</th>\n"); 
         out.write("      <th>LOGIN ID</th>\n"); 
         out.write("      <th>MAKER</th>\n"); 
         out.write("      <th>TRANSACTION TYPE</th>\n"); 
         out.write("      <th>STATUS</th>\n"); 
         out.write("     </tr> \n"); 
         out.write("     "); 
         // c:forEach 
         org.apache.taglibs.standard.tag.rt.core.ForEachTag _jspx_th_c_forEach_0 = (org.apache.taglibs.standard.tag.rt.core.ForEachTag) _jspx_tagPool_c_forEach_var_items.get(org.apache.taglibs.standard.tag.rt.core.ForEachTag.class); 
         _jspx_th_c_forEach_0.setPageContext(_jspx_page_context); 
         _jspx_th_c_forEach_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_c_if_0); 
         _jspx_th_c_forEach_0.setVar("item"); 
         _jspx_th_c_forEach_0.setItems((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${ToDoList}", java.lang.Object.class, (PageContext)_jspx_page_context, null)); 
         int[] _jspx_push_body_count_c_forEach_0 = new int[] { 0 }; 
         try { 
         int _jspx_eval_c_forEach_0 = _jspx_th_c_forEach_0.doStartTag(); 
         if (_jspx_eval_c_forEach_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { 
          do { 
          out.write("\n"); 
          out.write("      <tr>\n"); 
          out.write("       <td> <input value=\""); 
          out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[0]}", java.lang.String.class, (PageContext)_jspx_page_context, null)); 
          out.write("\" type=\"number\" name=\"id\" readonly /></td>\n"); 
          out.write("       <td> <input value=\""); 
          out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[1]}", java.lang.String.class, (PageContext)_jspx_page_context, null)); 
          out.write("\" type=\"text\" name=\"loginId\" readonly /></td>\n"); 
          out.write("       <td> <input value=\""); 
          out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[2]}", java.lang.String.class, (PageContext)_jspx_page_context, null)); 
          out.write("\" type=\"text\" name=\"maker\" readonly /></td>\n"); 
          out.write("       <td> <input value=\""); 
          out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[3]}", java.lang.String.class, (PageContext)_jspx_page_context, null)); 
          out.write("\" type=\"text\" name=\"transactionType\" readonly /></td>\n"); 
          out.write("       <td> <input value=\""); 
          out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[4]}", java.lang.String.class, (PageContext)_jspx_page_context, null)); 
          out.write("\" type=\"text\" name=\"status\" readonly /></td>\n"); 
          out.write("       <td>\n"); 
          out.write("        "); 
          // form:select 
... 
} 
+0

你真的不應該比較那樣的字符串。你應該試試''成功'.equals(result)'。 – Makoto 2014-09-27 19:56:12

+0

@Makoto感謝您的建議,我已經做了相應的改變。請在NPE間歇性提示 – Vinoth 2014-09-28 05:32:44

回答

0

此異常以上發生在usertodolist.jsp 。 NPE是由於空密鑰引起的,所以這意味着EL中的某些內容會評估爲null

+0

如果它是空的,那麼錯誤應該是一致的,但對於我的情況它是間歇性的。 – Vinoth 2014-09-27 19:00:35

+0

不一定。環境中的某些東西可能會改變。你可以看看usertodolist併發布EL代碼,甚至可以獲取__usertodolist.java並查看第175行 – mp911de 2014-09-30 09:05:10

+0

已添加UserToDoList_jsp.java,請幫助 – Vinoth 2014-10-04 07:19:34

相關問題