Skip to content

Jetty tmpdir processing doesn't match Java on Windows #14068

@patrickptibco

Description

@patrickptibco

Jetty version(s)
12.1

Jetty Environment
all

HTTP version
N/A

Java version/vendor (use: java -version)
All (25, 21,17)

OS type/version
Windows

Description
The commit 94991c6 states Context now has a getter for a temp directory, which is never null. This is false for some JVM-supported configurations on Windows, which can lead to NPE's. Furthermore, Jetty tried to support extra temp directory specifications (file URI), but the JVM doesn't support those. It would be best to match the JVM.

I believe this is a simple as changing https://github.com/jetty/jetty.project/blame/jetty-12.1.x/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java#L920 to be Path.of().toFile(), not IO.asFile

java.io.tmpdir JVM Jetty
C:\correct\backslash
C;/unix/slashes
file:///C:/uri/style/path ✅ (actually fails due to JVM, but the Jetty code supports it)

How to reproduce?

JVM:

PS C:\temp> jshell '-R-Djava.io.tmpdir=file:///C:/temp/'
jshell> File.createTempFile("blerh", ".gh")
|  Exception java.io.IOException: The filename, directory name, or volume label syntax is incorrect
|        at WinNTFileSystem.createFileExclusively0 (Native Method)
|        at WinNTFileSystem.createFileExclusively (WinNTFileSystem.java:542)
|        at File.createTempFile (File.java:1887)
|        at File.createTempFile (File.java:1928)
|        at (#1:1)

PS C:\temp> jshell '-R-Djava.io.tmpdir=C:/temp/'
jshell> File.createTempFile("blerh", ".gh")
$1 ==> C:\temp\blerh11142617723366970929.gh

PS C:\temp> jshell '-R-Djava.io.tmpdir=C:\\temp\\'
jshell> File.createTempFile("blerh", ".gh")
$1 ==> C:\temp\blerh9068161279322634000.gh

Jetty:
Download and extract the latest jetty, unzip, and run a terminal in the install path, then run:

PS C:\testj\jetty-home-12.1.4\jetty-home-12.1.4> mkdir base


    Directory: C:\testj\jetty-home-12.1.4\jetty-home-12.1.4


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        11/19/2025  12:42 PM                base


PS C:\testj\jetty-home-12.1.4\jetty-home-12.1.4> cd base
PS C:\testj\jetty-home-12.1.4\jetty-home-12.1.4\base> java -jar ..\start.jar '--add-modules=ee11-demo-simple,ee11-deploy,http'
..snip...
PS C:\testj\jetty-home-12.1.4\jetty-home-12.1.4\base> java '-Djava.io.tmpdir=C:/testj/' -jar ..\start.jar
2025-11-19 12:42:53.707:INFO :oejs.Server:main: jetty-12.1.4; built: 2025-11-10T17:42:37.481Z; git: 4137e00793d583cfc4ce76bf607e482178a85597; jvm 25.0.1+8-LTS
2025-11-19 12:42:53.725:INFO :oejd.DeploymentScanner:main: Deployment monitoring of [C:\testj\jetty-home-12.1.4\jetty-home-12.1.4\base\webapps] at intervals 0s (hot-redeploy disabled)
2025-11-19 12:42:53.914:WARN :oeje11w.WebAppContext:main: Failed startup of context oeje11w.WebAppContext@ffaa6af{/ee11-demo-simple,/ee11-demo-simple,b=null,a=STOPPED,h=oeje11s.SessionHandler@53ce1329{STOPPED}}{file:///C:/testj/jetty-home-12.1.4/jetty-home-12.1.4/base/webapps/ee11-demo-simple.war}
java.lang.NullPointerException: defaultObj
        at java.base/java.util.Objects.requireNonNull(Objects.java:246)
        at java.base/java.util.Objects.requireNonNullElse(Objects.java:295)
        at org.eclipse.jetty.server.Server$ServerContext.getTempDirectory(Server.java:1009)
        at org.eclipse.jetty.server.handler.ContextHandler.makeTempDirectory(ContextHandler.java:998)
        at org.eclipse.jetty.ee11.webapp.WebAppContext.makeTempDirectory(WebAppContext.java:1470)
        at org.eclipse.jetty.ee11.webapp.WebInfConfiguration.resolveTempDirectory(WebInfConfiguration.java:143)
        at org.eclipse.jetty.ee11.webapp.WebInfConfiguration.preConfigure(WebInfConfiguration.java:57)
        at org.eclipse.jetty.ee11.webapp.Configurations.preConfigure(Configurations.java:487)
        at org.eclipse.jetty.ee11.webapp.WebAppContext.preConfigure(WebAppContext.java:457)
        at org.eclipse.jetty.ee11.webapp.WebAppContext.doStart(WebAppContext.java:498)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:92)
        at org.eclipse.jetty.deploy.StandardDeployer.deploy(StandardDeployer.java:118)
        at org.eclipse.jetty.deploy.DeploymentScanner.performActions(DeploymentScanner.java:885)
        at org.eclipse.jetty.deploy.DeploymentScanner.pathsChanged(DeploymentScanner.java:612)
        at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:918)
        at org.eclipse.jetty.util.Scanner.scan(Scanner.java:817)
        at org.eclipse.jetty.util.Scanner.startScanning(Scanner.java:706)
        at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:678)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:92)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:170)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:121)
        at org.eclipse.jetty.deploy.DeploymentScanner.doStart(DeploymentScanner.java:759)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:92)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:170)
        at org.eclipse.jetty.server.Server.start(Server.java:689)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:121)
        at org.eclipse.jetty.server.Handler$Abstract.doStart(Handler.java:545)
        at org.eclipse.jetty.server.Server.doStart(Server.java:630)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:92)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:2124)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:312)
        at org.eclipse.jetty.start.Main.start(Main.java:603)
        at org.eclipse.jetty.start.Main.main(Main.java:82)
2025-11-19 12:42:53.917:INFO :oejs.DefaultSessionIdManager:main: Session workerName=node0
2025-11-19 12:42:53.969:INFO :oejs.AbstractConnector:main: Started oejs.ServerConnector@600d2415{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2025-11-19 12:42:53.972:INFO :oejs.Server:main: Started oejs.Server@2e8c1c9b{STARTING}[12.1.4,sto=0] @272ms


PS C:\testj\jetty-home-12.1.4\jetty-home-12.1.4\base> java '-Djava.io.tmpdir=file:///C:/temp/' -jar ..\start.jar
WARNING: java.io.tmpdir directory does not exist
java.lang.ExceptionInInitializerError
        at java.base/java.nio.file.Files.createTempFile(Files.java:842)
        at org.eclipse.jetty.start.StartArgs.getMainArgs(StartArgs.java:609)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:303)
        at org.eclipse.jetty.start.Main.start(Main.java:603)
        at org.eclipse.jetty.start.Main.main(Main.java:82)
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4: file:///C:/temp/
        at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:191)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:142)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:46)
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:203)
        at java.base/java.nio.file.Path.of(Path.java:148)
        at java.base/java.nio.file.TempFileHelper.<clinit>(TempFileHelper.java:47)
        ... 5 more
java.lang.ExceptionInInitializerError
        at java.base/java.nio.file.Files.createTempFile(Files.java:842)
        at org.eclipse.jetty.start.StartArgs.getMainArgs(StartArgs.java:609)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:303)
        at org.eclipse.jetty.start.Main.start(Main.java:603)
        at org.eclipse.jetty.start.Main.main(Main.java:82)
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 4: file:///C:/temp/
        at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:191)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:142)
        at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:46)
        at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:203)
        at java.base/java.nio.file.Path.of(Path.java:148)
        at java.base/java.nio.file.TempFileHelper.<clinit>(TempFileHelper.java:47)
        ... 5 more

Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
       java -jar $JETTY_HOME/start.jar --help  # for more information


PS C:\testj\jetty-home-12.1.4\jetty-home-12.1.4\base> java '-Djava.io.tmpdir=C:\\temp\\' -jar ..\start.jar
2025-11-19 13:25:33.378:INFO :oejs.Server:main: jetty-12.1.4; built: 2025-11-10T17:42:37.481Z; git: 4137e00793d583cfc4ce76bf607e482178a85597; jvm 25.0.1+8-LTS
2025-11-19 13:25:33.395:INFO :oejd.DeploymentScanner:main: Deployment monitoring of [C:\testj\jetty-home-12.1.4\jetty-home-12.1.4\base\webapps] at intervals 0s (hot-redeploy disabled)
2025-11-19 13:25:33.796:INFO :oeje11w.StandardDescriptorProcessor:main: NO JSP Support for /ee11-demo-simple, did not find org.eclipse.jetty.ee11.jsp.JettyJspServlet
2025-11-19 13:25:33.816:INFO :oejsh.ContextHandler:main: Started oeje11w.WebAppContext@4b8d604b{Servlet 6 Demo Simple WebApp,/ee11-demo-simple,b=file:///C:/temp/jetty-0_0_0_0-8080-ee11-demo-simple_war-_ee11-demo-simple-any-9626780820422732753/webapp/,a=AVAILABLE,h=oeje11s.SessionHandler@5e7cd6cc{STARTED}}{file:///C:/testj/jetty-home-12.1.4/jetty-home-12.1.4/base/webapps/ee11-demo-simple.war}
2025-11-19 13:25:33.847:INFO :oeje11s.ServletContextHandler:main: Started oeje11w.WebAppContext@4b8d604b{Servlet 6 Demo Simple WebApp,/ee11-demo-simple,b=file:///C:/temp/jetty-0_0_0_0-8080-ee11-demo-simple_war-_ee11-demo-simple-any-9626780820422732753/webapp/,a=AVAILABLE,h=oeje11s.SessionHandler@5e7cd6cc{STARTED}}{file:///C:/testj/jetty-home-12.1.4/jetty-home-12.1.4/base/webapps/ee11-demo-simple.war}
2025-11-19 13:25:33.851:INFO :oejs.DefaultSessionIdManager:main: Session workerName=node0
2025-11-19 13:25:33.905:INFO :oejs.AbstractConnector:main: Started oejs.ServerConnector@600d2415{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2025-11-19 13:25:33.909:INFO :oejs.Server:main: Started oejs.Server@3eb91815{STARTING}[12.1.4,sto=0] @536ms

Metadata

Metadata

Assignees

Labels

BugFor general bugs on Jetty sideMicrosoft WindowsFor issues unique to Microsoft Windows

Type

No type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions