org.apache.jsp.mouseproduct_jsp._jspService上的java.lang.NullPointerException(mouseproduct_jsp.java:145)

时间:2015-04-25 21:02:14

标签: java nullpointerexception tomcat8 intellij-14

使用IntelliJ Idea14在tomcat8上运行我的应用程序时出现以下异常。

   25-Apr-2015 16:30:49.221 SEVERE [http-nio-8443-exec-133]    org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [jsp] in context with path [] threw exception [An exception occurred processing JSP page /mouseproduct.jsp at line 35
  <%
            String ppic = oc.getPpicture();
           ppic = UT.findProductPicture(ppic, oc.getPcolor());
           int [] wh = SwUtil.getPicWHByMin(application.getRealPath("images").replaceFirst("newportal_admin","newportal")+"\\"+ppic);
              %>
           <img src="<%="../images/"+ppic%>" width="<%=wh[0]%>" height="<%=wh[1]%>" border="0">
 </td>


Stacktrace:] with root cause
 java.lang.NullPointerException
    at org.apache.jsp.mouseproduct_jsp._jspService(mouseproduct_jsp.java:145)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:431)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:299)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1517)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1474)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

2 个答案:

答案 0 :(得分:0)

  • 您的代码中没有第145行NullPointerException
  • 我认为application.getRealPath("images")为空。
  • 准确地说,您可以找到此JSP的转换后的servlet代码,请参阅确切的行号。
  • 从上面的代码中可以找到超过一个的地方,可以通过NPE。

答案 1 :(得分:0)

我通过添加jsp-2.3.1 jar,servlet3.1 jar解决了这个问题。由于Tomcat 8实现了servlet3.1,jsp2.3,我需要升级旧的jar文件。