From 369b5ef021963461ccc756e5ec5dd53ec1ec70aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Fri, 8 Nov 2024 11:25:02 +0100 Subject: [PATCH] Fixed resolving Windows paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Path.of expects a path using slash as a separator, so old windows paths are invalid for this. We always have to use File first. Signed-off-by: David Matějček --- .../appclient/client/CLIBootstrap.java | 2 +- .../client/acc/ACCStartupContext.java | 2 +- .../src/main/resources/bin/asadmin.bat | 74 +++++++++---------- .../src/main/resources/bin/debug-asadmin.bat | 4 +- .../src/main/resources/bin/startserv.bat | 6 +- .../src/main/resources/bin/stopserv | 17 ++++- .../src/main/resources/bin/stopserv.bat | 58 ++++++++++----- .../main/resources/glassfish/bin/asadmin.bat | 74 +++++++++---------- .../connectors/jms/util/JmsRaUtil.java | 4 +- .../sun/enterprise/admin/cli/AdminMain.java | 4 +- .../admin/launcher/GlassFishMainLauncher.java | 6 +- .../glassfish/ASenvPropertyReader.java | 27 ++----- .../main/jdke/props/EnvToPropsConverter.java | 15 ++-- .../osgi/EmbeddedOSGiGlassFishRuntime.java | 4 +- .../server/CommonClassLoaderServiceImpl.java | 2 +- .../src/main/resources/bin/nadmin.bat | 4 +- .../src/main/resources/bin/startserv.bat | 4 +- .../src/main/resources/config/asenv.bat | 18 ++--- nucleus/distributions/pom.xml | 3 + 19 files changed, 170 insertions(+), 158 deletions(-) diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/CLIBootstrap.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/CLIBootstrap.java index 5f1da73e4ec..437a41b61bb 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/CLIBootstrap.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/CLIBootstrap.java @@ -882,7 +882,7 @@ static class GlassFishInfo { GlassFishInfo() { String asInstallPath = System.getProperty(ENV_VAR_PROP_PREFIX + "AS_INSTALL"); - if (asInstallPath == null || asInstallPath.length() == 0) { + if (asInstallPath == null || asInstallPath.isEmpty()) { throw new IllegalArgumentException("AS_INSTALL == null"); } this.home = new File(asInstallPath); diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCStartupContext.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCStartupContext.java index 0ae12f0f2ef..8d2fcef3299 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCStartupContext.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCStartupContext.java @@ -72,7 +72,7 @@ private static Properties accEnvironment() { "AS_DEF_NODES_PATH", AGENT_ROOT_PROPERTY); Map files = new EnvToPropsConverter(rootDirectory.toPath()).convert(pairs); Properties env = new Properties(); - files.entrySet().forEach(e -> env.put(e.getKey(), e.getValue().getAbsolutePath())); + files.entrySet().forEach(e -> env.put(e.getKey(), e.getValue().getPath())); return env; } diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat index 74e07986b99..aba24752bed 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat @@ -1,37 +1,37 @@ -@echo off -REM -REM Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation -REM Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. -REM -REM This program and the accompanying materials are made available under the -REM terms of the Eclipse Public License v. 2.0, which is available at -REM http://www.eclipse.org/legal/epl-2.0. -REM -REM This Source Code may also be made available under the following Secondary -REM Licenses when the conditions for such availability set forth in the -REM Eclipse Public License v. 2.0 are satisfied: GNU General Public License, -REM version 2 with the GNU Classpath Exception, which is available at -REM https://www.gnu.org/software/classpath/license.html. -REM -REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -REM - -VERIFY OTHER 2>nul -setlocal ENABLEEXTENSIONS -if ERRORLEVEL 0 goto ok -echo "Unable to enable extensions" -exit /B 1 - -:ok -set AS_INSTALL="%~dp0..\glassfish" -call "%AS_INSTALL%\config\asenv.bat" -if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" -goto run - -:UsePath -set JAVA=java - -:run -set ASADMIN_CLASSPATH="%AS_INSTALL%\appserver-cli.jar:%ASADMIN_CLASSPATH%" -%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain %* +@echo off +REM +REM Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation +REM Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. +REM +REM This program and the accompanying materials are made available under the +REM terms of the Eclipse Public License v. 2.0, which is available at +REM http://www.eclipse.org/legal/epl-2.0. +REM +REM This Source Code may also be made available under the following Secondary +REM Licenses when the conditions for such availability set forth in the +REM Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +REM version 2 with the GNU Classpath Exception, which is available at +REM https://www.gnu.org/software/classpath/license.html. +REM +REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +REM + +VERIFY OTHER 2>nul +setlocal ENABLEEXTENSIONS +if ERRORLEVEL 0 goto ok +echo "Unable to enable extensions" +exit /B 1 + +:ok +set AS_INSTALL=%~dp0..\glassfish +call "%AS_INSTALL%\config\asenv.bat" +if "%AS_JAVA%x" == "x" goto UsePath +set JAVA=%AS_JAVA%\bin\java +goto run + +:UsePath +set JAVA=java + +:run +set ASADMIN_CLASSPATH=%AS_INSTALL%\appserver-cli.jar;%ASADMIN_CLASSPATH% +%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin.bat index 5b41772b7b2..8034a959e7a 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin.bat @@ -26,12 +26,12 @@ exit /B 1 set AS_INSTALL="%~dp0..\glassfish" call "%AS_INSTALL%\config\asenv.bat" if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" +set JAVA=%AS_JAVA%\bin\java goto run :UsePath set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%\appserver-cli.jar:%ASADMIN_CLASSPATH%" +set ASADMIN_CLASSPATH=%AS_INSTALL%\appserver-cli.jar:%ASADMIN_CLASSPATH% %JAVA% %ASADMIN_JVM_OPTIONS% -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat index 7db123c3d21..30937189041 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat @@ -23,15 +23,15 @@ echo "Unable to enable extensions" exit /B 1 :ok -set AS_INSTALL="%~dp0.." +set AS_INSTALL=%~dp0.. call "%AS_INSTALL%\config\asenv.bat" if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" +set JAVA=%AS_JAVA%\bin\java goto run :UsePath set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%\appserver-cli.jar:%ASADMIN_CLASSPATH%" +set ASADMIN_CLASSPATH=%AS_INSTALL%\appserver-cli.jar;%ASADMIN_CLASSPATH% %JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain start-domain --verbose %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv b/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv index fee54b1c43f..45b8c4bb85c 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. @@ -16,6 +16,17 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/../glassfish +export AS_INSTALL="$(dirname $(realpath -s $0))/../glassfish" +case "`uname`" in + CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` +esac +. "${AS_INSTALL}/config/asenv.conf" -exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_INSTALL/admin-cli.jar" stop-domain "$@" +JAVA=java +if [ ${AS_JAVA} ]; then + JAVA=${AS_JAVA}/bin/java +fi + +export ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:${ASADMIN_CLASSPATH}" + +"$JAVA" ${ASADMIN_JVM_OPTIONS} --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain stop-domain "$@" diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv.bat index eba403e3a52..7823302ee35 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv.bat @@ -1,20 +1,38 @@ -@echo off -REM -REM Copyright (c) 2024 Contributors to the Eclipse Foundation -REM Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. -REM -REM This program and the accompanying materials are made available under the -REM terms of the Eclipse Public License v. 2.0, which is available at -REM http://www.eclipse.org/legal/epl-2.0. -REM -REM This Source Code may also be made available under the following Secondary -REM Licenses when the conditions for such availability set forth in the -REM Eclipse Public License v. 2.0 are satisfied: GNU General Public License, -REM version 2 with the GNU Classpath Exception, which is available at -REM https://www.gnu.org/software/classpath/license.html. -REM -REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -REM - - -java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\glassfish\admin-cli.jar" stop-domain %* +@echo off +REM +REM Copyright (c) 2024 Contributors to the Eclipse Foundation +REM Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. +REM +REM This program and the accompanying materials are made available under the +REM terms of the Eclipse Public License v. 2.0, which is available at +REM http://www.eclipse.org/legal/epl-2.0. +REM +REM This Source Code may also be made available under the following Secondary +REM Licenses when the conditions for such availability set forth in the +REM Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +REM version 2 with the GNU Classpath Exception, which is available at +REM https://www.gnu.org/software/classpath/license.html. +REM +REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +REM + + +VERIFY OTHER 2>nul +setlocal ENABLEEXTENSIONS +if ERRORLEVEL 0 goto ok +echo "Unable to enable extensions" +exit /B 1 + +:ok +set AS_INSTALL=%~dp0.. +call "%AS_INSTALL%\config\asenv.bat" +if "%AS_JAVA%x" == "x" goto UsePath +set JAVA=%AS_JAVA%\bin\java +goto run + +:UsePath +set JAVA=java + +:run +set ASADMIN_CLASSPATH=%AS_INSTALL%\appserver-cli.jar;%ASADMIN_CLASSPATH% +%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain stop-domain %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin.bat index 0822ceb03b3..4b326a849fb 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin.bat @@ -1,37 +1,37 @@ -@echo off -REM -REM Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation -REM Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. -REM -REM This program and the accompanying materials are made available under the -REM terms of the Eclipse Public License v. 2.0, which is available at -REM http://www.eclipse.org/legal/epl-2.0. -REM -REM This Source Code may also be made available under the following Secondary -REM Licenses when the conditions for such availability set forth in the -REM Eclipse Public License v. 2.0 are satisfied: GNU General Public License, -REM version 2 with the GNU Classpath Exception, which is available at -REM https://www.gnu.org/software/classpath/license.html. -REM -REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -REM - -VERIFY OTHER 2>nul -setlocal ENABLEEXTENSIONS -if ERRORLEVEL 0 goto ok -echo "Unable to enable extensions" -exit /B 1 - -:ok -set AS_INSTALL="%~dp0.." -call "%AS_INSTALL%\config\asenv.bat" -if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" -goto run - -:UsePath -set JAVA=java - -:run -set ASADMIN_CLASSPATH="%AS_INSTALL%\appserver-cli.jar:%ASADMIN_CLASSPATH%" -%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain %* +@echo off +REM +REM Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation +REM Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. +REM +REM This program and the accompanying materials are made available under the +REM terms of the Eclipse Public License v. 2.0, which is available at +REM http://www.eclipse.org/legal/epl-2.0. +REM +REM This Source Code may also be made available under the following Secondary +REM Licenses when the conditions for such availability set forth in the +REM Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +REM version 2 with the GNU Classpath Exception, which is available at +REM https://www.gnu.org/software/classpath/license.html. +REM +REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +REM + +VERIFY OTHER 2>nul +setlocal ENABLEEXTENSIONS +if ERRORLEVEL 0 goto ok +echo "Unable to enable extensions" +exit /B 1 + +:ok +set AS_INSTALL=%~dp0.. +call "%AS_INSTALL%\config\asenv.bat" +if "%AS_JAVA%x" == "x" goto UsePath +set JAVA=%AS_JAVA%\bin\java +goto run + +:UsePath +set JAVA=java + +:run +set ASADMIN_CLASSPATH=%AS_INSTALL%\appserver-cli.jar;%ASADMIN_CLASSPATH% +%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain %* diff --git a/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/util/JmsRaUtil.java b/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/util/JmsRaUtil.java index 7647e291620..7a9f0603ba0 100755 --- a/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/util/JmsRaUtil.java +++ b/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/util/JmsRaUtil.java @@ -342,9 +342,9 @@ public void upgradeIfNecessary() { return; } - final Path imqLib = Path.of(imqLibPath); + final Path imqLib = new File(imqLibPath).toPath(); + final Path deployedDir = new File(installRoot).toPath().resolve(SYSTEM_APP_DIR).resolve(DEFAULT_JMS_ADAPTER); final File imqLibRar = imqLib.resolve(MQ_RAR).toFile(); - final Path deployedDir = Path.of(installRoot).resolve(SYSTEM_APP_DIR).resolve(DEFAULT_JMS_ADAPTER); final String installedMqVersion; final String deployedMqVersion; try { diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java index 092dff67b9c..053f348b5b8 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/AdminMain.java @@ -158,9 +158,9 @@ protected Set getExtensions() { locations.add(modules); } } else { - for (String path : envClasspath.split(":")) { + for (String path : envClasspath.split(File.pathSeparator)) { File file = new File(path); - // nuclesus doesn't contain some files, ie. backup.jar + // nucleus doesn't contain some files, ie. backup.jar if (file.exists()) { locations.add(file); } diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GlassFishMainLauncher.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GlassFishMainLauncher.java index d5ad1ca10f9..4a24640dbce 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GlassFishMainLauncher.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GlassFishMainLauncher.java @@ -17,8 +17,6 @@ package com.sun.enterprise.admin.launcher; -import com.sun.enterprise.universal.io.SmartFile; - import java.io.File; import java.nio.file.Path; import java.util.List; @@ -66,8 +64,8 @@ List getMainClasspath() throws GFLauncherException { @Override List getMainModulepath() throws GFLauncherException { - return List - .of(SmartFile.sanitize(Path.of(getEnvProps().get(INSTALL_ROOT_PROPERTY), "lib", "bootstrap").toFile())); + Path installRoot = new File(getEnvProps().get(INSTALL_ROOT_PROPERTY)).toPath(); + return List.of(installRoot.resolve(Path.of("lib", "bootstrap")).toAbsolutePath().normalize().toFile()); } @Override diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java index e08749952ce..ba881c25445 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReader.java @@ -128,11 +128,12 @@ public String toString() { static class ASenvMap extends HashMap { ASenvMap(File installDir) { new EnvToPropsConverter(installDir.toPath()).convert(ENV_TO_SYS_PROPERTY).entrySet() - .forEach(e -> this.put(e.getKey(), e.getValue().getAbsolutePath())); - put(JAVA_ROOT_PROPERTY, System.getProperty("java.home")); - put(JAVA_ROOT_PROPERTY_ASENV, System.getProperty("java.home")); - put(INSTALL_ROOT_PROPERTY, installDir.getAbsolutePath()); - put(PRODUCT_ROOT_PROPERTY, installDir.getParentFile().getAbsolutePath()); + .forEach(e -> this.put(e.getKey(), e.getValue().getPath())); + String javaHome = new File(System.getProperty("java.home")).toPath().toString(); + put(JAVA_ROOT_PROPERTY, javaHome); + put(JAVA_ROOT_PROPERTY_ASENV, javaHome); + put(INSTALL_ROOT_PROPERTY, installDir.toPath().toString()); + put(PRODUCT_ROOT_PROPERTY, installDir.getParentFile().toPath().toString()); put(HOST_NAME_PROPERTY, getHostname()); } @@ -146,21 +147,5 @@ private static String getHostname() { } return hostname; } - - private static boolean isValidJavaRoot(String javaRootName) { - if (!GFLauncherUtils.ok(javaRootName)) { - return false; - } - - // look for ${javaRootName}/bin/java[.exe] - File f = new File(javaRootName); - - if (GFLauncherUtils.isWindows()) { - f = new File(f, "bin/java.exe"); - } else { - f = new File(f, "bin/java"); - } - return f.exists(); - } } } diff --git a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/props/EnvToPropsConverter.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/props/EnvToPropsConverter.java index 7129887143a..9691c0c9a62 100644 --- a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/props/EnvToPropsConverter.java +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/props/EnvToPropsConverter.java @@ -53,7 +53,7 @@ public EnvToPropsConverter(final Path relativePathAnchor) { * There is no guarantee the file does exist. * * @param envToSys - key is env name, value is system property name. - * @return map of system property names and files. + * @return map of system property names and absolute files. */ public Map convert(final Map envToSys) { final Map files = new HashMap<>(envToSys.size()); @@ -86,7 +86,7 @@ public Map convert(final Map envToSys) { */ public File convert(final String envPropertyName, final String systemPropertyName) { final String value = evaluate(envPropertyName, systemPropertyName); - return value == null ? null : toAbsoluteFile(Path.of(value)); + return value == null ? null : toAbsoluteFile(new File(value)); } @@ -104,13 +104,10 @@ private String evaluate(final String envPropertyName, final String systemPropert } - private File toAbsoluteFile(final Path path) { - File absoluteFile; - if (path.isAbsolute()) { - absoluteFile = path.normalize().toFile(); - } else { - absoluteFile = anchor.resolve(path).normalize().toFile(); + private File toAbsoluteFile(final File file) { + if (file.isAbsolute()) { + return file.toPath().normalize().toFile(); } - return absoluteFile; + return anchor.resolve(file.toPath()).toAbsolutePath().normalize().toFile(); } } diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntime.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntime.java index cdc711bee88..2f092f215fb 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntime.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntime.java @@ -244,14 +244,14 @@ private void setEnv(Properties bootstrapProperties) { File installRoot = new File(installRootValue); new EnvToPropsConverter(installRoot.toPath()).convert(pairs).entrySet() - .forEach(e -> System.setProperty(e.getKey(), e.getValue().getAbsolutePath())); + .forEach(e -> System.setProperty(e.getKey(), e.getValue().getPath())); System.setProperty(INSTALL_ROOT_PROP_NAME, installRootValue); System.setProperty(INSTALL_ROOT_URI_PROP_NAME, installRoot.toURI().toString()); } final String instanceRootValue = bootstrapProperties.getProperty(INSTANCE_ROOT_PROP_NAME); if (instanceRootValue != null && !instanceRootValue.isEmpty()) { - File instanceRoot = new File(instanceRootValue); + File instanceRoot = new File(instanceRootValue).toPath().normalize().toFile(); System.setProperty(INSTANCE_ROOT_PROP_NAME, instanceRoot.getAbsolutePath()); System.setProperty(INSTANCE_ROOT_URI_PROP_NAME, instanceRoot.toURI().toString()); } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImpl.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImpl.java index dc340138559..ccfbb57df8b 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImpl.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImpl.java @@ -185,7 +185,7 @@ private static Path getDerbyDir(File installDir) { if (derbyHomeProperty == null) { return installDir.toPath().resolve(Path.of("..", "javadb")); } - Path derbyHome = Path.of(derbyHomeProperty); + Path derbyHome = new File(derbyHomeProperty).toPath(); if (derbyHome.isAbsolute()) { return derbyHome; } diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat index 50cebcbe7f5..c8300b1325d 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat @@ -23,10 +23,10 @@ echo "Unable to enable extensions" exit /B 1 :ok -set AS_INSTALL="%~dp0.." +set AS_INSTALL=%~dp0.. call "%AS_INSTALL%\config\asenv.bat" if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" +set JAVA=%AS_JAVA%\bin\java goto run :UsePath diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat index add308faae3..55d7b12b106 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat @@ -23,10 +23,10 @@ echo "Unable to enable extensions" exit /B 1 :ok -set AS_INSTALL="%~dp0.." +set AS_INSTALL=%~dp0.. call "%AS_INSTALL%\config\asenv.bat" if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" +set JAVA=%AS_JAVA%\bin\java goto run :UsePath diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat index 444dd9e6307..cda98e747a9 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat @@ -38,14 +38,14 @@ REM directory. REM REM This file uses UTF-8 character encoding. -set AS_DERBY_INSTALL="%AS_INSTALL%\..\javadb" -set AS_IMQ_LIB="%AS_INSTALL%\..\mq\lib" -set AS_IMQ_BIN="%AS_INSTALL%\..\mq\bin" +set AS_DERBY_INSTALL=%AS_INSTALL%\..\javadb +set AS_IMQ_LIB=%AS_INSTALL%\..\mq\lib +set AS_IMQ_BIN=%AS_INSTALL%\..\mq\bin -set AS_CONFIG="%AS_INSTALL%\config" -set AS_DEF_DOMAINS_PATH="%AS_INSTALL%\domains" -set AS_DEF_NODES_PATH="%AS_INSTALL%\nodes" +set AS_CONFIG=%AS_INSTALL%\config +set AS_DEF_DOMAINS_PATH=%AS_INSTALL%\domains +set AS_DEF_NODES_PATH=%AS_INSTALL%\nodes -set ASADMIN_MODULEPATH="%AS_INSTALL%\lib\bootstrap" -set ASADMIN_JVM_OPTIONS="-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -set ASADMIN_CLASSPATH="%AS_INSTALL%\admin-cli.jar:%AS_INSTALL%\lib\asadmin\*:%AS_INSTALL%\modules\admin-util.jar:%AS_INSTALL%\modules\backup.jar:%AS_INSTALL%\modules\cluster-common.jar:%AS_INSTALL%\modules\config-api.jar:%AS_INSTALL%\modules\config-types.jar:%AS_INSTALL%\modules\common-util.jar:%AS_INSTALL%\modules\glassfish-api.jar:%AS_INSTALL%\modules\hk2.jar:%AS_INSTALL%\modules\hk2-config-generator.jar:%AS_INSTALL%\modules\jackson-core.jar:%AS_INSTALL%\modules\jakarta.activation-api.jar:%AS_INSTALL%\modules\jakarta.validation-api.jar:%AS_INSTALL%\modules\jakarta.xml.bind-api.jar:%AS_INSTALL%\modules\jaxb-osgi.jar:%AS_INSTALL%\modules\jettison.jar:%AS_INSTALL%\modules\launcher.jar:%AS_INSTALL%\modules\mimepull.jar" +set ASADMIN_MODULEPATH=%AS_INSTALL%\lib\bootstrap +set ASADMIN_JVM_OPTIONS=-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager +set ASADMIN_CLASSPATH=%AS_INSTALL%\admin-cli.jar;%AS_INSTALL%\lib\asadmin\*;%AS_INSTALL%\modules\admin-util.jar;%AS_INSTALL%\modules\backup.jar;%AS_INSTALL%\modules\cluster-common.jar;%AS_INSTALL%\modules\config-api.jar;%AS_INSTALL%\modules\config-types.jar;%AS_INSTALL%\modules\common-util.jar;%AS_INSTALL%\modules\glassfish-api.jar;%AS_INSTALL%\modules\hk2.jar;%AS_INSTALL%\modules\hk2-config-generator.jar;%AS_INSTALL%\modules\jackson-core.jar;%AS_INSTALL%\modules\jakarta.activation-api.jar;%AS_INSTALL%\modules\jakarta.validation-api.jar;%AS_INSTALL%\modules\jakarta.xml.bind-api.jar;%AS_INSTALL%\modules\jaxb-osgi.jar;%AS_INSTALL%\modules\jettison.jar;%AS_INSTALL%\modules\launcher.jar;%AS_INSTALL%\modules\mimepull.jar diff --git a/nucleus/distributions/pom.xml b/nucleus/distributions/pom.xml index 4d32ee32f56..a7f38923bd7 100644 --- a/nucleus/distributions/pom.xml +++ b/nucleus/distributions/pom.xml @@ -135,6 +135,9 @@ ${nadmin.executable} ${create-domain.args} + true + + true