文件上传异常 unexpected end of part

问题1:
2017-09-12 09:51:34
[DEBUG]-[Thread: http-bio-8081-exec-7047]-[com.jfinal.kit.LogKit.debug()]: 已拦截
java.lang.RuntimeException: java.io.IOException: unexpected end of part
	at com.jfinal.upload.MultipartRequest.wrapMultipartRequest(MultipartRequest.java:126)
	at com.jfinal.upload.MultipartRequest.<init>(MultipartRequest.java:68)
	at com.jfinal.core.Controller.getFiles(Controller.java:775)
	at com.jfinal.core.Controller.getFile(Controller.java:780)
	at com.yuminsoft.cps.pic.api.file.FileDataController.upload(FileDataController.java:105)
	at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	at com.jfinal.validate.Validator.intercept(Validator.java:86)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.validate.Validator.intercept(Validator.java:86)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.api.common.ApiInterceptor.intercept(ApiInterceptor.java:37)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.common.interceptor.AuthInterceptor.intercept(AuthInterceptor.java:26)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.common.interceptor.ExceptionGlobalInterceptor.intercept(ExceptionGlobalInterceptor.java:29)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82)
	at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:48)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	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:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: unexpected end of part
	at com.oreilly.servlet.multipart.PartInputStream.fill(PartInputStream.java:100)
	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)
	... 38 more

主要是图片上传,FileDataController.java:105代码

pic1.jpg

问题2:

2017-09-12 10:37:26
[DEBUG]-[Thread: http-bio-8081-exec-7114]-[com.jfinal.kit.LogKit.debug()]: 已拦截
java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out
	at com.jfinal.upload.MultipartRequest.wrapMultipartRequest(MultipartRequest.java:126)
	at com.jfinal.upload.MultipartRequest.<init>(MultipartRequest.java:68)
	at com.jfinal.core.Controller.getFiles(Controller.java:775)
	at com.jfinal.core.Controller.getFile(Controller.java:780)
	at com.yuminsoft.cps.pic.api.file.FileDataController.upload(FileDataController.java:105)
	at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	at com.jfinal.validate.Validator.intercept(Validator.java:86)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.validate.Validator.intercept(Validator.java:86)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.api.common.ApiInterceptor.intercept(ApiInterceptor.java:37)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.common.interceptor.AuthInterceptor.intercept(AuthInterceptor.java:26)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.common.interceptor.ExceptionGlobalInterceptor.intercept(ExceptionGlobalInterceptor.java:29)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82)
	at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:48)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	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:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketTimeoutException: Read timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:152)
	at java.net.SocketInputStream.read(SocketInputStream.java:122)
	at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:535)
	at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:504)
	at org.apache.coyote.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:566)
	at org.apache.coyote.http11.filters.IdentityInputFilter.doRead(IdentityInputFilter.java:137)
	at org.apache.coyote.http11.AbstractInputBuffer.doRead(AbstractInputBuffer.java:287)
	at org.apache.coyote.Request.doRead(Request.java:438)
	at org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:290)
	at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:449)
	at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315)
	at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200)
	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:183)
	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)
	... 38 more

最后直接拖死系统,

2017-09-12 16:45:44
[DEBUG]-[Thread: http-bio-8081-exec-8152]-[com.jfinal.kit.LogKit.debug()]: 已拦截
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at com.jfinal.aop.Invocation.invoke(Invocation.java:87)
	at com.jfinal.validate.Validator.intercept(Validator.java:86)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.validate.Validator.intercept(Validator.java:86)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.api.common.ApiInterceptor.intercept(ApiInterceptor.java:37)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.common.interceptor.AuthInterceptor.intercept(AuthInterceptor.java:26)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.yuminsoft.cps.pic.common.interceptor.ExceptionGlobalInterceptor.intercept(ExceptionGlobalInterceptor.java:29)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:82)
	at com.jfinal.ext.handler.ContextPathHandler.handle(ContextPathHandler.java:48)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	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:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:958)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:452)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	... 30 more
Caused by: java.lang.OutOfMemoryError: Java heap space


ApiInterceptor.java

pic2.jpg

AuthInterceptor.java

pic3.jpg

ExceptionGlobalInterceptor.java

pic4.jpg

评论区

杜福忠

2017-09-13 12:35

拦截器里要取参, 也得先 getFile的

无为

2017-09-13 13:50

@杜福忠 好的,我测试一下

1040110333

2017-09-13 19:31

@无为 com/google/zxing/client/j2se/MatrixToImageWriter 这是引用jfinal 3.3报的错

无为

2017-09-14 14:32

@1040110333 jfinal3.2,系统没有引用ZXing包

1040110333

2017-09-14 15:38

问题已经解决了

无为

2017-09-14 21:34

叶落风吹

2017-11-03 13:29

我也碰到这个问题了,怎么解决啊?求大佬~~~

无为

2017-11-06 11:43

@叶落风吹 静态文件走nginx,所有文件下载。比如压缩后下载,java压缩好后放到服务器上,转nginx下载。上传就没问题了。

93538271

2017-11-21 17:25

热门反馈

扫码入社