Unable to create tempDir, java.io.tmpdir is set to C:\Windows\

ilya picture ilya · May 30, 2018 · Viewed 13.2k times · Source

I'm using Spring Boot with embedded tomcat, everything worked fine and suddenly I got the error :

Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to create tempDir. java.io.tmpdir is set to C:\Windows\
    at org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory.createTempDir(AbstractEmbeddedServletContainerFactory.java:183)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:165)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
    ... 11 common frames omitted
Caused by: java.io.IOException: Access is denied
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createTempFile(File.java:2024)
    at java.io.File.createTempFile(File.java:2070)
    at org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory.createTempDir(AbstractEmbeddedServletContainerFactory.java:174)
    ... 14 common frames omitted

I didn't do any manipulations with user or system variables.

My TEMP user variable is looking on C:/Users/me/AppData/Local/Temp , and I guess tomcat has to use this value insted of system one, which is actually C:/Windows/Temp

Answer

Max picture Max · Jun 21, 2018

If you use IDEA check "Include parent environment variables" in Environment Variables window in the Run/Debug Configuration.