HTTP Status 500 - An exception occurred processing JSP page /index.jsp at line 20

来源:8-6 所有商品信息显示

隔壁王爷爷

2015-04-15 17:24

HTTP Status 500 - An exception occurred processing JSP page /index.jsp at line 20
type Exception report
message An exception occurred processing JSP page /index.jsp at line 20
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 20

17:     <%
18:       ItemsDao itemsDao = new ItemsDao();
19:       ArrayList<Items> list = itemsDao.getAllItems();
20:       for (int i = 0; i < list.size(); i++) {
21:     %>
22:     <center>
23:       <table width="750" height="60" cellpadding="0" cellspacing="0" border="0">


Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
	org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:395)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause
java.lang.NullPointerException
	org.apache.jsp.index_jsp._jspService(index_jsp.java:80)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
	org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:395)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

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


写回答 关注

6回答

  • demo_h
    2015-04-15 23:07:15
    已采纳

    同学你问题表述的不是很清楚 麻烦你说清楚点 不能只把异常显示出来 要把源代码一起贴出来 别人才好可以给你解答 

    xiulan... 回复隔壁王爷爷

    这个问题是如何解决的呢? 我也遇到 空指针问题,报错跟你一样

    2016-06-03 10:15:25

    共 3 条回复 >

  • weixin_慕虎6515297
    2019-02-28 13:57:16

    我这边有个问题,点击任意一个产品后,出现如下错过是什么回事

    求各位大神帮忙指点。

    https://img4.mukewang.com/5c77781f00016de908300486.jpg


  • 隔壁王爷爷
    2015-04-15 23:53:57

    Class.forName() 能执行之后

    重启之后DriverManager.getConnection()爆错

    吃完饭回来

    才想起来 重启之后没开启服务

    开启MySQL之后就OK了

    http://img.mukewang.com/552e898f0001e77c10220726.jpg


  • 隔壁王爷爷
    2015-04-15 21:20:53

    现在是Class.forName() 能执行

    DriverManager.getConnection()爆错

    一直在循环爆这个错误

    2015-04-15 21:09:02 JRebel: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
    com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 
    
    ** BEGIN NESTED EXCEPTION ** 
    
    java.net.ConnectException
    MESSAGE: Connection refused: connect
    
    STACKTRACE:
    
    java.net.ConnectException: Connection refused: connect
    	at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    	at java.net.Socket.connect(Socket.java:589)
    	at java.net.Socket.connect(Socket.java:538)
    	at java.net.Socket.<init>(Socket.java:434)
    	at java.net.Socket.<init>(Socket.java:244)
    	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
    	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
    	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
    	at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
    	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    	at java.sql.DriverManager.getConnection(DriverManager.java:664)
    	at java.sql.DriverManager.getConnection(DriverManager.java:247)
    	at shop.util.DBHelper.getInstance(DBHelper.java:41)
    	at shop.dao.ItemsDao.getAllItems(ItemsDao.java:35)
    	at org.apache.jsp.index_jsp._jspService(index_jsp.java:115)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    	at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:395)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    	at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:122)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    	at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:170)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2466)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2455)
    	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)
    
    
    ** END NESTED EXCEPTION **
    
    
    
    Last packet sent to the server was 0 ms ago.
    	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2847)
    	at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
    	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    	at java.sql.DriverManager.getConnection(DriverManager.java:664)
    	at java.sql.DriverManager.getConnection(DriverManager.java:247)
    	at shop.util.DBHelper.getInstance(DBHelper.java:41)
    	at shop.dao.ItemsDao.getAllItems(ItemsDao.java:35)
    	at org.apache.jsp.index_jsp._jspService(index_jsp.java:115)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    	at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:395)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    	at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:122)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    	at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:170)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2466)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2455)
    	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)
    com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 
    
    ** BEGIN NESTED EXCEPTION ** 
    
    java.net.ConnectException
    MESSAGE: Connection refused: connect
    
    STACKTRACE:
    
    java.net.ConnectException: Connection refused: connect
    	at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
    	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    	at java.net.Socket.connect(Socket.java:589)
    	at java.net.Socket.connect(Socket.java:538)
    	at java.net.Socket.<init>(Socket.java:434)
    	at java.net.Socket.<init>(Socket.java:244)
    	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
    	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
    	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
    	at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
    	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    	at java.sql.DriverManager.getConnection(DriverManager.java:664)
    	at java.sql.DriverManager.getConnection(DriverManager.java:247)
    	at shop.util.DBHelper.getInstance(DBHelper.java:41)
    	at shop.dao.ItemsDao.getAllItems(ItemsDao.java:35)
    	at org.apache.jsp.index_jsp._jspService(index_jsp.java:115)
    	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    	at org.apache.jasper.servlet.JspServlet._serviceJspFile(JspServlet.java:395)
    	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java)
    	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    	at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:122)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
    	at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:170)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
    	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
    	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2466)
    	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2455)
    	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)
    
    
    ** END NESTED EXCEPTION **


  • 隔壁王爷爷
    2015-04-15 21:18:16

    debug加搜索 用了三个小时,发现tomcat跟java的classloader不一样

    把mysql-connector-*.jar 复制到tomcat/lib下 还是显示不出正确结果

    先去吃晚饭,吃完饭继续debug

  • 隔壁王爷爷
    2015-04-15 21:15:39

    开始以为是编码的问题,把所有文件搞成utf-8

    又把数据库搞成utf-8,还是爆错

JAVA遇见HTML——JSP篇

Java Web入门级教程JSP,带你轻松的学习JSP基础知识

248278 学习 · 3071 问题

查看课程

相似问题