关于jfinal上传大文件报错

我在后台系统中使用layui上传一个接近200M的视频。,

上传报错,后台日志信息如下。

java.lang.RuntimeException: org.apache.catalina.connector.ClientAbortException: java.io.EOFException: Unexpected EOF read on the socket
	at com.jfinal.upload.MultipartRequest.wrapMultipartRequest(MultipartRequest.java:126)
	at com.jfinal.upload.MultipartRequest.<init>(MultipartRequest.java:63)
	at com.jfinal.core.Controller.getFiles(Controller.java:764)
	at com.jfinal.core.Controller.getFile(Controller.java:769)
	at com.yutong.cms.admin.controller.ComnController.uploadVideo(ComnController.java:170)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82)
	at com.yutong.cms.core.handler.WebSocketHandler.handle(WebSocketHandler.java:15)
	at com.jfinal.plugin.druid.DruidStatViewHandler.handle(DruidStatViewHandler.java:75)
	at com.yutong.cms.core.handler.ActionHandler.handle(ActionHandler.java:45)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.catalina.connector.ClientAbortException: java.io.EOFException: Unexpected EOF read on the socket
	at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:348)
	at org.apache.catalina.connector.InputBuffer.checkByteBufferEof(InputBuffer.java:663)
	at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:370)
	at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:183)
	at com.oreilly.servlet.multipart.BufferedServletInputStream.fill(BufferedServletInputStream.java:64)
	at com.oreilly.servlet.multipart.BufferedServletInputStream.readLine(BufferedServletInputStream.java:108)
	at com.oreilly.servlet.multipart.LimitedServletInputStream.readLine(LimitedServletInputStream.java:60)
	at com.oreilly.servlet.multipart.PartInputStream.fill(PartInputStream.java:97)
	at com.oreilly.servlet.multipart.PartInputStream.read(PartInputStream.java:195)
	at com.oreilly.servlet.multipart.PartInputStream.read(PartInputStream.java:156)
	at com.oreilly.servlet.multipart.FilePart.write(FilePart.java:208)
	at com.oreilly.servlet.multipart.FilePart.writeTo(FilePart.java:167)
	at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:272)
	at com.jfinal.upload.MultipartRequest.wrapMultipartRequest(MultipartRequest.java:107)
	... 47 more
Caused by: java.io.EOFException: Unexpected EOF read on the socket
	at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:736)
	at org.apache.coyote.http11.Http11InputBuffer.access$300(Http11InputBuffer.java:40)
	at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1086)
	at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:140)
	at org.apache.coyote.http11.Http11InputBuffer.doRead(Http11InputBuffer.java:263)
	at org.apache.coyote.Request.doRead(Request.java:581)
	at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:344)
	... 60 more

同时我也有修改过tomcat的链接超时时间。但仍然出错。

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="300000"
               redirectPort="8443" />

请求波总支援

评论区

阿城锅

2019-05-27 11:57

JFinal

2019-05-27 12:03

异常是:java.io.EOFException: Unexpected EOF read on the socket

也就是说上传的数据格式不对,没有遵守 html 规范,注意查看客户端代码

阿城锅

2019-05-27 13:38

@JFinal
public void uploadVideo() {
try {
Constants constants = new Constants();
UploadFile file = this.getFile("file", "video");
file.getFile().createNewFile();
Map data = new HashMap();
data.put("filePath", "/"+constants.getBaseUploadPath()+"/video/" + file.getFileName());
data.put("fileName", file.getFileName());
rendSuccessJson(data);
} catch (Exception e) {
e.printStackTrace();
rendFailedJson(ErrorCode.get("9999"));
}
}
小文件没问题,大文件上传,在上传读条过程中超过了一定时间就出现此类错误

要输就输给追求

2019-05-27 15:22

看看我用jfinal处理的大文件上传。 https://gitee.com/ysjsgzq/splitUpload.git 浏览器直接把文件切成小片,然后服务器端接收了再组合起来

热门反馈

扫码入社