net.sf.jasperreports.engine.JRException:Class not found when loading object from file代码如下用jsp调用(那itext-1.3.1.jar,itextasia.jar等这几个包都导入了,但报以上的异常): <%
//报表编译之后生成的.jasper 文件的存放位置
File reportFile = new File(application.getRealPath("/reports/first.jasper"));
//这个是用来联接我的mysql 的JDBC URL
Connection conn=null;
try{
Context ctx=new InitialContext();DataSource source = (DataSource)ctx.lookup("java:comp/env/123");
conn=source.getConnection();}catch(Exception e){
e.printStackTrace();
} System.out.println("---------conn-------------");
//连接到数据库
JasperPrint jasperPrint=JasperFillManager.fillReport(reportFile.getPath(),null,conn); byte[] bytes=JasperRunManager.runReportToPdf(reportFile.getPath(),null,conn); System.out.println("---------Jasper end-------------");
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
%>这个问题已婚好多天没有搞定了。。以前是可以出来的。。也是这个程序,但现在不知是怎么回事运行起来报错.大家帮帮忙!
只要问题能解决。。一定送分!
//报表编译之后生成的.jasper 文件的存放位置
File reportFile = new File(application.getRealPath("/reports/first.jasper"));
//这个是用来联接我的mysql 的JDBC URL
Connection conn=null;
try{
Context ctx=new InitialContext();DataSource source = (DataSource)ctx.lookup("java:comp/env/123");
conn=source.getConnection();}catch(Exception e){
e.printStackTrace();
} System.out.println("---------conn-------------");
//连接到数据库
JasperPrint jasperPrint=JasperFillManager.fillReport(reportFile.getPath(),null,conn); byte[] bytes=JasperRunManager.runReportToPdf(reportFile.getPath(),null,conn); System.out.println("---------Jasper end-------------");
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream ouputStream = response.getOutputStream();
ouputStream.write(bytes, 0, bytes.length);
ouputStream.flush();
ouputStream.close();
%>这个问题已婚好多天没有搞定了。。以前是可以出来的。。也是这个程序,但现在不知是怎么回事运行起来报错.大家帮帮忙!
只要问题能解决。。一定送分!
找不到要装载的class文件
你先看一下你目录下有没有要装载的文件
然后再检查路径吧
没什么其他问题啊