From 5be8ba60ac54322136638a8a6818de29c1f751af Mon Sep 17 00:00:00 2001 From: Marco Collovati Date: Fri, 4 Dec 2026 12:13:13 +0000 Subject: [PATCH] fix(devloop): start forked servers on the chosen JDK when JDK_HOME is set Payara Server's Maven plugin reads JDK_HOME before JAVA_HOME, so an inherited JDK_HOME started the server on another JDK. The daemon now sets JDK_HOME to the same JDK as JAVA_HOME. --- flow-devloop-daemon/README.md | 5 +++++ .../com/vaadin/flow/devloop/daemon/MavenGoalRuntime.java | 5 +++++ .../com/vaadin/flow/devloop/daemon/MavenGoalRuntimeTest.java | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/flow-devloop-daemon/README.md b/flow-devloop-daemon/README.md index af52b1fa549..3bbbdbc8ebb 100644 --- a/flow-devloop-daemon/README.md +++ b/flow-devloop-daemon/README.md @@ -275,11 +275,16 @@ process: ``` JAVA_HOME= +JDK_HOME= mvnw -B -ntp -nsu [-f /pom.xml -pl : -am] -Dmaven.test.skip=true org.wildfly.plugins:wildfly-maven-plugin::run -Dwildfly.javaOpts=" " ``` +`JDK_HOME` is there because a plugin can read it before `JAVA_HOME`: Payara +Server's does, so a `JDK_HOME` the daemon inherited would otherwise start the +server on another JDK, which may refuse the loop's flags. + Every one of them deploys the packaged WAR rather than the module's own output, so one has to exist. WildFly's goal declares `@Execute(phase = PACKAGE)` and forks the packaging itself, which is why the command above names no phase, diff --git a/flow-devloop-daemon/src/main/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntime.java b/flow-devloop-daemon/src/main/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntime.java index 6256ce3ccc4..fa3d229e1b7 100644 --- a/flow-devloop-daemon/src/main/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntime.java +++ b/flow-devloop-daemon/src/main/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntime.java @@ -178,6 +178,11 @@ public Invocation invocation(Launch.Project project, List jvmFlags, // JetBrains Runtime that Jvm chose is the one the application runs on - // and with it, enhanced class redefinition. environment.put("JAVA_HOME", launch.appJvm().home().toString()); + // The same for JDK_HOME, which a forked server's plugin can read + // before JAVA_HOME. Payara Server's does, so an inherited JDK_HOME - + // a CI agent sets one to its own Java 8 - started the server on that + // JDK, which refused the loop's --add-opens and never started. + environment.put("JDK_HOME", launch.appJvm().home().toString()); // And first on the PATH, for the forked servers: a plugin that is given // no java of its own runs the first one it finds there, whatever // JAVA_HOME says. Payara Micro's does, and on Linux that was a JDK diff --git a/flow-devloop-daemon/src/test/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntimeTest.java b/flow-devloop-daemon/src/test/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntimeTest.java index 923e8c9d36c..465dd77d94e 100644 --- a/flow-devloop-daemon/src/test/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntimeTest.java +++ b/flow-devloop-daemon/src/test/java/com/vaadin/flow/devloop/daemon/MavenGoalRuntimeTest.java @@ -445,6 +445,10 @@ void invocation_forkedServerInAReactor_packsTheFlagsIntoItsParameter() .startsWith(launch.appJvm().home().resolve("bin") + File.pathSeparator), invocation.environment().get("PATH")); + // Payara Server's plugin reads JDK_HOME before JAVA_HOME, so an + // inherited one must not pick another JDK. + assertEquals(launch.appJvm().home().toString(), + invocation.environment().get("JDK_HOME")); assertFalse(Files.exists(launch.reactor().app().classesDir() .resolve("hotswap-agent.properties"))); }