导出报错org.apache.catalina.connector.ClientAbortException: java.io.IOException

在做excel导出的时候,有些文件可以正常导出,有些失败,有些莫名其妙,经过分析,最终得以解决,下面做一下解决总结;

1、报错日志

org.apache.catalina.connector.ClientAbortException: java.io.IOException
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:370)
    at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:334)
    at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at java.io.FilterOutputStream.close(Unknown Source)
    at com.supyuan.util.ExcelUtils.writeData(ExcelUtils.java:215)
    at com.supyuan.system.bom.BomController.exportViewList(BomController.java:488)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:83)
    at com.supyuan.component.interceptor.CommonInterceptor.intercept(CommonInterceptor.java:27)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:77)
    at com.supyuan.component.interceptor.UserInterceptor.intercept(UserInterceptor.java:124)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:77)
    at com.supyuan.component.interceptor.UserKeyInterceptor.intercept(UserKeyInterceptor.java:28)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:77)
    at com.supyuan.jfinal.component.interceptor.JflyfoxInterceptor.intercept(JflyfoxInterceptor.java:26)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:77)
    at com.supyuan.jfinal.component.interceptor.SessionAttrInterceptor.intercept(SessionAttrInterceptor.java:48)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:77)
    at com.jfinal.ext.interceptor.SessionInViewInterceptor.intercept(SessionInViewInterceptor.java:44)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:77)
    at com.supyuan.jfinal.component.interceptor.ExceptionInterceptor.intercept(ExceptionInterceptor.java:38)
    at com.jfinal.aop.Invocation.invoke(Invocation.java:77)
    at com.jfinal.core.ActionHandler.handle(ActionHandler.java:90)
    at com.supyuan.system.websocket.WebSocketHandler.handle(WebSocketHandler.java:31)
    at com.supyuan.jfinal.component.handler.CurrentPathHandler.handle(CurrentPathHandler.java:53)
    at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:48)
    at com.supyuan.jfinal.component.handler.BasePathHandler.handle(BasePathHandler.java:57)
    at com.supyuan.jfinal.component.handler.HtmlHandler.handle(HtmlHandler.java:48)
    at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:89)
    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:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2575)
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2564)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException
    at org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:205)
    at org.apache.coyote.http11.InternalAprOutputBuffer.flush(InternalAprOutputBuffer.java:109)
    at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:850)
    at org.apache.coyote.Response.action(Response.java:171)
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:366)
    ... 50 more

二、从日志在看具体报错的代码是

BufferedOutputStream bos = new BufferedOutputStream(outputStream);

.......

bos.close();

流的关闭报错,导出已经正确,也就是不能正常导出,跟导出正常的文件进行对比,发现数据也没有很大区别,最终发现在导出文件命名的区别

导出失败:35003100(亮光)单独出货-0002

导出成功:14300000(ROHS)-0000

导出失败文件的命名有中文的括号,后来发现有逗号也不可以,最终修改导出文件命名方式,问题得以解决。

你可能感兴趣的:(java)