LoginSignup
9
4

More than 3 years have passed since last update.

Spring boot temporary upload location [/tmp/tomcat ・・・ is not valid]

Last updated at Posted at 2019-06-16

事象

いつも動いていたファイルアップロードがある日突然動かなくなった。
※Spring boot embedded Tomcatを使っている時は要注意。

エラー内容

application.log
ERROR 39865 --- [http-nio-20080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is 
org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException:
The temporary upload location [/tmp/tomcat.12071915071708668548.20080/work/Tomcat/localhost/ROOT] is not valid] with root cause

原因

SpringのembeddedTomcatが一時フォルダ(ファイルアップロード時などのWORK)として利用するディレクトリをOSが削除していた。。(OSの削除対象ディレクトリとかぶっていた)
そのため、突然アップロード時に使用する一時フォルダが存在しないと言う状態に。
今回はCentOSを使用していた。
embeddedTomcatの場合一時フォルダはデフォルトだと/tmp/tomcat.xxxxxx で作成される(tomcat起動時に自動生成)

対応

一時フォルダを/tmpから変更する

application.yml
server:
  tomcat:
    basedir: /xxx/xxxx/xxxx   # ここでパスを指定
9
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
4