我们刚刚将Tomcat从9.0升级到10.1,Java从8升级到11。一切都运行得很好,除了现在我们有临时文件堆积在Apache Software Foundation\Tomcat 10.1\work\Catalina\localhost\root
中。这导致Java堆空间问题后出现502错误。我们看到这样的错误。
07-Feb-2023 23:33:11.414 SEVERE [http-nio-81-exec-3] org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun Error running socket processor
java.io.UncheckedIOException: Cannot delete C:\Program Files\Apache Software Foundation\Tomcat 10.1\work\Catalina\localhost\root\upload_ac88107d_733f_4b9d_a3a3_9274a46f92e3_00000509.tmp
at org.apache.tomcat.util.http.fileupload.disk.DiskFileItem.delete(DiskFileItem.java:429)
at org.apache.catalina.core.ApplicationPart.delete(ApplicationPart.java:54)
at org.apache.catalina.connector.Request.recycle(Request.java:451)
at org.apache.catalina.connector.CoyoteAdapter.log(CoyoteAdapter.java:512)
at org.apache.catalina.connector.CoyoteAdapter.checkRecycled(CoyoteAdapter.java:536)
at org.apache.coyote.http11.Http11Processor.recycle(Http11Processor.java:1440)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.release(AbstractProtocol.java:1052)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:1024)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1734)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: Cannot delete C:\Program Files\Apache Software Foundation\Tomcat 10.1\work\Catalina\localhost\root\upload_ac88107d_733f_4b9d_a3a3_9274a46f92e3_00000509.tmp
... 14 more
字符串
有什么想法吗?
1条答案
按热度按时间inb24sb21#
它来自你的代码的文件处理部分。代码在tomcat 8.0.50上工作正常,但在更高的版本中,它会抛出错误,如:无法删除临时文件。
有两种方法可以解决这个问题:
1.在阅读写数据时不要使用**
byte[]
**类型的arg。从输入文件中读取数据的正确方法是:字符串
注意:这将需要一些时间来处理文件,但它不会抛出任何错误。
1.恢复到旧的tomcat版本使用**
byte[]
**。