POI 3.8版本导出excel :java.lang.RuntimeException: java.io.IOException: No such file or directory

POI 3.8版本导出excel问题

 

使用poi 3.8版本导出excel时,在本地和测试环境都是好使的,但是部署到线上环境(linux+tomcat)后直接报错,报错日志如下图:

java.lang.RuntimeException: java.io.IOException: No such file or directory
        at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:569)
        at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:558)
        at com.app.util.ExcelIOUtil.write(ExcelIOUtil.java:46)
        at com.app.controllers.DrivingSchoolController.download(DrivingSchoolController.java:106)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.mvc.invoke.ActionInvoker.invoke(ActionInvoker.java:75)
        at com.mvc.MvcDispatcher.service(MvcDispatcher.java:119)
        at com.mvc.MvcFilter.doFilter(MvcFilter.java:67)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.AprEndpoint$SocketWithOptionsProcessor.run(AprEndpoint.java:1810)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662) 

原因是:

poi3.8默认情况下,用到的tomcat临时目录。 

解决办法:

查看tomcat目录下temp目录是否还存在,如果没有,新建一个即可。

你可能感兴趣的:(POI 3.8版本导出excel :java.lang.RuntimeException: java.io.IOException: No such file or directory)