"No such file or directory" 使用Resteasy上传文件时出错
"No such file or directory" error when uploading a file using Resteasy
我有一个正在寻找多部分数据的 Web 服务端点
@POST
@Path("/import/file")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response importData(MultipartFormDataInput multipartData) {
if(multipartData == null) {
return Response.status(400).entity("Invalid Data").build();
}
InputStream is = multipartData.getFormDataPart("file", Inputstream.class, null);
try {
someService.someMethod(is);
} catch(Exception ex) {
return Response.serverError().build();
}
return Response.ok().build();
}
当我调用此 Web 服务(使用 Postman)时,我不断收到此错误
15:29:52.664 WARN - Failed executing POST /import/file
org.jboss.resteasy.spi.ReaderException: java.lang.RuntimeException: java.io.IOException: No such file or directory
at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:183) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:89) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:112) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:217) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:224) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:62) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:185) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.ModuleResourceFilter.doFilter(ModuleResourceFilter.java:157) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.ModuleResourceFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.MarmottaServerNameFilter.doFilter(MarmottaServerNameFilter.java:104) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.TemplatingFilter.doFilter(TemplatingFilter.java:176) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.TemplatingFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:182) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.security.filters.MarmottaAccessControlFilter.doFilter(MarmottaAccessControlFilter.java:151) [marmotta-security-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.security.filters.MarmottaAccessControlFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-security-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.user.filters.MarmottaAuthenticationFilter.doFilter(MarmottaAuthenticationFilter.java:191) [marmotta-user-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.user.filters.MarmottaAuthenticationFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-user-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter.doFilter(MarmottaResourceFilter.java:133) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.marmotta.platform.core.servlet.MarmottaPreStartupFilter.doFilter(MarmottaPreStartupFilter.java:106) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:208) [cors-filter-2.2.1.jar:2.2.1]
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:271) [cors-filter-2.2.1.jar:2.2.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.marmotta.platform.core.servlet.MarmottaOptionsFilter.doFilter(MarmottaOptionsFilter.java:81) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.35]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [catalina.jar:8.0.35]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.35]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.35]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) [catalina.jar:8.0.35]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) [tomcat-coyote.jar:8.0.35]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-coyote.jar:8.0.35]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) [tomcat-coyote.jar:8.0.35]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) [tomcat-coyote.jar:8.0.35]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.35]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]
Caused by: java.lang.RuntimeException: java.io.IOException: No such file or directory
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryOnlyMessageBuilder.body(MultipartInputImpl.java:140) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.apache.james.mime4j.parser.MimeStreamParser.parse(MimeStreamParser.java:101) ~[apache-mime4j-0.6.jar:0.6]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:153) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:146) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:197) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:52) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:20) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:59) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:62) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:51) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:150) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
... 56 common frames omitted
Caused by: java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:1.8.0_77]
at java.io.File.createTempFile(File.java:2024) ~[na:1.8.0_77]
at org.apache.james.mime4j.storage.TempFileStorageProvider.createStorageOutputStream(TempFileStorageProvider.java:104) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.storage.ThresholdStorageProvider$ThresholdStorageOutputStream.write0(ThresholdStorageProvider.java:113) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.storage.StorageOutputStream.write(StorageOutputStream.java:119) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.codec.CodecUtil.copy(CodecUtil.java:43) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.storage.AbstractStorageProvider.store(AbstractStorageProvider.java:57) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.message.BodyFactory.binaryBody(BodyFactory.java:92) ~[apache-mime4j-0.6.jar:0.6]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryOnlyMessageBuilder.body(MultipartInputImpl.java:132) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
... 68 common frames omitted
据我所知,请求正在命中过滤器并清除它们,但由于某种原因,没有进入 importData
方法。
有人能告诉我为什么会出现这个错误吗?在我看来,服务器无法在某处创建一些临时文件,但我无法理解在哪里以及为什么需要这个临时文件?
我能够确定问题所在。系统属性java.io.tmpdir
的值在系统中不存在。手动创建位置后,我没有收到错误消息。
背景:
File.createTempFile(String prefix, String suffix, File dir)
方法尝试在指定目录中创建一个临时文件。如果这是 null
那么它使用系统提供的路径 属性 java.io.tmpdir
。此 属性 应该是系统中的有效目录。如果此 属性 未设置或在系统中不存在,您将得到我得到的异常。
我有一个正在寻找多部分数据的 Web 服务端点
@POST
@Path("/import/file")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response importData(MultipartFormDataInput multipartData) {
if(multipartData == null) {
return Response.status(400).entity("Invalid Data").build();
}
InputStream is = multipartData.getFormDataPart("file", Inputstream.class, null);
try {
someService.someMethod(is);
} catch(Exception ex) {
return Response.serverError().build();
}
return Response.ok().build();
}
当我调用此 Web 服务(使用 Postman)时,我不断收到此错误
15:29:52.664 WARN - Failed executing POST /import/file
org.jboss.resteasy.spi.ReaderException: java.lang.RuntimeException: java.io.IOException: No such file or directory
at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:183) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:89) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:112) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:217) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:224) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:62) [resteasy-jaxrs-3.0.10.Final.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:185) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.ModuleResourceFilter.doFilter(ModuleResourceFilter.java:157) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.ModuleResourceFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.MarmottaServerNameFilter.doFilter(MarmottaServerNameFilter.java:104) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.TemplatingFilter.doFilter(TemplatingFilter.java:176) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.filters.TemplatingFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:182) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.security.filters.MarmottaAccessControlFilter.doFilter(MarmottaAccessControlFilter.java:151) [marmotta-security-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.security.filters.MarmottaAccessControlFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-security-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.user.filters.MarmottaAuthenticationFilter.doFilter(MarmottaAuthenticationFilter.java:191) [marmotta-user-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.user.filters.MarmottaAuthenticationFilter$Proxy$_$$_WeldClientProxy.doFilter(Unknown Source) [marmotta-user-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter$MarmottaFilterChain.doFilter(MarmottaResourceFilter.java:180) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter.doFilter(MarmottaResourceFilter.java:133) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.marmotta.platform.core.servlet.MarmottaPreStartupFilter.doFilter(MarmottaPreStartupFilter.java:106) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:208) [cors-filter-2.2.1.jar:2.2.1]
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:271) [cors-filter-2.2.1.jar:2.2.1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.marmotta.platform.core.servlet.MarmottaOptionsFilter.doFilter(MarmottaOptionsFilter.java:81) [marmotta-core-3.3.0.jar:3.3.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [catalina.jar:8.0.35]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.35]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [catalina.jar:8.0.35]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.35]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) [catalina.jar:8.0.35]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.35]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) [catalina.jar:8.0.35]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) [tomcat-coyote.jar:8.0.35]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-coyote.jar:8.0.35]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) [tomcat-coyote.jar:8.0.35]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) [tomcat-coyote.jar:8.0.35]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_77]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_77]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.35]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_77]
Caused by: java.lang.RuntimeException: java.io.IOException: No such file or directory
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryOnlyMessageBuilder.body(MultipartInputImpl.java:140) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.apache.james.mime4j.parser.MimeStreamParser.parse(MimeStreamParser.java:101) ~[apache-mime4j-0.6.jar:0.6]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:153) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:146) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:197) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:52) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:20) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:59) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:62) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:51) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:150) ~[resteasy-jaxrs-3.0.10.Final.jar:na]
... 56 common frames omitted
Caused by: java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:1.8.0_77]
at java.io.File.createTempFile(File.java:2024) ~[na:1.8.0_77]
at org.apache.james.mime4j.storage.TempFileStorageProvider.createStorageOutputStream(TempFileStorageProvider.java:104) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.storage.ThresholdStorageProvider$ThresholdStorageOutputStream.write0(ThresholdStorageProvider.java:113) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.storage.StorageOutputStream.write(StorageOutputStream.java:119) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.codec.CodecUtil.copy(CodecUtil.java:43) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.storage.AbstractStorageProvider.store(AbstractStorageProvider.java:57) ~[apache-mime4j-0.6.jar:0.6]
at org.apache.james.mime4j.message.BodyFactory.binaryBody(BodyFactory.java:92) ~[apache-mime4j-0.6.jar:0.6]
at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryOnlyMessageBuilder.body(MultipartInputImpl.java:132) ~[resteasy-multipart-provider-3.0.10.Final.jar:na]
... 68 common frames omitted
据我所知,请求正在命中过滤器并清除它们,但由于某种原因,没有进入 importData
方法。
有人能告诉我为什么会出现这个错误吗?在我看来,服务器无法在某处创建一些临时文件,但我无法理解在哪里以及为什么需要这个临时文件?
我能够确定问题所在。系统属性java.io.tmpdir
的值在系统中不存在。手动创建位置后,我没有收到错误消息。
背景:
File.createTempFile(String prefix, String suffix, File dir)
方法尝试在指定目录中创建一个临时文件。如果这是 null
那么它使用系统提供的路径 属性 java.io.tmpdir
。此 属性 应该是系统中的有效目录。如果此 属性 未设置或在系统中不存在,您将得到我得到的异常。