首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

tomcat出现org.apache.catalina.core.StandardWrapperValve invoke异常

2012-02-13 
tomcat出现org.apache.catalina.core.StandardWrapperValve invoke错误代码如下:%@ page importjava.aw

tomcat出现org.apache.catalina.core.StandardWrapperValve invoke错误
代码如下:
<%@ page import="java.awt.image.*,java.sql.*,com.sun.image.codec.jpeg.*,java.util.*,javax.imageio.*,java.io.*"%><%

// Create image
String username,password,url;
BufferedInputStream inputimage = null;
//定义用户名、密码以及URL
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url,username,password);
//System.out.println(conn);  
Statement stmt = conn.createStatement();
//System.out.println(stmt);
boolean defaultCommit = conn.getAutoCommit();
conn.setAutoCommit(false);

try {

ResultSet rs = stmt.executeQuery("SELECT thumbnail FROM t_course where course_id = "+request.getParameter("courseId"));

while (rs.next()) {
  Blob blob = rs.getBlob("thumbnail");
  inputimage = new BufferedInputStream(blob.getBinaryStream());
}
} catch (Exception ex) {
  System.out.println("blobRead()s exception "+ex);
  conn.rollback();
  throw ex;
}
conn.setAutoCommit(defaultCommit);

// Send back image
BufferedImage image = null;
try{
  image = ImageIO.read(inputimage);
}catch(IOException e){
  System.out.println(e);
}


response.setContentType("image/jpeg");
response.reset();
ServletOutputStream sos = response.getOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
encoder.encode(image);
inputimage.close();
%>
结果调试运行的时候出现:
org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at org.apache.jsp.course.courseBlobList_jsp._jspService(courseBlobList_jsp.java:83)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)



[解决办法]
用得的变量看一下是否有null
[解决办法]
找到相关的了你看看:http://fengpeixi.javaeye.com/blog/216762
[解决办法]
你确定所有的变量都有值?怎么会有空指针异常,应该有一个变量没有值。全部判断一下看看。

热点排行