jasper导出Excel文件,debug导出文件异常,非debug是正常的

u010538302 2015-07-06 08:38:37

public class ReportUtil {
public static void http_export_Excel(HttpServletRequest request, HttpServletResponse response,
String jasperTemplateName, List<?> list,String exportname) {

response.setContentType("application/vnd.ms-excel");
JasperReport jasperReport = null;
JasperPrint jasperPrint = null;
// String url = ReportUtil.class.getResource("ReportUtil.class").getFile().toString();
// String jasperPath = url.substring(0,url.indexOf("WEB-INF"))+"/jasper/"+jasperTemplateName;
// File reportFile = new File(jasperPath.replace("file:", ""));
String jasperPath = "F:/ireport/loaninformationquery.jasper";
File reportFile = new File(jasperPath);

try {

String fileName = new String((exportname+".xls").getBytes("gbk"), "ISO8859_1");
response.setHeader("Content-disposition", "attachment; filename=" + fileName);
jasperReport = (JasperReport) JRLoader.loadObjectFromFile(reportFile.getPath());
jasperPrint = JasperFillManager.fillReport(jasperReport, null, new JRBeanCollectionDataSource(list));
Exporter<ExporterInput, XlsReportConfiguration, XlsExporterConfiguration, OutputStreamExporterOutput> exporter = new JRXlsExporter();
SimpleXlsReportConfiguration config = new SimpleXlsReportConfiguration();
config.setRemoveEmptySpaceBetweenColumns(true);
config.setRemoveEmptySpaceBetweenRows(true);
config.setWhitePageBackground(false);
config.setDetectCellType(true);
exporter.setConfiguration(config);
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
ServletOutputStream ouputStream = response.getOutputStream();
OutputStreamExporterOutput exporterout = new SimpleOutputStreamExporterOutput(ouputStream);
exporter.setExporterInput(exporterInput);
exporter.setExporterOutput(exporterout);
exporter.exportReport();

} catch (JRException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}
上面是我的源码
下面是报错堆栈信息:
[ERROR] Error for /mcms-portal/crzDebit/account/toGetExcel.do
java.lang.OutOfMemoryError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:366)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:55)
at ch.qos.logback.classic.spi.LoggingEvent.<init>(LoggingEvent.java:124)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:447)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:403)
at ch.qos.logback.classic.Logger.log(Logger.java:803)
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:147)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:910)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at com.suning.mcms.web.auth.filter.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:204)
at com.suning.mcms.web.auth.filter.FilterSecurityInterceptor.doFilterHttp(FilterSecurityInterceptor.java:131)
at com.suning.mcms.web.auth.filter.SecurityFilter.doFilter(SecurityFilter.java:52)
at com.suning.mcms.web.auth.filter.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:216)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
[ERROR] EXCEPTION
java.lang.OutOfMemoryError: PermGen space
java.lang.reflect.InvocationTargetException
[ERROR] handle failed
java.lang.OutOfMemoryError: PermGen space
...全文
115 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

50,600

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧