From ad12f1997bfdc29774b9ebaf401db7a12725c447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Sun, 6 Oct 2024 22:54:12 +0200 Subject: [PATCH 01/38] Improved Derby and CommonClassLoader initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček # Conflicts: # nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImpl.java --- .../admin/cli/optional/DatabaseCommand.java | 8 +- .../client/acc/ACCStartupContext.java | 14 +- .../connectors/util/DriverLoader.java | 6 +- .../util/SystemPropertyConstants.java | 3 + .../bootstrap/cfg/BootstrapKeys.java | 3 + .../server/CommonClassLoaderServiceImpl.java | 164 +++++++----------- 6 files changed, 83 insertions(+), 115 deletions(-) diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java index 1e705e0e588..8c53eeb22a0 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java @@ -28,7 +28,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; -import static com.sun.enterprise.util.SystemPropertyConstants.DERBY_ROOT_PROPERTY; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; import static com.sun.enterprise.util.SystemPropertyConstants.JAVA_ROOT_PROPERTY; @@ -77,7 +77,7 @@ protected void prepareProcessExecutor() throws Exception { } javaHome = new File(getSystemProperty(JAVA_ROOT_PROPERTY)); - dbLocation = new File(getSystemProperty(DERBY_ROOT_PROPERTY)); + dbLocation = new File(getSystemProperty(DERBY_ROOT_PROP_NAME)); checkIfDbInstalled(dbLocation); sClasspath.add(new File(installRoot, "lib/asadmin/cli-optional.jar")); @@ -137,7 +137,7 @@ protected String[] pingDatabaseCmd(boolean bRedirect) throws Exception { "com.sun.enterprise.admin.cli.optional.DerbyControl", "ping", - dbHost, dbPort, Boolean.valueOf(bRedirect).toString() }; + dbHost, dbPort, Boolean.toString(bRedirect) }; } @@ -148,7 +148,7 @@ protected String[] pingDatabaseCmd(boolean bRedirect) throws Exception { "com.sun.enterprise.admin.cli.optional.DerbyControl", "ping", - dbHost, dbPort, Boolean.valueOf(bRedirect).toString() }; + dbHost, dbPort, Boolean.toString(bRedirect) }; } /** 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 e6e4e6e77a1..03e17819e8d 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 @@ -30,6 +30,9 @@ import org.jvnet.hk2.annotations.Service; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_PROP_NAME; + /** * Start-up context for the ACC. Note that this context is used also for * Java Web Start launches. @@ -40,8 +43,6 @@ @Singleton public class ACCStartupContext extends StartupContext { - private static final String DERBY_ROOT_PROPERTY = "AS_DERBY_INSTALL"; - public ACCStartupContext() { super(accEnvironment()); } @@ -53,11 +54,12 @@ public ACCStartupContext() { * @return */ private static Properties accEnvironment() { - final Properties environment = AsenvConf.parseAsEnv(getRootDirectory()).toProperties(); - environment.setProperty("com.sun.aas.installRoot", getRootDirectory().getAbsolutePath()); - final File javadbDir = new File(getRootDirectory().getParentFile(), "javadb"); + final File rootDirectory = getRootDirectory(); + final Properties environment = AsenvConf.parseAsEnv(rootDirectory).toProperties(); + environment.setProperty(INSTALL_ROOT_PROP_NAME, rootDirectory.getAbsolutePath()); + final File javadbDir = new File(rootDirectory.getParentFile(), "javadb"); if (javadbDir.isDirectory()) { - environment.setProperty(DERBY_ROOT_PROPERTY, javadbDir.getAbsolutePath()); + environment.setProperty(DERBY_ROOT_PROP_NAME, javadbDir.getAbsolutePath()); } return environment; } diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/DriverLoader.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/DriverLoader.java index 4de401edcf7..5ae19193200 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/DriverLoader.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/DriverLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -48,6 +48,8 @@ import org.jvnet.hk2.annotations.Service; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; + /** * Driver Loader to load the jdbc drivers and get driver/datasource classnames * by introspection. @@ -492,7 +494,7 @@ private boolean isVendorSpecific(File f, String dbVendor, String className, private List getJdbcDriverLocations() { List jarFileLocations = new ArrayList<>(); - jarFileLocations.add(getLocation(SystemPropertyConstants.DERBY_ROOT_PROPERTY)); + jarFileLocations.add(getLocation(DERBY_ROOT_PROP_NAME)); jarFileLocations.add(getLocation(SystemPropertyConstants.INSTALL_ROOT_PROPERTY)); jarFileLocations.add(getLocation(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY)); return jarFileLocations; diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java index 7fc7dee7df7..efd073d8721 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/SystemPropertyConstants.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -20,6 +21,7 @@ import java.io.File; +// FIXME: Visit BootstrapKeys and remove duplicit constants here public class SystemPropertyConstants { /** @@ -177,6 +179,7 @@ public class SystemPropertyConstants { public static final String JDMK_HOME_PROPERTY = "com.sun.aas.jdmkHome"; + @Deprecated public static final String DERBY_ROOT_PROPERTY = "com.sun.aas.derbyRoot"; /** Java ES Monitoring Framework install directory */ diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java index 0cba7944e22..8b2cfbd92fd 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java @@ -72,6 +72,9 @@ public final class BootstrapKeys { public static final String AUTO_DELETE = "org.glassfish.embeddable.autoDelete"; + public static final String DERBY_ROOT_PROP_NAME = "com.sun.aas.derbyRoot"; + + private BootstrapKeys() { } } 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 54b4bd5485e..da264b68132 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 @@ -17,21 +17,18 @@ package com.sun.enterprise.v3.server; -import com.sun.enterprise.module.bootstrap.StartupContext; -import com.sun.enterprise.util.SystemPropertyConstants; - import jakarta.inject.Inject; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Properties; +import java.util.Objects; import java.util.function.Predicate; import java.util.jar.JarFile; import java.util.jar.Manifest; @@ -46,6 +43,10 @@ import org.glassfish.kernel.KernelLoggerInfo; import org.jvnet.hk2.annotations.Service; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_PROP_NAME; +import static java.util.logging.Level.CONFIG; + /** * This class is responsible for setting up Common Class Loader. As the * name suggests, Common Class Loader is common to all deployed applications. @@ -70,87 +71,74 @@ */ @Service public class CommonClassLoaderServiceImpl implements PostConstruct { + + private static final Logger LOG = KernelLoggerInfo.getLogger(); + /** * The common classloader. */ private GlassfishUrlClassLoader commonClassLoader; @Inject - APIClassLoaderServiceImpl acls; + private APIClassLoaderServiceImpl acls; @Inject - ServerEnvironment env; + private ServerEnvironment env; - final static Logger logger = KernelLoggerInfo.getLogger(); - private ClassLoader APIClassLoader; + private ClassLoader apiClassLoader; private String commonClassPath = ""; private static final String SERVER_EXCLUDED_ATTR_NAME = "GlassFish-ServerExcluded"; @Override public void postConstruct() { - APIClassLoader = acls.getAPIClassLoader(); - assert (APIClassLoader != null); + apiClassLoader = Objects.requireNonNull(acls.getAPIClassLoader(), "API ClassLoader is null!"); createCommonClassLoader(); } private void createCommonClassLoader() { List cpElements = new ArrayList<>(); File domainDir = env.getInstanceRoot(); - // I am forced to use System.getProperty, as there is no API that makes - // the installRoot available. Sad, but true. Check dev forum on this. - final String installRoot = System.getProperty( - SystemPropertyConstants.INSTALL_ROOT_PROPERTY); - - // See https://glassfish.dev.java.net/issues/show_bug.cgi?id=5872 - // In case of embedded GF, we may not have an installRoot. - if (installRoot!=null) { - File installDir = new File(installRoot); - File installLibPath = new File(installDir, "lib"); - if (installLibPath.isDirectory()) { - Collections.addAll(cpElements, - installLibPath.listFiles(new CompiletimeJarFileFilter())); - } - } else { - logger.logp(Level.WARNING, "CommonClassLoaderServiceImpl", - "createCommonClassLoader", - KernelLoggerInfo.systemPropertyNull, - SystemPropertyConstants.INSTALL_ROOT_PROPERTY); + final String installRoot = System.getProperty(INSTALL_ROOT_PROP_NAME); + if (installRoot == null) { + throw new IllegalStateException("The system property is not set: " + INSTALL_ROOT_PROP_NAME); + } + File installDir = new File(installRoot); + File installLibDir = new File(installDir, "lib"); + if (installLibDir.isDirectory()) { + Collections.addAll(cpElements, installLibDir.listFiles(new CompiletimeJarFileFilter())); } - File domainClassesDir = new File(domainDir, "lib/classes/"); // NOI18N + final File domainLibDir = new File(domainDir, "lib"); + final File domainClassesDir = new File(domainLibDir, "classes"); if (domainClassesDir.exists()) { cpElements.add(domainClassesDir); } - final File domainLib = new File(domainDir, "lib/"); // NOI18N - if (domainLib.isDirectory()) { - Collections.addAll(cpElements, - domainLib.listFiles(new JarFileFilter())); + if (domainLibDir.isDirectory()) { + Collections.addAll(cpElements, domainLibDir.listFiles(new JarFileFilter())); } - // See issue https://glassfish.dev.java.net/issues/show_bug.cgi?id=13612 - // We no longer add derby jars to launcher class loader, we add them to common class loader instead. - cpElements.addAll(findDerbyClient()); + cpElements.addAll(findDerbyJars(installDir)); List urls = new ArrayList<>(); - for (File f : cpElements) { + for (File file : cpElements) { try { - urls.add(f.toURI().toURL()); - } catch (MalformedURLException e) { - logger.log(Level.WARNING, KernelLoggerInfo.invalidClassPathEntry, - new Object[] {f, e}); + urls.add(file.toURI().toURL()); + } catch (IOException e) { + LOG.log(Level.WARNING, KernelLoggerInfo.invalidClassPathEntry, new Object[] {file, e}); } } commonClassPath = urlsToClassPath(urls.stream()); if (urls.isEmpty()) { - logger.logp(Level.FINE, "CommonClassLoaderManager", + LOG.logp(Level.FINE, "CommonClassLoaderManager", "Skipping creation of CommonClassLoader as there are no libraries available", "urls = {0}", urls); } else { // Skip creation of an unnecessary classloader in the hierarchy, // when all it would have done was to delegate up. - commonClassLoader = new GlassfishUrlClassLoader(urls.toArray(URL[]::new), APIClassLoader); + commonClassLoader = new GlassfishUrlClassLoader(urls.toArray(URL[]::new), apiClassLoader); + LOG.log(Level.FINE, "Created common classloader: {0}", commonClassLoader); } } public ClassLoader getCommonClassLoader() { - return commonClassLoader != null ? commonClassLoader : APIClassLoader; + return commonClassLoader == null ? apiClassLoader : commonClassLoader; } /** @@ -160,7 +148,7 @@ public ClassLoader getCommonClassLoader() { */ public void addToClassPath(URL url) { if (commonClassLoader == null) { - commonClassLoader = new GlassfishUrlClassLoader(new URL[] {url}, APIClassLoader); + commonClassLoader = new GlassfishUrlClassLoader(new URL[] {url}, apiClassLoader); } else { commonClassLoader.addURL(url); } @@ -180,87 +168,57 @@ private static String urlsToClassPath(Stream urls) { .collect(Collectors.joining(File.pathSeparator)); } - private List findDerbyClient() { - final String DERBY_HOME_PROP = "AS_DERBY_INSTALL"; - StartupContext startupContext = env.getStartupContext(); - Properties arguments = null; + private List findDerbyJars(File installDir) { + Path derbyHome = getDerbyDir(installDir); + LOG.log(CONFIG, "Using derby home: {0}", derbyHome); - if (startupContext != null) { - arguments = startupContext.getArguments(); + final File derbyLib = derbyHome.resolve("lib").toFile(); + if (!derbyLib.exists()) { + LOG.info(KernelLoggerInfo.cantFindDerby); + return Collections.emptyList(); } - String derbyHome = null; - - if (arguments != null) { - derbyHome = arguments.getProperty(DERBY_HOME_PROP, - System.getProperty(DERBY_HOME_PROP)); - } + return Arrays + .asList(derbyLib.listFiles((dir, name) -> name.endsWith(".jar") && !name.startsWith("derbyLocale_"))); + } - File derbyLib = null; - if (derbyHome != null) { - derbyLib = new File(derbyHome, "lib"); + private static Path getDerbyDir(File installDir) { + String derbyHomeProperty = System.getProperty(DERBY_ROOT_PROP_NAME); + if (derbyHomeProperty == null) { + return installDir.toPath().resolve(Path.of("..", "javadb")); } - if (derbyLib == null || !derbyLib.exists()) { - logger.info(KernelLoggerInfo.cantFindDerby); - return Collections.emptyList(); + Path derbyHome = Path.of(derbyHomeProperty); + if (derbyHome.isAbsolute()) { + return derbyHome; } - - return Arrays.asList(derbyLib.listFiles(new FilenameFilter(){ - @Override - public boolean accept(File dir, String name) { - // Include only files having .jar extn and exclude all localisation jars, because they are - // already mentioned in the Class-Path header of the main jars - return (name.endsWith(".jar") && !name.startsWith("derbyLocale_")); - } - })); + return new File(installDir, "config").toPath().resolve(derbyHome); } private static class JarFileFilter implements FilenameFilter { - private final String JAR_EXT = ".jar"; // NOI18N @Override public boolean accept(File dir, String name) { - return name.endsWith(JAR_EXT); + return name.endsWith(".jar"); } } private static class CompiletimeJarFileFilter extends JarFileFilter { - /* - * See https://glassfish.dev.java.net/issues/show_bug.cgi?id=9526 - */ + @Override - public boolean accept(File dir, String name) - { + public boolean accept(File dir, String name) { if (super.accept(dir, name)) { File file = new File(dir, name); - JarFile jar = null; - try - { - jar = new JarFile(file); + try (JarFile jar = new JarFile(file)) { Manifest manifest = jar.getManifest(); if (manifest != null) { - String exclude = manifest.getMainAttributes(). - getValue(SERVER_EXCLUDED_ATTR_NAME); - if (exclude != null && exclude.equalsIgnoreCase("true")) { + String exclude = manifest.getMainAttributes().getValue(SERVER_EXCLUDED_ATTR_NAME); + if ("true".equalsIgnoreCase(exclude)) { return false; } } - } - catch (IOException e) - { - logger.log(Level.WARNING, KernelLoggerInfo.exceptionProcessingJAR, + } catch (IOException e) { + LOG.log(Level.WARNING, KernelLoggerInfo.exceptionProcessingJAR, new Object[] {file.getAbsolutePath(), e}); - } finally { - try - { - if (jar != null) { - jar.close(); - } - } - catch (IOException e) - { - // ignore - } } return true; } From d5ae053c8642c2cbba4d8b32058d1f71d8ee0e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 21:30:04 +0200 Subject: [PATCH 02/38] Simplified CommonClassLoaderServiceImplTest - using HK2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../CommonClassLoaderServiceImplTest.java | 155 ++---------------- .../v3/services/impl/GrizzlyProxyTest.java | 4 +- .../kernel/test/KernelJUnitExtension.java | 15 +- .../tests/utils/junit/ExcludeClasses.java | 4 +- .../tests/utils/junit/HK2ClasssVisitor.java | 4 +- .../tests/utils/junit/JUnitSystem.java | 51 ++++++ 6 files changed, 86 insertions(+), 147 deletions(-) create mode 100644 nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/JUnitSystem.java diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImplTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImplTest.java index d72fd6f10a6..e424c480e49 100644 --- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImplTest.java +++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/server/CommonClassLoaderServiceImplTest.java @@ -15,52 +15,35 @@ */ package com.sun.enterprise.v3.server; -import com.sun.enterprise.module.bootstrap.StartupContext; +import jakarta.inject.Inject; import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.file.Path; -import org.glassfish.api.admin.RuntimeType; import org.glassfish.api.admin.ServerEnvironment; -import org.junit.jupiter.api.BeforeEach; +import org.glassfish.main.core.kernel.test.KernelJUnitExtension; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.stringContainsInOrder; +@ExtendWith(KernelJUnitExtension.class) public class CommonClassLoaderServiceImplTest { - private int loadClassCalls; - private int getResourceCalls; + @Inject + private CommonClassLoaderServiceImpl commonCLService; - CommonClassLoaderServiceImpl commonCLService; - MockServerEnvironment serverEnv; - - @BeforeEach - public void setUp() { - commonCLService = new CommonClassLoaderServiceImpl(); - commonCLService.acls = new APIClassLoaderServiceImpl() { - @Override - public ClassLoader getAPIClassLoader() { - return new URLClassLoader(new URL[0], null); - } - - }; - serverEnv = new MockServerEnvironment(); - commonCLService.env = serverEnv; - } + @Inject + private ServerEnvironment env; @Test - public void testAddingUrlWithNoInitialUrls() throws MalformedURLException, ClassNotFoundException { - commonCLService.postConstruct(); - + public void testAddingUrlWithNoInitialUrls() throws Exception { final String classesPath = "target/test-additional-classes/"; commonCLService.addToClassPath(new File(classesPath).toURI().toURL()); -// we need to retrieve the classloader after adding URLs, otherwise we + // we need to retrieve the classloader after adding URLs, otherwise we // would get its parent because of an optimization in the service final ClassLoader commonClassLoader = commonCLService.getCommonClassLoader(); commonClassLoader.loadClass(CommonClassLoaderServiceImplTestAdditionalClass.class.getName()); @@ -68,10 +51,7 @@ public void testAddingUrlWithNoInitialUrls() throws MalformedURLException, Class } @Test - public void testAddingUrlWithInitialUrl() throws MalformedURLException, ClassNotFoundException { - final String domainDir = "target/test-domain"; - serverEnv.setInstanceRoot(new File(domainDir)); - commonCLService.postConstruct(); + public void testAddingUrlWithInitialUrl() throws Exception { // the classloader should already be the one we want, initialized with classes in domain/lib/classes final ClassLoader commonClassLoader = commonCLService.getCommonClassLoader(); @@ -80,112 +60,9 @@ public void testAddingUrlWithInitialUrl() throws MalformedURLException, ClassNot commonClassLoader.loadClass(CommonClassLoaderServiceImplTestAdditionalClass.class.getName()); commonClassLoader.loadClass(CommonClassLoaderServiceImplTestDomainClass.class.getName()); - assertThat(commonCLService.getCommonClassPath(), containsString(new File(classesPath).getAbsolutePath())); - assertThat(commonCLService.getCommonClassPath(), containsString(Path.of(domainDir,"lib","classes").toAbsolutePath().toString())); - } - - static class MockServerEnvironment implements ServerEnvironment { - - File instanceRoot; - - @Override - public File getInstanceRoot() { - return instanceRoot; - } - - public void setInstanceRoot(File instanceRoot) { - this.instanceRoot = instanceRoot; - } - - @Override - public StartupContext getStartupContext() { - return null; - } - - @Override - public File getConfigDirPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getLibPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getApplicationRepositoryPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getApplicationStubPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getApplicationCompileJspPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getApplicationGeneratedXMLPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getApplicationEJBStubPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getApplicationPolicyFilePath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getApplicationAltDDPath() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getMasterPasswordFile() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getJKS() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public File getTrustStore() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Status getStatus() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public RuntimeType getRuntimeType() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getInstanceName() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isInstance() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public boolean isDas() { - throw new UnsupportedOperationException("Not supported yet."); - } - + assertThat(commonCLService.getCommonClassPath(), + stringContainsInOrder( + env.getInstanceRoot().toPath().resolve(Path.of("lib", "classes")).toString(), + new File(classesPath).getAbsolutePath())); } } diff --git a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/services/impl/GrizzlyProxyTest.java b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/services/impl/GrizzlyProxyTest.java index 8c19131cb23..6013939b50a 100644 --- a/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/services/impl/GrizzlyProxyTest.java +++ b/nucleus/core/kernel/src/test/java/com/sun/enterprise/v3/services/impl/GrizzlyProxyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -149,7 +149,7 @@ public void testInitAddressWithInvalidVal() throws IOException { private static void validateLogContents(String[] messages) throws IOException { try (BufferedReader reader = new BufferedReader(new FileReader(TEST_LOG))) { - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { buf.append(line); diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/KernelJUnitExtension.java b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/KernelJUnitExtension.java index b99dd6420f5..8e78a2b4605 100644 --- a/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/KernelJUnitExtension.java +++ b/nucleus/core/kernel/src/test/java/org/glassfish/main/core/kernel/test/KernelJUnitExtension.java @@ -1,6 +1,5 @@ /* - * Copyright (c) 2021 Eclipse Foundation and/or its affiliates. All rights reserved. - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -18,11 +17,15 @@ package org.glassfish.main.core.kernel.test; import com.sun.enterprise.admin.util.InstanceStateService; +import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; +import com.sun.enterprise.util.io.FileUtils; import com.sun.enterprise.v3.admin.ObjectInputStreamWithServiceLocator; +import java.nio.file.Path; import java.util.Set; import org.glassfish.tests.utils.junit.HK2JUnit5Extension; +import org.glassfish.tests.utils.junit.JUnitSystem; import org.junit.jupiter.api.extension.ExtensionContext; @@ -33,6 +36,14 @@ */ public class KernelJUnitExtension extends HK2JUnit5Extension { + static { + Path installRoot = JUnitSystem.detectBasedir(); + Path instanceRoot = installRoot.resolve(Path.of("target", "test-domain")); + FileUtils.mkdirsMaybe(instanceRoot.toFile()); + System.setProperty(BootstrapKeys.INSTALL_ROOT_PROP_NAME, installRoot.toString()); + System.setProperty(BootstrapKeys.INSTANCE_ROOT_PROP_NAME, instanceRoot.toString()); + } + @Override protected String getDomainXml(final Class testClass) { return "DomainTest.xml"; diff --git a/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/ExcludeClasses.java b/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/ExcludeClasses.java index fa7415326c0..0a0e49e3a00 100644 --- a/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/ExcludeClasses.java +++ b/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/ExcludeClasses.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -43,5 +43,5 @@ * * @return array iof ignored classes */ - public Class[] value(); + Class[] value(); } diff --git a/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/HK2ClasssVisitor.java b/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/HK2ClasssVisitor.java index ee09b870346..dff527ab80e 100644 --- a/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/HK2ClasssVisitor.java +++ b/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/HK2ClasssVisitor.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation. * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, 2023 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -50,7 +50,7 @@ class HK2ClasssVisitor extends ClassVisitor { * @param locator * @param excludedClasses */ - public HK2ClasssVisitor(final ServiceLocator locator, final Set> excludedClasses) { + HK2ClasssVisitor(final ServiceLocator locator, final Set> excludedClasses) { super(ASM9); this.locator = locator; this.excludedClasses = excludedClasses.stream().map(Class::getName).collect(Collectors.toSet()); diff --git a/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/JUnitSystem.java b/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/JUnitSystem.java new file mode 100644 index 00000000000..4243d63c58b --- /dev/null +++ b/nucleus/test-utils/src/main/java/org/glassfish/tests/utils/junit/JUnitSystem.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.tests.utils.junit; + +import java.io.File; +import java.nio.file.Path; + +/** + * Helper class to make possible running tests the same way in Maven as in Eclipse IDE, probably + * also other environments. + */ +public final class JUnitSystem { + + private JUnitSystem() { + // utility class + } + + /** + * Useful for a heuristic inside Eclipse and other environments. + * + * @return Absolute path to the glassfish directory. + */ + public static Path detectBasedir() { + // Maven would set this property. + final String basedir = System.getProperty("basedir"); + if (basedir != null) { + return new File(basedir).toPath().toAbsolutePath(); + } + // Maybe we are standing in the basedir. + final File target = new File("target"); + if (target.exists()) { + return target.toPath().toAbsolutePath().getParent(); + } + // Eclipse IDE sometimes uses target as the current dir. + return new File(".").toPath().toAbsolutePath().getParent(); + } +} From 51290ba08a77b86408820b202b4c1ca310b0acfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 21:44:09 +0200 Subject: [PATCH 03/38] ASenvPropertyReader now supports trivial bash expressions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - useful when you use exports rather than editing asenv.conf Signed-off-by: David Matějček --- .../glassfish/ASenvPropertyReader.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 58f0b13af9f..b238b6f312d 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 @@ -279,6 +279,25 @@ private void setProperty(String line) { if (pos > 0) { String lhs = (line.substring(0, pos)).trim(); String rhs = (line.substring(pos + 1)).trim(); + String rhsExpression = "\"${" + lhs + ":-"; + if (!GFLauncherUtils.isWindows() && rhs.contains(rhsExpression) && rhs.contains("}")) { + String env = System.getenv(lhs); + int start = rhs.indexOf(rhsExpression); + int end = rhs.indexOf('}'); + StringBuilder value = new StringBuilder(); + if (start > 0) { + value.append(rhs.subSequence(0, start)); + } + if (env == null) { + value.append('"').append(rhs.substring(start + rhsExpression.length(), end)); + } else { + value.append(env); + } + if (rhs.length() > end + 1) { + value.append(rhs.substring(end + 1)); + } + rhs = value.toString(); + } if (GFLauncherUtils.isWindows()) { // trim off the "set " From 31b04f0d2470e274ecf9a1f6e56870c969c35ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 21:47:07 +0200 Subject: [PATCH 04/38] asenv.conf now supports external env properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../src/main/resources/config/asenv.conf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf index 2f6bffd19df..53793cb53cb 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf @@ -37,10 +37,10 @@ # # This file uses UTF-8 character encoding. -AS_IMQ_LIB="../../mq/lib" -AS_IMQ_BIN="../../mq/bin" -AS_CONFIG="../config" -AS_INSTALL=".." -AS_DEF_DOMAINS_PATH="../domains" -AS_DEF_NODES_PATH="../nodes" -AS_DERBY_INSTALL="../../javadb" +AS_IMQ_LIB="${AS_IMQ_LIB:-../../mq/lib}" +AS_IMQ_BIN="${AS_IMQ_BIN:-../../mq/bin}" +AS_CONFIG="${AS_CONFIG:-../config}" +AS_INSTALL="${AS_INSTALL:-..}" +AS_DEF_DOMAINS_PATH="${AS_DEF_DOMAINS_PATH:-../domains}" +AS_DEF_NODES_PATH="${AS_DEF_NODES_PATH:-../nodes}" +AS_DERBY_INSTALL="${AS_DERBY_INSTALL:-../../javadb}" From 87f500f015c08b9e9810e1614da3221cb1721b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 21:57:27 +0200 Subject: [PATCH 05/38] Disabled automatic class path in manifest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Caused parallel classloader architecture to osgi, so ie. default-web.xml filter for JSPC was worthless, dependencies were always found somehow. - However it is still useful for jar files with Main executed from command line. Signed-off-by: David Matějček --- appserver/admin/cli/pom.xml | 4 +++- nucleus/admin/cli/pom.xml | 3 +++ nucleus/core/bootstrap/pom.xml | 5 +---- nucleus/parent/pom.xml | 5 ++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/appserver/admin/cli/pom.xml b/appserver/admin/cli/pom.xml index 6a1157fea28..fc0d76684bc 100755 --- a/appserver/admin/cli/pom.xml +++ b/appserver/admin/cli/pom.xml @@ -47,7 +47,7 @@ org.glassfish.main.admin admin-cli - ${project.parent.version} + ${project.version} @@ -60,6 +60,8 @@ org.glassfish.admin.cli.AsadminMain true + custom + ${artifact.artifactId}.${artifact.extension} ../../modules diff --git a/nucleus/admin/cli/pom.xml b/nucleus/admin/cli/pom.xml index acd86a1f1b0..c963b41fcda 100755 --- a/nucleus/admin/cli/pom.xml +++ b/nucleus/admin/cli/pom.xml @@ -187,6 +187,9 @@ com.sun.enterprise.admin.cli.AdminMain + true + custom + ${artifact.artifactId}.${artifact.extension} ../lib/bootstrap/glassfish-jul-extension.jar jakarta.annotation-api.jar jakarta.xml.bind-api.jar diff --git a/nucleus/core/bootstrap/pom.xml b/nucleus/core/bootstrap/pom.xml index 7bb611c1042..58dde84f9f2 100755 --- a/nucleus/core/bootstrap/pom.xml +++ b/nucleus/core/bootstrap/pom.xml @@ -121,10 +121,7 @@ - true - custom - ${artifact.artifactId}.${artifact.extension} - com.sun.enterprise.glassfish.bootstrap.ASMain + com.sun.enterprise.glassfish.bootstrap.GlassFishMain diff --git a/nucleus/parent/pom.xml b/nucleus/parent/pom.xml index 30c6e3f2213..5f747eb70f6 100644 --- a/nucleus/parent/pom.xml +++ b/nucleus/parent/pom.xml @@ -2019,10 +2019,9 @@ maven-jar-plugin + true - true - custom - ${artifact.artifactId}.${artifact.extension} + false ${project.build.outputDirectory}/META-INF/MANIFEST.MF From 65b8e05e4b1c0e872cb068f083e3b5184653f436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 22:56:37 +0200 Subject: [PATCH 06/38] AdminMain revisited MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Stop swallowing exceptions - Log stacktraces if AS_TRACE or AS_DEBUG enabled - To get very verbose logs for asadmin: - export AS_ADMIN_LOG_FORMATTER=org.glassfish.main.jul.formatter.OneLineFormatter - export AS_TRACE=true Signed-off-by: David Matějček --- .../org/glassfish/admin/cli/AsadminMain.java | 24 +- .../sun/enterprise/admin/cli/AdminMain.java | 236 ++++++++++-------- .../enterprise/admin/cli/.gitkeep_empty_dir | 0 .../cli/src/main/resources/logging.properties | 2 + .../admin/cli/resources/.gitkeep_empty_dir | 0 5 files changed, 159 insertions(+), 103 deletions(-) delete mode 100644 nucleus/admin/cli/src/main/resources/com/sun/enterprise/admin/cli/.gitkeep_empty_dir create mode 100644 nucleus/admin/cli/src/main/resources/logging.properties delete mode 100644 nucleus/admin/cli/src/main/resources/org/glassfish/admin/cli/resources/.gitkeep_empty_dir diff --git a/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java b/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java index d38d2572875..a750dee6b47 100644 --- a/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java +++ b/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -19,6 +20,9 @@ import com.sun.enterprise.admin.cli.AdminMain; import com.sun.enterprise.admin.cli.Environment; +import java.io.File; +import java.util.Set; + /** * The asadmin main program. */ @@ -29,14 +33,32 @@ public static void main(String[] args) { // Metrix.event("START"); Environment.setPrefix("AS_ADMIN_"); Environment.setShortPrefix("AS_"); - int code = new AsadminMain().doMain(args); + + AsadminMain main = new AsadminMain(); + int code = main.doMain(args); // Metrix.event("DONE"); // System.out.println("METRIX:"); // System.out.println(Metrix.getInstance().toString()); System.exit(code); } + + @Override protected String getCommandName() { return "asadmin"; } + + + @Override + protected Set getExtensions() { + final Set locations = super.getExtensions(); + // FIXME: Identify just modules containing admin commands and their dependencies. + // Then split those jar files to server and cli part. + // Then cli parts should be under lib/admin + // And server parts under modules. + // They should not depend on each other. + final File modules = getInstallRoot().resolve("modules").toFile(); + locations.add(modules); + return locations; + } } 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 ee6eb6d88fa..1ccc4dc6f75 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 @@ -25,9 +25,11 @@ import com.sun.enterprise.util.SystemPropertyConstants; import java.io.File; +import java.io.IOException; import java.io.PrintStream; import java.lang.Runtime.Version; import java.net.ConnectException; +import java.nio.file.Path; import java.security.AccessController; import java.security.PrivilegedAction; import java.time.Instant; @@ -40,6 +42,7 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Formatter; import java.util.logging.Handler; +import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; import java.util.logging.SimpleFormatter; @@ -52,11 +55,13 @@ import org.glassfish.main.jul.GlassFishLogManager; import org.glassfish.main.jul.GlassFishLogManagerInitializer; import org.glassfish.main.jul.cfg.GlassFishLogManagerConfiguration; -import org.glassfish.main.jul.cfg.GlassFishLoggingConstants; import org.glassfish.main.jul.cfg.LoggingProperties; +import org.glassfish.main.jul.formatter.GlassFishLogFormatter; +import org.glassfish.main.jul.handler.BlockingExternallyManagedLogHandler; import org.glassfish.main.jul.tracing.GlassFishLoggingTracer; import static com.sun.enterprise.admin.cli.CLIConstants.WALL_CLOCK_START_PROP; +import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; import static java.util.logging.Level.FINE; import static java.util.logging.Level.FINER; import static java.util.logging.Level.FINEST; @@ -66,16 +71,6 @@ * The admin main program (nadmin). */ public class AdminMain { - private static final LoggingProperties LOGGING_CFG; - static { - GlassFishLoggingTracer.trace(AdminMain.class, "Preconfiguring logging for asadmin."); - // The logging is explicitly configured in doMain method - LOGGING_CFG = new LoggingProperties(); - LOGGING_CFG.setProperty("handlers", GlassFishLoggingConstants.CLASS_HANDLER_BLOCKING); - if (!GlassFishLogManagerInitializer.tryToSetAsDefault(LOGGING_CFG)) { - throw new IllegalStateException("GlassFishLogManager is not set as the default LogManager!"); - } - } private static final Environment env = new Environment(); private static final int SUCCESS = 0; private static final int ERROR = 1; @@ -85,13 +80,14 @@ public class AdminMain { private static final String ADMIN_CLI_LOGGER = "com.sun.enterprise.admin.cli"; private static final String[] SYS_PROPERTIES_TO_SET_FROM_ASENV = { - SystemPropertyConstants.INSTALL_ROOT_PROPERTY, + INSTALL_ROOT_PROPERTY, SystemPropertyConstants.CONFIG_ROOT_PROPERTY, SystemPropertyConstants.PRODUCT_ROOT_PROPERTY }; private static final LocalStringsImpl strings = new LocalStringsImpl(AdminMain.class); static { + GlassFishLogManagerInitializer.tryToSetAsDefault(); Map systemProps = new ASenvPropertyReader().getProps(); for (String prop : SYS_PROPERTIES_TO_SET_FROM_ASENV) { String val = systemProps.get(prop); @@ -101,6 +97,7 @@ public class AdminMain { } } + private final Path installRoot; private String classPath; private String className; private String command; @@ -108,6 +105,26 @@ public class AdminMain { private CLIContainer cliContainer; private Logger logger; + + public AdminMain() { + this.installRoot = Path.of(System.getProperty(INSTALL_ROOT_PROPERTY)); + if (installRoot == null) { + throw new Error("The install root was not specified by the system property " + INSTALL_ROOT_PROPERTY); + } + try { + final File dir = installRoot.toRealPath().toFile(); + if (!dir.isDirectory() && dir.canRead()) { + throw new Error("The install root is not an existing readable directory: " + installRoot); + } + } catch (IOException e) { + throw new Error("The install root is not valid: " + installRoot, e); + } + } + + protected Path getInstallRoot() { + return this.installRoot; + } + /** * Get the class loader that is used to load local commands. * @@ -122,15 +139,14 @@ private ClassLoader getExtensionClassLoader(final Set extensions) { try { return new DirectoryClassLoader(extensions, ecl); } catch (final RuntimeException ex) { - // any failure here is fatal - logger.info(strings.get("ExtDirFailed", ex)); + throw new Error(strings.get("ExtDirFailed", extensions), ex); } - return ecl; }; return AccessController.doPrivileged(action); } - /** Get set of JAR files that is used to locate local commands (CLICommand). + /** + * Get set of JAR files that is used to locate local commands (CLICommand). * Results can contain JAR files or directories where all JAR files are * used. It must return all JARs or directories * with acceptable CLICommands excluding admin-cli.jar. @@ -139,18 +155,13 @@ private ClassLoader getExtensionClassLoader(final Set extensions) { * @return set of JAR files or directories with JAR files */ protected Set getExtensions() { - final Set result = new HashSet<>(); - final File inst = new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY)); - final File ext = new File(new File(inst, "lib"), "asadmin"); + final Set locations = new HashSet<>(); + final File ext = installRoot.resolve(Path.of("lib", "asadmin")).toFile(); if (ext.exists() && ext.isDirectory()) { - result.add(ext); - } else { - if (logger.isLoggable(FINER)) { - logger.finer(strings.get("ExtDirMissing", ext)); - } + locations.add(ext); + return locations; } - result.add(new File(new File(inst, "modules"), "admin-cli.jar")); - return result; + throw new Error(strings.get("ExtDirMissing", ext)); } @@ -158,63 +169,13 @@ protected String getCommandName() { return "nadmin"; } - /** - * A ConsoleHandler that prints all non-SEVERE messages to System.out and - * all SEVERE messages to System.err. - */ - private static class CLILoggerHandler extends ConsoleHandler { - - private CLILoggerHandler(final Formatter formatter) { - setFormatter(formatter); - } - - @Override - public void publish(LogRecord logRecord) { - if (!isLoggable(logRecord)) { - return; - } - @SuppressWarnings("resource") - final PrintStream ps = logRecord.getLevel() == SEVERE ? System.err : System.out; - ps.print(getFormatter().format(logRecord)); - ps.flush(); - } - } - - - private static class CLILoggerFormatter extends SimpleFormatter { - private static final boolean TRACE = env.trace(); - - @Override - public synchronized String format(LogRecord record) { - // this formatter adds blank lines between records - if (record.getThrown() == null) { - return formatMessage(record) + System.lineSeparator(); - } - // Some messages use exception as a parameter. - // If we don't print stacktraces, the cause would be lost. - final Object[] parameters; - if (record.getParameters() == null) { - parameters = new Object[] {record.getThrown()}; - } else { - parameters = new Object[record.getParameters().length + 1]; - System.arraycopy(record.getParameters(), 0, parameters, 0, parameters.length - 1); - parameters[parameters.length - 1] = record.getThrown(); - } - record.setParameters(parameters); - if (TRACE) { - return super.format(record) + System.lineSeparator(); - } - return formatMessage(record) + " " + record.getThrown().getLocalizedMessage() + System.lineSeparator(); - } - } - public static void main(String[] args) { AdminMain adminMain = new AdminMain(); int code = adminMain.doMain(args); System.exit(code); } - protected int doMain(String[] args) { + protected final int doMain(String[] args) { Version version = Runtime.version(); if (version.feature() < 11) { System.err.println(strings.get("OldJdk", 11, version)); @@ -222,8 +183,13 @@ protected int doMain(String[] args) { } System.setProperty(WALL_CLOCK_START_PROP, Instant.now().toString()); - GlassFishLogManager.getLogManager().reconfigure(new GlassFishLogManagerConfiguration(LOGGING_CFG), - this::reconfigureLogging, null); + final LoggingProperties logging = new LoggingProperties(); + logging.setProperty("handlers", BlockingExternallyManagedLogHandler.class.getName()); + if (isClassAndMethodDetectionRequired()) { + logging.setProperty("org.glassfish.main.jul.classAndMethodDetection.enabled", "true"); + } + GlassFishLogManager.getLogManager().reconfigure(new GlassFishLogManagerConfiguration(logging), + this::configureLogging, null); // Set the thread's context class loader so that everyone can load from our extension directory. Set extensions = getExtensions(); @@ -287,6 +253,15 @@ protected int doMain(String[] args) { } + private boolean isClassAndMethodDetectionRequired() { + Formatter formatter = env.getLogFormatter(); + if (formatter instanceof GlassFishLogFormatter) { + GlassFishLogFormatter gfFormatter = (GlassFishLogFormatter) formatter; + return gfFormatter.isPrintSource(); + } + return false; + } + public int executeCommand(String[] argv) { CLICommand cmd = null; try { @@ -299,7 +274,7 @@ public int executeCommand(String[] argv) { po = new ProgramOptions(params, env); readAndMergeOptionsFromAuxInput(po); List operands = rcp.getOperands(); - argv = operands.toArray(new String[operands.size()]); + argv = operands.toArray(String[]::new); } else { po = new ProgramOptions(env); } @@ -321,17 +296,18 @@ public int executeCommand(String[] argv) { cmd = CLICommand.getCommand(cliContainer, command); return cmd.execute(argv); } catch (CommandValidationException cve) { - logger.severe(cve.getMessage()); - if (cmd == null) // error parsing program options - { + logError(cve); + if (cmd == null) { + // error parsing program options printUsage(); } else { logger.severe(cmd.getUsage()); + } return ERROR; } catch (InvalidCommandException ice) { + logError(ice); // find closest match with local or remote commands - logger.severe(ice.getMessage()); try { po.setEcho(false); CLIUtil.displayClosestMatch(command, @@ -342,9 +318,9 @@ public int executeCommand(String[] argv) { } return ERROR; } catch (CommandException ce) { + logError(ce); if (ce.getCause() instanceof ConnectException) { // find closest match with local commands - logger.severe(ce.getMessage()); try { CLIUtil.displayClosestMatch(command, CLIUtil.getLocalCommands(cliContainer), @@ -352,14 +328,12 @@ public int executeCommand(String[] argv) { } catch (InvalidCommandException e) { logger.info(strings.get("InvalidRemoteCommand", command)); } - } else { - logger.severe(ce.getMessage()); } return ERROR; } } - private void reconfigureLogging() { + private void configureLogging() { GlassFishLoggingTracer.trace(AdminMain.class, "Configuring logging for asadmin."); boolean trace = env.trace(); boolean debug = env.debug(); @@ -368,31 +342,48 @@ private void reconfigureLogging() { // admin commands to share. Only this logger and its children obey the // conventions that map terse=false to the INFO level and terse=true to // the FINE level. - logger = Logger.getLogger(ADMIN_CLI_LOGGER); + final Logger cliLogger = Logger.getLogger(ADMIN_CLI_LOGGER); if (trace) { - logger.setLevel(FINEST); + cliLogger.setLevel(FINEST); } else if (debug) { - logger.setLevel(FINER); + cliLogger.setLevel(FINER); } else { - logger.setLevel(FINE); + cliLogger.setLevel(FINE); } - logger.setUseParentHandlers(false); + cliLogger.setUseParentHandlers(false); Formatter formatter = env.getLogFormatter(); Handler cliHandler = new CLILoggerHandler(formatter == null ? new CLILoggerFormatter() : formatter); - cliHandler.setLevel(logger.getLevel()); - logger.addHandler(cliHandler); + cliHandler.setLevel(cliLogger.getLevel()); + cliLogger.addHandler(cliHandler); // make sure the root logger uses our handler as well Logger rootLogger = Logger.getLogger(""); rootLogger.setUseParentHandlers(false); if (trace) { - rootLogger.setLevel(logger.getLevel()); + rootLogger.setLevel(cliLogger.getLevel()); } for (Handler handler : rootLogger.getHandlers()) { rootLogger.removeHandler(handler); handler.close(); } rootLogger.addHandler(cliHandler); + this.logger = cliLogger; + } + + private void logError(Exception e) { + if (env.trace() || env.debug()) { + logger.log(Level.SEVERE, e.getMessage(), e); + } else { + logger.log(Level.SEVERE, e.getMessage()); + } + } + + /** + * Print usage message for the admin command. XXX - should be derived from + * ProgramOptions. + */ + private void printUsage() { + logger.severe(strings.get("Usage.full", getCommandName())); } private static void readAndMergeOptionsFromAuxInput(final ProgramOptions progOpts) { @@ -417,15 +408,56 @@ private static void readAndMergeOptionsFromAuxInput(final ProgramOptions progOpt } } + private static boolean isNotEmpty(String s) { + return s != null && !s.isEmpty(); + } + + /** - * Print usage message for the admin command. XXX - should be derived from - * ProgramOptions. + * A ConsoleHandler that prints all non-SEVERE messages to System.out and + * all SEVERE messages to System.err. */ - private void printUsage() { - logger.severe(strings.get("Usage.full", getCommandName())); + private static class CLILoggerHandler extends ConsoleHandler { + + private CLILoggerHandler(final Formatter formatter) { + setFormatter(formatter); + } + + @Override + public void publish(LogRecord logRecord) { + if (!isLoggable(logRecord)) { + return; + } + final PrintStream ps = logRecord.getLevel() == SEVERE ? System.err : System.out; + ps.print(getFormatter().format(logRecord)); + ps.flush(); + } } - private static boolean isNotEmpty(String s) { - return s != null && !s.isEmpty(); + private static class CLILoggerFormatter extends SimpleFormatter { + private static final boolean TRACE = env.trace(); + + @Override + public synchronized String format(LogRecord record) { + // this formatter adds blank lines between records + if (record.getThrown() == null) { + return formatMessage(record) + System.lineSeparator(); + } + // Some messages use exception as a parameter. + // If we don't print stacktraces, the cause would be lost. + final Object[] parameters; + if (record.getParameters() == null) { + parameters = new Object[] {record.getThrown()}; + } else { + parameters = new Object[record.getParameters().length + 1]; + System.arraycopy(record.getParameters(), 0, parameters, 0, parameters.length - 1); + parameters[parameters.length - 1] = record.getThrown(); + } + record.setParameters(parameters); + if (TRACE) { + return super.format(record) + System.lineSeparator(); + } + return formatMessage(record) + " " + record.getThrown().getLocalizedMessage() + System.lineSeparator(); + } } } diff --git a/nucleus/admin/cli/src/main/resources/com/sun/enterprise/admin/cli/.gitkeep_empty_dir b/nucleus/admin/cli/src/main/resources/com/sun/enterprise/admin/cli/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/nucleus/admin/cli/src/main/resources/logging.properties b/nucleus/admin/cli/src/main/resources/logging.properties new file mode 100644 index 00000000000..0faf28ddc3c --- /dev/null +++ b/nucleus/admin/cli/src/main/resources/logging.properties @@ -0,0 +1,2 @@ +handlers=org.glassfish.main.jul.handler.BlockingExternallyManagedLogHandler + diff --git a/nucleus/admin/cli/src/main/resources/org/glassfish/admin/cli/resources/.gitkeep_empty_dir b/nucleus/admin/cli/src/main/resources/org/glassfish/admin/cli/resources/.gitkeep_empty_dir deleted file mode 100644 index e69de29bb2d..00000000000 From 4e4dd0e268a000e9466d5eae1aff7dd7061f6582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 22:57:06 +0200 Subject: [PATCH 07/38] Fixed log messages - throwable is not a parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../admin/remote/RemoteRestAdminCommand.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java index 0b27f8d1b76..818e26e9a01 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java @@ -1110,30 +1110,30 @@ private void doHttpCommand(String uriString, String httpMethod, HttpCommand cmd, continue; } catch (ConnectException ce) { - logger.log(FINER, "doHttpCommand: connect exception {0}", ce); + logger.log(FINER, "doHttpCommand: connect exception", ce); // this really means nobody was listening on the remote server // note: ConnectException extends IOException and tells us more! String msg = strings.get("ConnectException", host, port + ""); throw new CommandException(msg, ce); } catch (UnknownHostException he) { - logger.log(FINER, "doHttpCommand: host exception {0}", he); + logger.log(FINER, "doHttpCommand: host exception", he); // bad host name String msg = strings.get("UnknownHostException", host); throw new CommandException(msg, he); } catch (SocketException se) { - logger.log(FINER, "doHttpCommand: socket exception {0}", se); + logger.log(FINER, "doHttpCommand: socket exception", se); throw new CommandException(se); } catch (SSLException se) { - logger.log(FINER, "doHttpCommand: SSL exception {0}", se); + logger.log(FINER, "doHttpCommand: SSL exception", se); if (secure) { logger.log(SEVERE, AdminLoggerInfo.mServerIsNotSecure, new Object[] { host, port }); } throw new CommandException(se); } catch (SocketTimeoutException e) { - logger.log(FINER, "doHttpCommand: read timeout {0}", e); + logger.log(FINER, "doHttpCommand: read timeout", e); throw new CommandException(strings.get("ReadTimeout", (float) readTimeout / 1000), e); } catch (IOException e) { - logger.log(FINER, "doHttpCommand: IO exception {0}", e); + logger.log(FINER, "doHttpCommand: IO exception", e); throw new CommandException(strings.get("IOError", e.getMessage()), e); } catch (CommandException e) { throw e; From cf57af1592f383fe68c6d0c8ffadfc167493017b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 23:19:12 +0200 Subject: [PATCH 08/38] Added log manager to domain.xml files, maintenance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed MaxPermSize - not supported on JDK11 - Removed -server and -client; on current JVMs -server is always active - Added log manager and blocking handler for waiting on instance's logging.properties Signed-off-by: David Matějček --- .../src/main/resources/config/domain.xml | 7 ++++-- .../src/test/resources/DomainTest.xml | 2 ++ .../domains/baddomain/config/domain.xml | 2 +- .../src/main/resources/config/domain.xml | 9 ++++--- .../src/test/resources/clusters1.xml | 24 +++++++++---------- .../src/test/resources/manysysprops.xml | 24 +++++++++---------- 6 files changed, 38 insertions(+), 30 deletions(-) diff --git a/appserver/admin/template/src/main/resources/config/domain.xml b/appserver/admin/template/src/main/resources/config/domain.xml index b29c5e4500e..05fa87e7db3 100644 --- a/appserver/admin/template/src/main/resources/config/domain.xml +++ b/appserver/admin/template/src/main/resources/config/domain.xml @@ -157,6 +157,8 @@ + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -Djdk.corba.allowOutputStreamSubclass=true -Djdk.tls.rejectClientInitiatedRenegotiation=true @@ -220,7 +222,7 @@ --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED --add-opens=java.base/jdk.internal.vm.annotation=ALL-UNNAMED - + -Djdk.attach.allowAttachSelf=true @@ -358,7 +360,8 @@ - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -Djdk.corba.allowOutputStreamSubclass=true -Djdk.tls.rejectClientInitiatedRenegotiation=true diff --git a/appserver/resources/resources-connector/src/test/resources/DomainTest.xml b/appserver/resources/resources-connector/src/test/resources/DomainTest.xml index 2812bd81297..57034937e42 100644 --- a/appserver/resources/resources-connector/src/test/resources/DomainTest.xml +++ b/appserver/resources/resources-connector/src/test/resources/DomainTest.xml @@ -117,6 +117,8 @@ + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -Djdk.corba.allowOutputStreamSubclass=true -Djdk.tls.rejectClientInitiatedRenegotiation=true diff --git a/nucleus/admin/launcher/src/test/resources/domains/baddomain/config/domain.xml b/nucleus/admin/launcher/src/test/resources/domains/baddomain/config/domain.xml index 9dc601a91a6..38d39739b08 100644 --- a/nucleus/admin/launcher/src/test/resources/domains/baddomain/config/domain.xml +++ b/nucleus/admin/launcher/src/test/resources/domains/baddomain/config/domain.xml @@ -139,7 +139,7 @@ - -client + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy -Djava.security.auth.login.config=${com.sun.aas.instanceRoot}/config/login.conf -Dsun.rmi.dgc.server.gcInterval=3600000 diff --git a/nucleus/admin/template/src/main/resources/config/domain.xml b/nucleus/admin/template/src/main/resources/config/domain.xml index 7383a811599..1cda6134391 100644 --- a/nucleus/admin/template/src/main/resources/config/domain.xml +++ b/nucleus/admin/template/src/main/resources/config/domain.xml @@ -130,8 +130,10 @@ - -Djdk.tls.rejectClientInitiatedRenegotiation=true + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true + -Djdk.tls.rejectClientInitiatedRenegotiation=true -Djavax.management.builder.initial=com.sun.enterprise.v3.admin.AppServerMBeanServerBuilder -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -179,7 +181,7 @@ --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED - + -Djdk.attach.allowAttachSelf=true @@ -285,7 +287,8 @@ - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -Djdk.tls.rejectClientInitiatedRenegotiation=true -XX:+UnlockDiagnosticVMOptions diff --git a/nucleus/common/common-util/src/test/resources/clusters1.xml b/nucleus/common/common-util/src/test/resources/clusters1.xml index 50728ddf616..2278b75f41d 100644 --- a/nucleus/common/common-util/src/test/resources/clusters1.xml +++ b/nucleus/common/common-util/src/test/resources/clusters1.xml @@ -171,8 +171,8 @@ - -XX:MaxPermSize=192m - -client + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -Djavax.management.builder.initial=com.sun.enterprise.v3.admin.AppServerMBeanServerBuilder -XX:+UnlockDiagnosticVMOptions @@ -322,8 +322,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -488,8 +488,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -654,8 +654,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -820,8 +820,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -986,8 +986,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy diff --git a/nucleus/common/common-util/src/test/resources/manysysprops.xml b/nucleus/common/common-util/src/test/resources/manysysprops.xml index f63d23ed193..5e4f3a3f908 100644 --- a/nucleus/common/common-util/src/test/resources/manysysprops.xml +++ b/nucleus/common/common-util/src/test/resources/manysysprops.xml @@ -176,8 +176,8 @@ - -XX:MaxPermSize=192m - -client + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -Djavax.management.builder.initial=com.sun.enterprise.v3.admin.AppServerMBeanServerBuilder -XX:+UnlockDiagnosticVMOptions @@ -327,8 +327,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -496,8 +496,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -662,8 +662,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -828,8 +828,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy @@ -994,8 +994,8 @@ - -XX:MaxPermSize=192m - -server + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -XX:+UnlockDiagnosticVMOptions -Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy From eec1f0fa55d994a589e0bf6cd6f3033ff516491e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 23:50:37 +0200 Subject: [PATCH 09/38] Boot classpath reconstruction - separation of layers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Separated bootstrap aka glassfish.jar and glassfish-osgi-bootstrap - Separated common-util (osgi enabled) and glassfish-jdk-extensions (usual jar) - Result: We have nonosgi part usable for standard Java classpath and another osgi-enabled group of jar files loaded dynamically. It is much easier to understand and manage all dependencies. - Result2: We can enable logging much sooner than before. Maybe even without blocking (not implemented yet, to be invented later). - This commit will not build, I am trying to separate the work to parts. Signed-off-by: David Matějček --- .../sun/enterprise/backup/ListManager.java | 3 +- .../admin/cli/optional/BackupCommands.java | 2 +- .../cli/optional/BackupDomainCommand.java | 2 +- .../admin/cli/optional/DatabaseCommand.java | 2 +- .../cli/optional/ListBackupsCommand.java | 2 +- .../cli/optional/RestoreDomainCommand.java | 2 +- .../cli/optional/StartDatabaseCommand.java | 2 +- .../cli/optional/StopDatabaseCommand.java | 2 +- .../packageappclient/PackageAppClient.java | 4 +- .../appclient/client/AppClientFacade.java | 12 +- .../appclient/client/acc/ACCClassLoader.java | 4 +- .../client/acc/JWSACCClassLoader.java | 4 +- .../ProviderContainerContractInfoImpl.java | 2 +- .../client/acc/UndeployedLaunchable.java | 2 +- .../DefaultGUICallbackHandler.java | 2 +- .../core/AppClientServerApplication.java | 4 +- .../server/core/jws/JavaWebStartInfo.java | 2 +- .../core/jws/servedcontent/TokenHelper.java | 3 +- .../org/glassfish/ha/commands/Strings.java | 2 +- .../enterprise/connectors/util/RARUtils.java | 4 +- .../javaee/full/deployment/EarHandler.java | 2 +- .../UberJarOSGiGlassFishRuntimeBuilder.java | 14 +- .../ServletContainerInitializerUtil.java | 4 +- .../web/loader/WebappClassLoader.java | 2 +- .../web/loader/WebappClassLoaderTest.java | 2 +- .../weld/BeanDeploymentArchiveImpl.java | 4 +- .../webservices/WebServicesDeployer.java | 4 +- .../monitoring/WebServiceTesterServlet.java | 2 +- .../sun/enterprise/admin/cli/AdminMain.java | 2 +- .../admin/cli/ArgumentTokenizer.java | 4 +- .../sun/enterprise/admin/cli/CLICommand.java | 2 +- .../com/sun/enterprise/admin/cli/CLIUtil.java | 2 +- .../admin/cli/DirectoryClassLoader.java | 7 +- .../enterprise/admin/cli/ExportCommand.java | 3 +- .../sun/enterprise/admin/cli/HelpCommand.java | 3 +- .../admin/cli/ListCommandsCommand.java | 3 +- .../enterprise/admin/cli/LoginCommand.java | 2 +- .../admin/cli/MultimodeCommand.java | 2 +- .../com/sun/enterprise/admin/cli/Parser.java | 2 +- .../enterprise/admin/cli/ProgramOptions.java | 2 +- .../com/sun/enterprise/admin/cli/Strings.java | 2 +- .../enterprise/admin/cli/UnsetCommand.java | 3 +- .../enterprise/admin/cli/VersionCommand.java | 2 +- .../admin/cli/remote/DetachListener.java | 2 +- .../cli/remote/ProgressStatusPrinter.java | 2 +- .../admin/cli/remote/RemoteCLICommand.java | 2 +- .../admin/cli/remote/RemoteCommand.java | 2 +- .../CustomizationTokensProvider.java | 4 +- .../config/util/PortBaseHelper.java | 2 +- .../sun/enterprise/config/util/Strings.java | 2 +- .../org/glassfish/config/support/Strings.java | 2 +- .../enterprise/admin/launcher/GFLauncher.java | 3 +- .../admin/launcher/GFLauncherException.java | 2 +- .../admin/launcher/GFLauncherLogger.java | 3 +- .../cli/ChangeAdminPasswordCommand.java | 2 +- .../cli/ChangeMasterPasswordCommand.java | 2 +- .../cli/ChangeMasterPasswordCommandDAS.java | 2 +- .../servermgmt/cli/CreateDomainCommand.java | 2 +- .../servermgmt/cli/CreateServiceCommand.java | 2 +- .../servermgmt/cli/DeleteDomainCommand.java | 2 +- .../servermgmt/cli/DeleteServiceCommand.java | 2 +- .../servermgmt/cli/DomainXmlVerifier.java | 2 +- .../servermgmt/cli/ListDomainsCommand.java | 2 +- .../servermgmt/cli/LocalServerCommand.java | 2 +- .../admin/servermgmt/cli/MonitorCommand.java | 2 +- .../admin/servermgmt/cli/MonitorTask.java | 2 +- .../servermgmt/cli/RestartDomainCommand.java | 2 +- .../servermgmt/cli/StartDomainCommand.java | 2 +- .../servermgmt/cli/StartServerHelper.java | 2 +- .../admin/servermgmt/cli/Strings.java | 2 +- .../cli/VerifyDomainXmlCommand.java | 4 +- .../admin/servermgmt/services/Strings.java | 2 +- .../impl/ArchiveEntryWrapperImpl.java | 2 +- .../stringsubs/impl/FileEntryFactory.java | 2 +- .../stringsubs/impl/FileLister.java | 3 +- .../impl/FileSubstitutionHandler.java | 3 +- .../impl/StringSubstitutionEngine.java | 2 +- .../impl/StringSubstitutionParser.java | 2 +- .../stringsubs/impl/SubstitutionFileUtil.java | 3 +- .../stringsubs/impl/algorithm/RadixTree.java | 3 +- .../impl/algorithm/RadixTreeNode.java | 3 +- .../algorithm/RadixTreeSubstitutionAlgo.java | 3 +- .../template/TemplateInfoHolder.java | 2 +- .../admin/progress/ProgressStatusClient.java | 2 +- .../admin/remote/PlainTextManager.java | 3 +- .../admin/remote/RemoteAdminCommand.java | 2 +- .../admin/remote/RemoteResponseManager.java | 3 +- .../admin/remote/RemoteRestAdminCommand.java | 2 +- .../admin/util/AsadminTrustManager.java | 3 +- .../sun/enterprise/admin/util/Strings.java | 2 +- .../enterprise/v3/admin/cluster/Strings.java | 2 +- .../ChangeNodeMasterPasswordCommand.java | 2 +- .../enterprise/admin/cli/cluster/Strings.java | 2 +- .../sun/enterprise/util/cluster/Strings.java | 2 +- .../cluster/ssh/connect/Strings.java | 2 +- .../glassfish/cluster/ssh/util/Strings.java | 2 +- .../enterprise/loader/ASURLClassLoader.java | 2 +- .../security/store/AsadminSecurityUtil.java | 3 +- .../sun/enterprise/universal/Duration.java | 2 +- .../universal/xml/MiniXmlParser.java | 2 +- .../java/com/sun/enterprise/util/Strings.java | 2 +- .../sun/enterprise/util/io/DomainDirs.java | 3 +- .../sun/enterprise/util/io/ServerDirs.java | 3 +- .../com/sun/enterprise/util/io/Strings.java | 2 +- .../sun/enterprise/util/reflect/Strings.java | 2 +- .../api/admin/ServerEnvironment.java | 4 +- .../common/glassfish-jdk-extensions/pom.xml | 44 +++++ .../jdke/cl}/GlassfishUrlClassLoader.java | 19 +- .../main/jdke}/i18n/LocalStrings.java | 3 +- .../main/jdke}/i18n/LocalStringsImpl.java | 4 +- .../jdke/cl}/GlassfishUrlClassLoaderTest.java | 6 +- nucleus/common/pom.xml | 1 + nucleus/common/simple-glassfish-api/README | 1 - nucleus/core/bootstrap-osgi/pom.xml | 112 ++++++++++++ .../embedded/AutoDisposableGlassFish.java | 4 +- .../embedded/EmbeddedGlassFishRuntime.java | 4 +- .../EmbeddedGlassFishRuntimeBuilder.java | 44 +++-- .../embedded/EmbeddedInhabitantsParser.java | 2 +- .../main/boot}/embedded/EmbeddedMain.java | 2 +- .../main/boot}/embedded/JarUtil.java | 2 +- .../main/boot}/embedded/SingleHK2Factory.java | 2 +- .../main/boot/impl}/GlassFishImpl.java | 2 +- .../main/boot}/osgi/BundleProvisioner.java | 2 +- .../osgi/BundleProvisionerCustomizer.java | 4 +- .../DefaultBundleProvisionerCustomizer.java | 5 +- .../boot}/osgi/EmbeddedOSGiGlassFishImpl.java | 2 +- .../osgi/EmbeddedOSGiGlassFishRuntime.java | 9 +- .../EmbeddedOSGiGlassFishRuntimeBuilder.java | 19 +- .../boot}/osgi/GlassFishBundleContext.java | 2 +- .../main/boot}/osgi/GlassFishDecorator.java | 2 +- .../boot}/osgi/GlassFishMainActivator.java | 48 +---- .../boot/osgi/GlassFishOsgiLauncher.java} | 20 ++- .../org/glassfish/main/boot}/osgi/Jar.java | 2 +- .../boot}/osgi/MinimalBundleProvisioner.java | 2 +- .../MinimalBundleProvisionerCustomizer.java | 2 +- .../boot}/osgi/OSGiFrameworkLauncher.java | 22 ++- .../main/boot}/osgi/OSGiGlassFishImpl.java | 2 +- .../main/boot}/osgi/OSGiGlassFishRuntime.java | 2 +- .../osgi/OSGiGlassFishRuntimeBuilder.java | 42 ++--- ...rg.glassfish.embeddable.spi.RuntimeBuilder | 3 + ...g.glassfish.hk2.api.PopulatorPostProcessor | 1 + .../src/main/resources/logging.properties | 8 + .../boot}/osgi/BundleProvisionerTest.java | 2 +- .../glassfish/bootstrap/GlassFishMain.java | 162 ++++++++--------- .../glassfish/bootstrap/cfg/AsenvConf.java | 2 + .../bootstrap/cfg/BootstrapKeys.java | 11 ++ .../bootstrap/{ => cfg}/FelixUtil.java | 2 +- .../glassfish/bootstrap/cfg/ServerFiles.java | 21 +++ .../{ => cfg}/StartupContextCfgFactory.java | 68 ++----- .../bootstrap/cfg/StartupContextUtil.java | 136 -------------- .../bootstrap/cp/ClassLoaderBuilder.java | 112 ++---------- .../bootstrap/cp/ClassPathBuilder.java | 51 ++---- .../bootstrap/cp/EmbeddedAdapter.java | 3 +- .../bootstrap/cp/EquinoxAdapter.java | 4 +- .../glassfish/bootstrap/cp/FelixAdapter.java | 4 +- .../bootstrap/cp/KnopflerfishAdapter.java | 4 +- .../bootstrap/cp/OsgiPlatformAdapter.java | 4 +- .../GlassfishOsgiBootstrapClassLoader.java} | 44 ++--- .../glassfish/bootstrap/launch/Launcher.java | 24 +++ ...rg.glassfish.embeddable.spi.RuntimeBuilder | 3 - ...g.glassfish.hk2.api.PopulatorPostProcessor | 1 - .../bootstrap/cp/ClassLoaderBuilderIT.java | 24 +-- .../sun/enterprise/v3/admin/IdmService.java | 43 +++-- .../enterprise/v3/admin/LocationsCommand.java | 17 +- .../enterprise/v3/admin/RestartServer.java | 17 +- .../com/sun/enterprise/v3/admin/Strings.java | 2 +- .../server/AppLibClassLoaderServiceImpl.java | 4 +- .../v3/server/AppServerStartup.java | 2 +- .../server/CommonClassLoaderServiceImpl.java | 19 +- .../v3/server/ServerContextImpl.java | 4 +- .../v3/server/ServerLifecycleModule.java | 2 +- .../enterprise/v3/server/SystemTasksImpl.java | 2 +- .../org/glassfish/runnablejar/UberMain.java | 3 +- .../glassfish/runnablejar/UberMainTest.java | 170 +++++++++--------- .../tests/kernel/deployment/EventsTest.java | 7 +- .../logging/LoggerInfoMetadataService.java | 2 +- nucleus/core/pom.xml | 1 + ...nceValidateRemoteDirDeploymentCommand.java | 2 +- .../flashlight/impl/client/Strings.java | 2 +- .../interactive/LocalOSGiShellCommand.java | 2 +- .../security/admin/cli/Strings.java | 2 +- 181 files changed, 836 insertions(+), 883 deletions(-) create mode 100755 nucleus/common/glassfish-jdk-extensions/pom.xml rename nucleus/common/{common-util/src/main/java/org/glassfish/common/util => glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/cl}/GlassfishUrlClassLoader.java (88%) rename nucleus/common/{common-util/src/main/java/com/sun/enterprise/universal => glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke}/i18n/LocalStrings.java (97%) rename nucleus/common/{common-util/src/main/java/com/sun/enterprise/universal => glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke}/i18n/LocalStringsImpl.java (98%) rename nucleus/common/{common-util/src/test/java/org/glassfish/common/util => glassfish-jdk-extensions/src/test/java/org/glassfish/main/jdke/cl}/GlassfishUrlClassLoaderTest.java (80%) delete mode 100644 nucleus/common/simple-glassfish-api/README create mode 100755 nucleus/core/bootstrap-osgi/pom.xml rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/embedded/AutoDisposableGlassFish.java (96%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/embedded/EmbeddedGlassFishRuntime.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/embedded/EmbeddedGlassFishRuntimeBuilder.java (83%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/embedded/EmbeddedInhabitantsParser.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/embedded/EmbeddedMain.java (96%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/embedded/JarUtil.java (99%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/embedded/SingleHK2Factory.java (97%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot/impl}/GlassFishImpl.java (99%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/BundleProvisioner.java (99%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/BundleProvisionerCustomizer.java (97%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/DefaultBundleProvisionerCustomizer.java (96%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/EmbeddedOSGiGlassFishImpl.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/EmbeddedOSGiGlassFishRuntime.java (96%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/EmbeddedOSGiGlassFishRuntimeBuilder.java (79%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/GlassFishBundleContext.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/GlassFishDecorator.java (97%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/GlassFishMainActivator.java (82%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/Launcher.java => bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishOsgiLauncher.java} (91%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/Jar.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/MinimalBundleProvisioner.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/MinimalBundleProvisionerCustomizer.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/OSGiFrameworkLauncher.java (85%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/OSGiGlassFishImpl.java (97%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/OSGiGlassFishRuntime.java (98%) rename nucleus/core/{bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/main/java/org/glassfish/main/boot}/osgi/OSGiGlassFishRuntimeBuilder.java (92%) create mode 100644 nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder create mode 100644 nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor create mode 100644 nucleus/core/bootstrap-osgi/src/main/resources/logging.properties rename nucleus/core/{bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap => bootstrap-osgi/src/test/java/org/glassfish/main/boot}/osgi/BundleProvisionerTest.java (98%) rename nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/{ => cfg}/FelixUtil.java (99%) rename nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/{ => cfg}/StartupContextCfgFactory.java (71%) delete mode 100644 nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/StartupContextUtil.java rename nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/{cp/GlassfishBootstrapClassLoader.java => launch/GlassfishOsgiBootstrapClassLoader.java} (61%) create mode 100644 nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/Launcher.java delete mode 100644 nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder delete mode 100644 nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor diff --git a/appserver/admin/backup/src/main/java/com/sun/enterprise/backup/ListManager.java b/appserver/admin/backup/src/main/java/com/sun/enterprise/backup/ListManager.java index 155f9832bf1..c2d98a38579 100644 --- a/appserver/admin/backup/src/main/java/com/sun/enterprise/backup/ListManager.java +++ b/appserver/admin/backup/src/main/java/com/sun/enterprise/backup/ListManager.java @@ -22,7 +22,6 @@ package com.sun.enterprise.backup; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.ColumnFormatter; import com.sun.enterprise.util.io.FileUtils; @@ -33,6 +32,8 @@ import java.util.List; import java.util.TreeSet; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupCommands.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupCommands.java index 93db55a57cf..39022d5c23c 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupCommands.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupCommands.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.servermgmt.cli.LocalDomainCommand; import com.sun.enterprise.backup.BackupRequest; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.ObjectAnalyzer; import java.io.File; @@ -28,6 +27,7 @@ import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import static com.sun.enterprise.util.Utility.isEmpty; import static com.sun.enterprise.util.io.DomainDirs.getDefaultDomainsDir; diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupDomainCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupDomainCommand.java index 07758abaa21..8b3901e62ee 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupDomainCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/BackupDomainCommand.java @@ -21,7 +21,6 @@ import com.sun.enterprise.backup.BackupException; import com.sun.enterprise.backup.BackupManager; import com.sun.enterprise.backup.BackupWarningException; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.util.ObjectAnalyzer; @@ -30,6 +29,7 @@ import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java index 8c53eeb22a0..3114b47658a 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.cli.CLICommand; import com.sun.enterprise.admin.cli.ClassPathBuilder; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.OS; import java.io.File; @@ -27,6 +26,7 @@ import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/ListBackupsCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/ListBackupsCommand.java index 461ced23840..882243e5037 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/ListBackupsCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/ListBackupsCommand.java @@ -20,13 +20,13 @@ import com.sun.enterprise.backup.BackupException; import com.sun.enterprise.backup.BackupWarningException; import com.sun.enterprise.backup.ListManager; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.ObjectAnalyzer; import java.io.File; import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/RestoreDomainCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/RestoreDomainCommand.java index cc81a25f2a9..febc08953cc 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/RestoreDomainCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/RestoreDomainCommand.java @@ -21,7 +21,6 @@ import com.sun.enterprise.backup.BackupRequest; import com.sun.enterprise.backup.BackupWarningException; import com.sun.enterprise.backup.RestoreManager; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.util.ObjectAnalyzer; @@ -32,6 +31,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; import static com.sun.enterprise.util.Utility.isAllNull; diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java index e89eb92fda3..841dc9b2667 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java @@ -18,7 +18,6 @@ import com.sun.enterprise.admin.cli.CLIProcessExecutor; import com.sun.enterprise.universal.glassfish.GFLauncherUtils; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.OS; import java.io.File; @@ -30,6 +29,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; import static com.sun.enterprise.admin.cli.optional.DerbyControl.DB_LOG_FILENAME; diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java index b25765cb0ab..f80e40100ae 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.cli.CLIProcessExecutor; import com.sun.enterprise.admin.cli.Environment; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.OS; import java.io.File; @@ -29,6 +28,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; import static com.sun.enterprise.admin.cli.CLIUtil.readPasswordFileOptions; diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java index cac07567328..d431490905a 100644 --- a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java @@ -16,8 +16,6 @@ package org.glassfish.appclient.client.packageappclient; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; @@ -35,6 +33,8 @@ import java.util.jar.JarOutputStream; import java.util.zip.ZipException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + import static java.util.jar.Attributes.Name.CLASS_PATH; /** diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java index b7c556eff58..b780cc3794c 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java @@ -73,7 +73,7 @@ import org.glassfish.appclient.client.acc.config.MessageSecurityConfig; import org.glassfish.appclient.client.acc.config.Property; import org.glassfish.appclient.client.acc.config.TargetServer; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -364,12 +364,12 @@ private static AppClientContainer createContainerForJWSLaunch(Builder builder, S return builder.newContainer(URI.create(appClientPath), null /* callbackHandler */, mainClassName, clientName); } - private static AppClientContainer createContainerForClassName(Builder builder, String className) throws Exception, UserError { - /* - * Place "." on the class path so that when we convert the class file path to a fully-qualified class name and try to - * load it, we'll find it. - */ + /** + * Place "." on the class path so that when we convert the class file path + * to a fully-qualified class name and try to load it, we'll find it. + */ + private static AppClientContainer createContainerForClassName(Builder builder, String className) throws Exception, UserError { ClassLoader loader = prepareLoaderToFindClassFile(Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(loader); diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java index 72031f4f5c7..cc02431ddcf 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023 Contributors to Eclipse Foundation. + * Copyright (c) 2021, 2024 Contributors to Eclipse Foundation. * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2022 Contributors to the Eclipse Foundation * @@ -39,7 +39,7 @@ import org.glassfish.appclient.common.ClassPathUtils; import org.glassfish.appclient.common.ClientClassLoaderDelegate; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import static java.security.AccessController.doPrivileged; diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java index ff5f2f07e2e..f7aa8132bc6 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -22,7 +22,7 @@ import java.security.PermissionCollection; import org.glassfish.appclient.common.ClientClassLoaderDelegate; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; public class JWSACCClassLoader extends GlassfishUrlClassLoader { diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java index edcec40f09e..fc7fa5581d7 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java @@ -36,8 +36,8 @@ import org.glassfish.api.deployment.DeploymentContext; import org.glassfish.api.naming.SimpleJndiName; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.deployment.common.RootDeploymentDescriptor; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.glassfish.persistence.jpa.ProviderContainerContractInfoBase; /** diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java index 1ba734d65d0..bc10fd0657e 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java @@ -25,7 +25,6 @@ import com.sun.enterprise.deployment.archivist.Archivist; import com.sun.enterprise.deployment.archivist.ArchivistFactory; import com.sun.enterprise.deployment.util.DOLUtils; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.IOException; import java.net.URI; @@ -40,6 +39,7 @@ import org.glassfish.deployment.common.ModuleDescriptor; import org.glassfish.deployment.common.RootDeploymentDescriptor; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.xml.sax.SAXException; diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/callbackhandler/DefaultGUICallbackHandler.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/callbackhandler/DefaultGUICallbackHandler.java index 7127d412357..2f6756ede62 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/callbackhandler/DefaultGUICallbackHandler.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/callbackhandler/DefaultGUICallbackHandler.java @@ -17,7 +17,6 @@ package org.glassfish.appclient.client.acc.callbackhandler; import com.sun.enterprise.security.GUILoginDialog; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.IOException; @@ -25,6 +24,7 @@ import javax.security.auth.callback.UnsupportedCallbackException; import org.glassfish.appclient.client.acc.callbackhandler.CallbackGUIBindings.MessageType; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Example callback handler for displaying and gathering information from the diff --git a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java index 7aa1db330af..5969dbf113a 100644 --- a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java +++ b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -33,9 +33,9 @@ import org.glassfish.api.deployment.DeployCommandParameters; import org.glassfish.api.deployment.DeploymentContext; import org.glassfish.appclient.server.core.jws.JavaWebStartInfo; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.jvnet.hk2.annotations.Service; /** diff --git a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/JavaWebStartInfo.java b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/JavaWebStartInfo.java index 565862ee6d3..e6991d59762 100644 --- a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/JavaWebStartInfo.java +++ b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/JavaWebStartInfo.java @@ -18,7 +18,6 @@ package org.glassfish.appclient.server.core.jws; import com.sun.enterprise.deployment.ApplicationClientDescriptor; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import jakarta.inject.Inject; @@ -59,6 +58,7 @@ import org.glassfish.logging.annotation.LogMessageInfo; import org.glassfish.logging.annotation.LogMessagesResourceBundle; import org.glassfish.logging.annotation.LoggerInfo; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; import org.jvnet.hk2.config.ConfigListener; import org.jvnet.hk2.config.UnprocessedChangeEvent; diff --git a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/servedcontent/TokenHelper.java b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/servedcontent/TokenHelper.java index 6a7119b3896..7387d7994df 100644 --- a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/servedcontent/TokenHelper.java +++ b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/jws/servedcontent/TokenHelper.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,7 +18,6 @@ package org.glassfish.appclient.server.core.jws.servedcontent; import com.sun.enterprise.deployment.ApplicationClientDescriptor; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.net.URI; import java.util.Properties; @@ -29,6 +29,7 @@ import org.glassfish.appclient.server.core.jws.JavaWebStartInfo; import org.glassfish.appclient.server.core.jws.JavaWebStartInfo.VendorInfo; import org.glassfish.appclient.server.core.jws.NamingConventions; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * diff --git a/appserver/common/container-common/src/main/java/org/glassfish/ha/commands/Strings.java b/appserver/common/container-common/src/main/java/org/glassfish/ha/commands/Strings.java index 625ec6702be..ccc8936ad2a 100644 --- a/appserver/common/container-common/src/main/java/org/glassfish/ha/commands/Strings.java +++ b/appserver/common/container-common/src/main/java/org/glassfish/ha/commands/Strings.java @@ -16,7 +16,7 @@ package org.glassfish.ha.commands; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java index 5a74c54864e..619c0d91d2a 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -37,7 +37,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; /** * This is a utility class to obtain the properties of a diff --git a/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarHandler.java b/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarHandler.java index cfb1150b8ed..0d15051d591 100644 --- a/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarHandler.java +++ b/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarHandler.java @@ -32,7 +32,6 @@ import com.sun.enterprise.security.ee.perms.PermsArchiveDelegate; import com.sun.enterprise.security.ee.perms.SMGlobalPolicyUtil; import com.sun.enterprise.security.integration.DDPermissionsLoader; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.LocalStringManagerImpl; import com.sun.enterprise.util.io.FileUtils; @@ -84,6 +83,7 @@ import org.glassfish.internal.deployment.ExtendedDeploymentContext; import org.glassfish.javaee.core.deployment.ApplicationHolder; import org.glassfish.loader.util.ASClassLoaderUtil; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; import org.xml.sax.SAXException; diff --git a/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java b/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java index fbfe11066f2..680499f4c4c 100644 --- a/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java +++ b/appserver/extras/embedded/common/bootstrap/src/main/java/org/glassfish/uberjar/bootstrap/UberJarOSGiGlassFishRuntimeBuilder.java @@ -18,7 +18,6 @@ package org.glassfish.uberjar.bootstrap; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; -import com.sun.enterprise.glassfish.bootstrap.osgi.OSGiFrameworkLauncher; import com.sun.enterprise.util.io.FileUtils; import java.io.File; @@ -37,6 +36,7 @@ import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishRuntime; import org.glassfish.embeddable.spi.RuntimeBuilder; +import org.glassfish.main.boot.osgi.OSGiFrameworkLauncher; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; @@ -103,7 +103,7 @@ public void destroy() throws GlassFishException { } @Override - public GlassFishRuntime build(BootstrapProperties bsOptions) throws GlassFishException { + public GlassFishRuntime build(BootstrapProperties bsOptions, ClassLoader classloader) throws GlassFishException { String uberJarURI = bsOptions.getProperty(UBER_JAR_URI); logger.log(Level.FINER, "UberJarOSGiGlassFishRuntimeBuilder.build, uberJarUri={0}", uberJarURI); @@ -154,7 +154,7 @@ public GlassFishRuntime build(BootstrapProperties bsOptions) throws GlassFishExc "jar:" + jar.toString() + "!/modules/instanceroot-builder_jar/," + "jar:" + jar.toString() + "!/modules/kernel_jar/"; - if (isOSGiEnv()) { + if (isOSGiEnv(classloader)) { autoStartBundleLocation = autoStartBundleLocation + ",jar:" + jar.toString() + "!/modules/osgi-modules-uninstaller_jar/"; } @@ -173,8 +173,8 @@ public GlassFishRuntime build(BootstrapProperties bsOptions) throws GlassFishExc logger.logp(Level.FINER, "UberJarOSGiGlassFishRuntimeBuilder", "build", "Building file system {0}", bsOptions); try { - if (!isOSGiEnv()) { - final OSGiFrameworkLauncher fwLauncher = new OSGiFrameworkLauncher(bsOptions.getProperties()); + if (!isOSGiEnv(classloader)) { + final OSGiFrameworkLauncher fwLauncher = new OSGiFrameworkLauncher(bsOptions.getProperties(), classloader); framework = fwLauncher.launchOSGiFrameWork(); return fwLauncher.getService(GlassFishRuntime.class); } @@ -197,8 +197,8 @@ private String getDefaultInstanceRoot() { .getAbsolutePath(); } - private boolean isOSGiEnv() { - return (getClass().getClassLoader() instanceof BundleReference); + private boolean isOSGiEnv(ClassLoader classloader) { + return classloader instanceof BundleReference; } public T getService(Class type, BundleContext context) throws Exception { diff --git a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java index 3723fcfee59..3c0861cf543 100644 --- a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java +++ b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -44,7 +44,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.deployment.common.ClassDependencyBuilder; import org.glassfish.hk2.classmodel.reflect.AnnotatedElement; import org.glassfish.hk2.classmodel.reflect.AnnotationType; @@ -54,6 +53,7 @@ import org.glassfish.hk2.classmodel.reflect.Parameter; import org.glassfish.hk2.classmodel.reflect.Type; import org.glassfish.hk2.classmodel.reflect.Types; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import static java.lang.Runtime.version; import static java.util.logging.Level.FINE; diff --git a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java index 6cdd56f23ff..a6d2c9bf685 100644 --- a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java +++ b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java @@ -73,8 +73,8 @@ import org.apache.naming.resources.ResourceAttributes; import org.apache.naming.resources.WebDirContext; import org.glassfish.api.deployment.InstrumentableClassLoader; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.hk2.api.PreDestroy; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.glassfish.web.loader.RepositoryManager.RepositoryResource; import static java.lang.System.Logger.Level.DEBUG; diff --git a/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java b/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java index 0ab3506dfe0..1a53a9c5ce4 100644 --- a/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java +++ b/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java @@ -24,7 +24,7 @@ import java.nio.file.Path; import org.apache.naming.resources.WebDirContext; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java index f3ac1733d01..6963e67c795 100644 --- a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java +++ b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation. + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation. * Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -39,7 +39,7 @@ import org.glassfish.api.deployment.DeploymentContext; import org.glassfish.api.deployment.archive.ReadableArchive; import org.glassfish.cdi.CDILoggerInfo; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.glassfish.weld.connector.WeldUtils; import org.glassfish.weld.connector.WeldUtils.BDAType; import org.glassfish.weld.ejb.EjbDescriptorImpl; diff --git a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java index fbf8517a234..42b3e415d01 100644 --- a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java +++ b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2006, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -68,10 +68,10 @@ import org.glassfish.api.deployment.archive.ArchiveType; import org.glassfish.api.deployment.archive.ReadableArchive; import org.glassfish.api.deployment.archive.WritableArchive; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.deployment.common.DeploymentException; import org.glassfish.javaee.core.deployment.JavaEEDeployer; import org.glassfish.loader.util.ASClassLoaderUtil; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.glassfish.web.deployment.descriptor.AppListenerDescriptorImpl; import org.glassfish.web.deployment.util.WebServerInfo; import org.glassfish.webservices.deployment.WebServicesDeploymentMBean; diff --git a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java index 1819865f5b5..10511928890 100644 --- a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java +++ b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java @@ -56,8 +56,8 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.jaxb.runtime.api.JAXBRIContext; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.glassfish.webservices.LogUtils; import org.glassfish.webservices.WebServiceContractImpl; 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 1ccc4dc6f75..badc3c02b6a 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 @@ -20,7 +20,6 @@ import com.sun.enterprise.admin.remote.reader.ProprietaryReaderFactory; import com.sun.enterprise.admin.remote.writer.ProprietaryWriterFactory; import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.SystemPropertyConstants; @@ -52,6 +51,7 @@ import org.glassfish.api.admin.InvalidCommandException; import org.glassfish.api.admin.ParameterMap; import org.glassfish.common.util.admin.AsadminInput; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.glassfish.main.jul.GlassFishLogManager; import org.glassfish.main.jul.GlassFishLogManagerInitializer; import org.glassfish.main.jul.cfg.GlassFishLogManagerConfiguration; diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ArgumentTokenizer.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ArgumentTokenizer.java index 30d6b089bb9..828d643e926 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ArgumentTokenizer.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ArgumentTokenizer.java @@ -16,10 +16,10 @@ package com.sun.enterprise.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import java.util.NoSuchElementException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + public class ArgumentTokenizer { protected int currentPosition; protected int maxPosition; diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java index afd67311aab..82792d0a675 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLICommand.java @@ -25,7 +25,6 @@ import com.sun.enterprise.admin.util.TokenValue; import com.sun.enterprise.admin.util.TokenValueSet; import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import jakarta.inject.Inject; import jakarta.inject.Scope; @@ -66,6 +65,7 @@ import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.PostConstruct; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Contract; import org.jvnet.hk2.annotations.Service; import org.jvnet.hk2.config.InjectionManager; diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIUtil.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIUtil.java index 7bd72b6f353..c8c291c6cf8 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIUtil.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIUtil.java @@ -18,7 +18,6 @@ package com.sun.enterprise.admin.cli; import com.sun.enterprise.admin.cli.remote.RemoteCLICommand; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.BufferedInputStream; import java.io.BufferedWriter; @@ -46,6 +45,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.api.admin.InvalidCommandException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java index 6d3dfa32df9..505236ad25b 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,8 +17,6 @@ package com.sun.enterprise.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import java.io.File; import java.io.IOException; import java.net.URL; @@ -31,7 +29,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * A class loader that loads classes from all jar files in a specified directory. diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ExportCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ExportCommand.java index bf04e3a4b54..4288e6ad2ec 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ExportCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ExportCommand.java @@ -16,8 +16,6 @@ package com.sun.enterprise.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import java.util.List; import java.util.Map; @@ -25,6 +23,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/HelpCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/HelpCommand.java index 11f7257587f..21022a93729 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/HelpCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/HelpCommand.java @@ -17,8 +17,6 @@ package com.sun.enterprise.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import jakarta.inject.Inject; import java.io.IOException; @@ -33,6 +31,7 @@ import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ListCommandsCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ListCommandsCommand.java index 92cdc3d09d2..8aabc059cfe 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ListCommandsCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ListCommandsCommand.java @@ -16,8 +16,6 @@ package com.sun.enterprise.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import jakarta.inject.Inject; import java.util.ArrayList; @@ -28,6 +26,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; import static com.sun.enterprise.admin.cli.CLIConstants.EOL; diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LoginCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LoginCommand.java index 7d492586255..55e3ac8b1fb 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LoginCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/LoginCommand.java @@ -21,7 +21,6 @@ import com.sun.appserv.management.client.prefs.LoginInfoStore; import com.sun.appserv.management.client.prefs.LoginInfoStoreFactory; import com.sun.enterprise.admin.cli.remote.DASUtils; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.SystemPropertyConstants; import java.io.Console; @@ -30,6 +29,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java index cc80923436b..2313a69ff87 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java @@ -18,7 +18,6 @@ package com.sun.enterprise.admin.cli; import com.sun.enterprise.admin.util.CommandModelData; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import jakarta.inject.Inject; @@ -46,6 +45,7 @@ import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.utilities.BuilderHelper; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Parser.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Parser.java index 4b050480494..acc94e24fd9 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Parser.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Parser.java @@ -18,7 +18,6 @@ package com.sun.enterprise.admin.cli; import com.sun.enterprise.admin.util.CommandModelData.ParamModelData; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.io.FileInputStream; @@ -33,6 +32,7 @@ import org.glassfish.api.admin.CommandModel.ParamModel; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.api.admin.ParameterMap; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * The Parser object is used to parse the command line and verify that the command line is CLIP compliant. diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java index 9a931112455..c14f15a1628 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java @@ -18,7 +18,6 @@ package com.sun.enterprise.admin.cli; import com.sun.enterprise.admin.util.CommandModelData.ParamModelData; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.HostAndPort; @@ -40,6 +39,7 @@ import org.glassfish.api.admin.ParameterMap; import org.glassfish.common.util.admin.AsadminInput; import org.glassfish.common.util.admin.AuthTokenManager; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Representation of the options known to the asadmin program. These options control the overall behavior of asadmin, diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Strings.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Strings.java index 5c6035680e2..d8893eb7553 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Strings.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. One file with Strings So one class for messing with them! Nothing in here is public diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/UnsetCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/UnsetCommand.java index 2afb736a82c..406bb2f87b1 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/UnsetCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/UnsetCommand.java @@ -16,14 +16,13 @@ package com.sun.enterprise.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import java.util.List; import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/VersionCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/VersionCommand.java index a38752aecb6..df751a8d3aa 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/VersionCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/VersionCommand.java @@ -19,13 +19,13 @@ import com.sun.appserv.server.util.Version; import com.sun.enterprise.admin.cli.remote.RemoteCLICommand; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.util.logging.Level; import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/DetachListener.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/DetachListener.java index 9da1432e70f..b56b778e447 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/DetachListener.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/DetachListener.java @@ -18,7 +18,6 @@ import com.sun.enterprise.admin.remote.RemoteRestAdminCommand; import com.sun.enterprise.admin.remote.sse.GfSseInboundEvent; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.StringUtils; import java.io.IOException; @@ -28,6 +27,7 @@ import org.glassfish.api.ActionReport; import org.glassfish.api.admin.AdminCommandEventBroker; import org.glassfish.api.admin.AdminCommandState; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Whenever a command is executed with --detach this class will close the Server Sent Events for detached commands and diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/ProgressStatusPrinter.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/ProgressStatusPrinter.java index 6fe8229e0c4..3bf2d2a38b7 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/ProgressStatusPrinter.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/ProgressStatusPrinter.java @@ -18,7 +18,6 @@ import com.sun.enterprise.admin.progress.ProgressStatusClient; import com.sun.enterprise.admin.remote.sse.GfSseInboundEvent; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.StringUtils; import java.io.IOException; @@ -30,6 +29,7 @@ import org.glassfish.api.admin.CommandProgress; import org.glassfish.api.admin.progress.ProgressStatusDTO; import org.glassfish.api.admin.progress.ProgressStatusEvent; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Prints ProgressStatus changes to given logger diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCLICommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCLICommand.java index c65d6b97603..6c4cf6d3d56 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCLICommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCLICommand.java @@ -34,7 +34,6 @@ import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.single.StaticModulesRegistry; import com.sun.enterprise.security.store.AsadminSecurityUtil; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.StringUtils; import com.sun.enterprise.util.SystemPropertyConstants; @@ -74,6 +73,7 @@ import org.glassfish.hk2.api.ActiveDescriptor; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.utilities.BuilderHelper; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.component.MultiMap; /** diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCommand.java index 17514d4be3a..6e7c2047ec5 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/remote/RemoteCommand.java @@ -33,7 +33,6 @@ import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.single.StaticModulesRegistry; import com.sun.enterprise.security.store.AsadminSecurityUtil; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.SystemPropertyConstants; import java.io.BufferedReader; @@ -66,6 +65,7 @@ import org.glassfish.hk2.api.ActiveDescriptor; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.utilities.BuilderHelper; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * A remote command handled by the asadmin CLI. diff --git a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java index 7d987207b18..671360f1192 100644 --- a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java +++ b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -37,8 +37,8 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; /** * @author Masoud Kalali diff --git a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/PortBaseHelper.java b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/PortBaseHelper.java index 5f024a6faf8..680f2ad29ca 100644 --- a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/PortBaseHelper.java +++ b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/PortBaseHelper.java @@ -18,13 +18,13 @@ import com.sun.enterprise.config.serverbeans.Server; import com.sun.enterprise.config.serverbeans.SystemProperty; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.net.NetUtils; import java.beans.PropertyVetoException; import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.config.TransactionFailure; import static com.sun.enterprise.config.util.PortConstants.ADMIN; diff --git a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/Strings.java b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/Strings.java index 6f0abd2eafd..287edb19aa7 100644 --- a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/Strings.java +++ b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/util/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.config.util; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. One file with Strings So one class for messing with them! Nothing in here is public diff --git a/nucleus/admin/config-api/src/main/java/org/glassfish/config/support/Strings.java b/nucleus/admin/config-api/src/main/java/org/glassfish/config/support/Strings.java index 6a80e739b0c..df0e3efbe4f 100644 --- a/nucleus/admin/config-api/src/main/java/org/glassfish/config/support/Strings.java +++ b/nucleus/admin/config-api/src/main/java/org/glassfish/config/support/Strings.java @@ -16,7 +16,7 @@ package org.glassfish.config.support; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. One file with Strings So one class for messing with them! Nothing in here is public diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java index 906a5b5a365..362ef704deb 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java @@ -20,7 +20,6 @@ import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; import com.sun.enterprise.universal.glassfish.GFLauncherUtils; import com.sun.enterprise.universal.glassfish.TokenResolver; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessStreamDrainer; import com.sun.enterprise.universal.xml.MiniXmlParser; import com.sun.enterprise.universal.xml.MiniXmlParserException; @@ -46,6 +45,8 @@ import java.util.Map; import java.util.Set; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + import static com.sun.enterprise.admin.launcher.GFLauncher.LaunchType.fake; import static com.sun.enterprise.admin.launcher.GFLauncherConstants.DEFAULT_LOGFILE; import static com.sun.enterprise.admin.launcher.GFLauncherConstants.FLASHLIGHT_AGENT_NAME; diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherException.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherException.java index 58abc301139..80b41cd190c 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherException.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherException.java @@ -16,7 +16,7 @@ package com.sun.enterprise.admin.launcher; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * The one and only type of Exception that will be thrown out of this package. I18N is wired in. If a String message is diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherLogger.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherLogger.java index 6509ccb4ee7..79859ebc5ab 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherLogger.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherLogger.java @@ -17,8 +17,6 @@ package com.sun.enterprise.admin.launcher; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; - import java.io.IOException; import java.util.logging.FileHandler; import java.util.logging.Handler; @@ -29,6 +27,7 @@ import org.glassfish.logging.annotation.LogMessageInfo; import org.glassfish.logging.annotation.LogMessagesResourceBundle; import org.glassfish.logging.annotation.LoggerInfo; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.glassfish.main.jul.formatter.ODLLogFormatter; import org.glassfish.main.jul.handler.SimpleLogHandler; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeAdminPasswordCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeAdminPasswordCommand.java index 9817def2c10..0cef12566e7 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeAdminPasswordCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeAdminPasswordCommand.java @@ -23,7 +23,6 @@ import com.sun.enterprise.admin.launcher.GFLauncherInfo; import com.sun.enterprise.admin.remote.RemoteRestAdminCommand; import com.sun.enterprise.config.serverbeans.SecureAdmin; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.xml.MiniXmlParserException; import com.sun.enterprise.util.SystemPropertyConstants; import com.sun.enterprise.util.net.NetUtils; @@ -39,6 +38,7 @@ import org.glassfish.api.admin.ParameterMap; import org.glassfish.api.admin.RuntimeType; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.glassfish.security.common.FileRealmHelper; import org.jvnet.hk2.annotations.Service; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommand.java index f53a6432c26..be6677b38ed 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommand.java @@ -17,7 +17,6 @@ package com.sun.enterprise.admin.servermgmt.cli; import com.sun.enterprise.admin.cli.CLICommand; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.io.DomainDirs; import jakarta.inject.Inject; @@ -31,6 +30,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommandDAS.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommandDAS.java index 38bfa2ad8a0..b756721b78b 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommandDAS.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ChangeMasterPasswordCommandDAS.java @@ -19,13 +19,13 @@ import com.sun.enterprise.admin.servermgmt.DomainConfig; import com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.util.HostAndPort; import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateDomainCommand.java index b0af9623112..d92fa59a4c0 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateDomainCommand.java @@ -30,7 +30,6 @@ import com.sun.enterprise.admin.servermgmt.domain.DomainBuilder; import com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager; import com.sun.enterprise.admin.util.CommandModelData.ParamModelData; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.SystemPropertyConstants; import com.sun.enterprise.util.io.FileUtils; import com.sun.enterprise.util.net.NetUtils; @@ -49,6 +48,7 @@ import org.glassfish.api.admin.CommandModel.ParamModel; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.glassfish.security.common.FileRealmHelper; import org.jvnet.hk2.annotations.Service; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateServiceCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateServiceCommand.java index 79eb61688c1..dbd7f33b256 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateServiceCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/CreateServiceCommand.java @@ -22,7 +22,6 @@ import com.sun.enterprise.admin.servermgmt.services.Service; import com.sun.enterprise.admin.servermgmt.services.ServiceFactory; import com.sun.enterprise.admin.util.ServerDirsSelector; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.OS; import com.sun.enterprise.util.SystemPropertyConstants; @@ -35,6 +34,7 @@ import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Create a "service" in the operating system to start this domain automatically. diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteDomainCommand.java index d6746ef943c..391707e1ff5 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteDomainCommand.java @@ -20,7 +20,6 @@ import com.sun.enterprise.admin.servermgmt.DomainConfig; import com.sun.enterprise.admin.servermgmt.DomainsManager; import com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.util.HostAndPort; @@ -31,6 +30,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteServiceCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteServiceCommand.java index 6f7512de9d7..55048dd6f14 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteServiceCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DeleteServiceCommand.java @@ -22,7 +22,6 @@ import com.sun.enterprise.admin.servermgmt.services.Service; import com.sun.enterprise.admin.servermgmt.services.ServiceFactory; import com.sun.enterprise.admin.util.ServerDirsSelector; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.OS; import com.sun.enterprise.util.io.FileUtils; @@ -34,6 +33,7 @@ import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Delete a "service" in the operating system. diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DomainXmlVerifier.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DomainXmlVerifier.java index 4a64ac9d8a1..c9497800dfd 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DomainXmlVerifier.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/DomainXmlVerifier.java @@ -18,7 +18,6 @@ // config imports import com.sun.enterprise.config.serverbeans.Domain; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.Result; import java.io.PrintStream; @@ -29,6 +28,7 @@ import java.util.Set; import java.util.WeakHashMap; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.config.ConfigBeanProxy; import org.jvnet.hk2.config.Dom; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ListDomainsCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ListDomainsCommand.java index 4549e7a8646..4f90a9de7e8 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ListDomainsCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/ListDomainsCommand.java @@ -21,7 +21,6 @@ import com.sun.enterprise.admin.servermgmt.DomainConfig; import com.sun.enterprise.admin.servermgmt.DomainsManager; import com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.ColumnFormatter; import com.sun.enterprise.util.HostAndPort; import com.sun.enterprise.util.io.DomainDirs; @@ -33,6 +32,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalServerCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalServerCommand.java index 68e22fc0425..9de47cbb38b 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalServerCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/LocalServerCommand.java @@ -22,7 +22,6 @@ import com.sun.enterprise.admin.cli.ProgramOptions; import com.sun.enterprise.admin.cli.remote.RemoteCLICommand; import com.sun.enterprise.security.store.PasswordAdapter; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.universal.xml.MiniXmlParser; @@ -42,6 +41,7 @@ import org.glassfish.api.ActionReport; import org.glassfish.api.ActionReport.ExitCode; import org.glassfish.api.admin.CommandException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import static com.sun.enterprise.admin.cli.CLIConstants.DEFAULT_ADMIN_PORT; import static com.sun.enterprise.admin.cli.CLIConstants.DEFAULT_HOSTNAME; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorCommand.java index 176d9d9bb46..fbed25507d0 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorCommand.java @@ -18,7 +18,6 @@ package com.sun.enterprise.admin.servermgmt.cli; import com.sun.enterprise.admin.cli.CLICommand; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.BufferedReader; import java.io.File; @@ -32,6 +31,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorTask.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorTask.java index b3a21144962..a578ee07ce2 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorTask.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/MonitorTask.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.cli.Environment; import com.sun.enterprise.admin.cli.ProgramOptions; import com.sun.enterprise.admin.cli.remote.RemoteCLICommand; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.util.Timer; @@ -28,6 +27,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import static com.sun.enterprise.admin.servermgmt.SLogger.MONITOR_MEMORY_TITLE; import static com.sun.enterprise.admin.servermgmt.SLogger.MONITOR_TITLE; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/RestartDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/RestartDomainCommand.java index 9655fad3c2a..a2733e7f4fa 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/RestartDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/RestartDomainCommand.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.cli.CLICommand; import com.sun.enterprise.admin.cli.remote.RemoteCLICommand; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.HostAndPort; import jakarta.inject.Inject; @@ -31,6 +30,7 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java index f5f5ddebb5e..0449e383d67 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java @@ -23,7 +23,6 @@ import com.sun.enterprise.admin.launcher.GFLauncherFactory; import com.sun.enterprise.admin.launcher.GFLauncherInfo; import com.sun.enterprise.admin.util.CommandModelData.ParamModelData; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessStreamDrainer; import com.sun.enterprise.universal.xml.MiniXmlParserException; @@ -43,6 +42,7 @@ import org.glassfish.api.admin.RuntimeType; import org.glassfish.api.admin.ServerEnvironment; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.glassfish.security.common.FileRealmHelper; import org.jvnet.hk2.annotations.Service; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java index fa8df2aed17..8067c06a87c 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartServerHelper.java @@ -20,7 +20,6 @@ import com.sun.enterprise.admin.launcher.GFLauncher; import com.sun.enterprise.admin.launcher.GFLauncherException; import com.sun.enterprise.admin.launcher.GFLauncherInfo; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessStreamDrainer; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.util.HostAndPort; @@ -38,6 +37,7 @@ import java.util.function.Supplier; import org.glassfish.api.admin.CommandException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import static com.sun.enterprise.admin.cli.CLIConstants.DEATH_TIMEOUT_MS; import static com.sun.enterprise.admin.cli.CLIConstants.MASTER_PASSWORD; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/Strings.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/Strings.java index 466b568cc75..97aa744603f 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/Strings.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.admin.servermgmt.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. One file with Strings So one class for messing with them! Nothing in here is public diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java index 1c4772f2ac8..221ecc5a044 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -32,9 +32,9 @@ import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.internal.api.Globals; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.jvnet.hk2.annotations.Service; import org.jvnet.hk2.config.ConfigParser; import org.jvnet.hk2.config.Dom; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/Strings.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/Strings.java index d442d8dbbcd..22d0fdb76dc 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/Strings.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/services/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.admin.servermgmt.services; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Package-wide String getter diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/ArchiveEntryWrapperImpl.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/ArchiveEntryWrapperImpl.java index c7a0f0aa2d6..4fa60830ccf 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/ArchiveEntryWrapperImpl.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/ArchiveEntryWrapperImpl.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.servermgmt.SLogger; import com.sun.enterprise.admin.servermgmt.xml.stringsubs.Archive; import com.sun.enterprise.admin.servermgmt.xml.stringsubs.MemberEntry; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.BufferedOutputStream; import java.io.File; @@ -42,6 +41,7 @@ import java.util.logging.Logger; import org.glassfish.api.logging.LogHelper; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Handles the operation related with an archive string substitution process. i.e extracting the substitutable entries diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileEntryFactory.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileEntryFactory.java index b85252dfcc8..5ffa834da49 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileEntryFactory.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileEntryFactory.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.servermgmt.SLogger; import com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable; import com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.io.FileNotFoundException; @@ -32,6 +31,7 @@ import java.util.regex.Pattern; import org.glassfish.api.logging.LogHelper; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Factory class to get the files that has to undergo string substitution. diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileLister.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileLister.java index 177a3aa1e94..016b1dcefad 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileLister.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileLister.java @@ -17,7 +17,6 @@ package com.sun.enterprise.admin.servermgmt.stringsubs.impl; import com.sun.enterprise.admin.servermgmt.SLogger; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.io.FilenameFilter; @@ -27,6 +26,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * Class to retrieve all the matching files for a given input path. It also handles the processing of wild-card in the * given path. diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileSubstitutionHandler.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileSubstitutionHandler.java index 5933085d99c..bf1a364a999 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileSubstitutionHandler.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileSubstitutionHandler.java @@ -18,7 +18,6 @@ import com.sun.enterprise.admin.servermgmt.SLogger; import com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.io.FileNotFoundException; @@ -27,6 +26,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * Abstract class initialize the input file for the string substitution. The sub-classes provides the way to create the * {@link Reader} and {@link Writer} for the input & output file. diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionEngine.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionEngine.java index 13b7b3c6e6a..c95bc415a6c 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionEngine.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionEngine.java @@ -35,7 +35,6 @@ import com.sun.enterprise.admin.servermgmt.xml.stringsubs.Property; import com.sun.enterprise.admin.servermgmt.xml.stringsubs.PropertyType; import com.sun.enterprise.admin.servermgmt.xml.stringsubs.StringsubsDefinition; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.io.InputStream; @@ -49,6 +48,7 @@ import java.util.logging.Logger; import org.glassfish.api.logging.LogHelper; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * A class to encapsulate string-subs definition. Parse, validate and performs String substitution for the given diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionParser.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionParser.java index 9960e303fde..0f2a80f2008 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionParser.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionParser.java @@ -20,7 +20,6 @@ import com.sun.enterprise.admin.servermgmt.SLogger; import com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException; import com.sun.enterprise.admin.servermgmt.xml.stringsubs.StringsubsDefinition; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBElement; @@ -38,6 +37,7 @@ import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.xml.sax.InputSource; import org.xml.sax.SAXException; diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/SubstitutionFileUtil.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/SubstitutionFileUtil.java index 798af800324..73595195b33 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/SubstitutionFileUtil.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/SubstitutionFileUtil.java @@ -17,13 +17,14 @@ package com.sun.enterprise.admin.servermgmt.stringsubs.impl; import com.sun.enterprise.admin.servermgmt.SLogger; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * Utility class for the substitutable files. */ diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTree.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTree.java index 5a1e4388fd3..acd56bdc6ee 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTree.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTree.java @@ -17,11 +17,12 @@ package com.sun.enterprise.admin.servermgmt.stringsubs.impl.algorithm; import com.sun.enterprise.admin.servermgmt.SLogger; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * This class implements the operation of a radix tree. A radix tree is a specialized set data structure based on the * tree/trie that is used to store a set of strings. The key for nodes of a radix tree are labeled with one or more diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeNode.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeNode.java index b4b5ff4ddf2..cdc97a76e01 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeNode.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeNode.java @@ -17,7 +17,6 @@ package com.sun.enterprise.admin.servermgmt.stringsubs.impl.algorithm; import com.sun.enterprise.admin.servermgmt.SLogger; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.util.Collection; import java.util.Collections; @@ -27,6 +26,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * Node for {@link RadixTree}. */ diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionAlgo.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionAlgo.java index 3cba2bd4bd5..b02a12b6eb9 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionAlgo.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionAlgo.java @@ -19,13 +19,14 @@ import com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException; import com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable; import com.sun.enterprise.admin.servermgmt.stringsubs.SubstitutionAlgorithm; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.IOException; import java.io.Reader; import java.io.Writer; import java.util.Map; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * Perform's string substitution by constructing the {@link RadixTree} of change-value pair. * diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java index 3db52eeb8b4..c1abd30aba0 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java @@ -19,7 +19,6 @@ import com.sun.enterprise.admin.servermgmt.DomainException; import com.sun.enterprise.admin.servermgmt.xml.templateinfo.TemplateInfo; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBElement; @@ -33,6 +32,7 @@ import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.xml.sax.InputSource; public class TemplateInfoHolder { diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/progress/ProgressStatusClient.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/progress/ProgressStatusClient.java index 912c384a26b..3951ad07c23 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/progress/ProgressStatusClient.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/progress/ProgressStatusClient.java @@ -16,7 +16,6 @@ package com.sun.enterprise.admin.progress; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.StringUtils; import java.util.HashMap; @@ -28,6 +27,7 @@ import org.glassfish.api.admin.progress.ProgressStatusDTO; import org.glassfish.api.admin.progress.ProgressStatusEvent; import org.glassfish.api.admin.progress.ProgressStatusEventCreateChild; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Provides mirroring of events into given ProgressStatus substructure. Never rewrites name in base ProgressStatus (i.e. diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/PlainTextManager.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/PlainTextManager.java index 5e3ee81e491..61cb7155a1f 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/PlainTextManager.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/PlainTextManager.java @@ -17,7 +17,8 @@ package com.sun.enterprise.admin.remote; import com.sun.enterprise.universal.collections.ManifestUtils; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; + +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java index c5499e77cda..d9b837b6944 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteAdminCommand.java @@ -24,7 +24,6 @@ import com.sun.enterprise.admin.util.HttpConnectorAddress; import com.sun.enterprise.admin.util.cache.AdminCacheUtils; import com.sun.enterprise.config.serverbeans.SecureAdmin; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.io.FileUtils; import com.sun.enterprise.util.net.NetUtils; @@ -76,6 +75,7 @@ import org.glassfish.api.admin.Payload; import org.glassfish.common.util.HttpParser; import org.glassfish.common.util.admin.AuthTokenManager; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteResponseManager.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteResponseManager.java index bd7c397a497..d7ea5a1ab77 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteResponseManager.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteResponseManager.java @@ -17,7 +17,6 @@ package com.sun.enterprise.admin.remote; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.io.FileUtils; import java.io.ByteArrayInputStream; @@ -29,6 +28,8 @@ import java.util.Map; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + import static com.sun.enterprise.util.StringUtils.ok; /** diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java index 818e26e9a01..c15807eccd5 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/remote/RemoteRestAdminCommand.java @@ -33,7 +33,6 @@ import com.sun.enterprise.admin.util.HttpConnectorAddress; import com.sun.enterprise.admin.util.cache.AdminCacheUtils; import com.sun.enterprise.config.serverbeans.SecureAdmin; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.StringUtils; import com.sun.enterprise.util.net.NetUtils; @@ -79,6 +78,7 @@ import org.glassfish.api.admin.ParameterMap; import org.glassfish.api.admin.Payload; import org.glassfish.common.util.admin.AuthTokenManager; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import static java.util.logging.Level.FINER; import static java.util.logging.Level.FINEST; diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/AsadminTrustManager.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/AsadminTrustManager.java index 1d9bb96ae27..771f4de6821 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/AsadminTrustManager.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/AsadminTrustManager.java @@ -17,7 +17,6 @@ package com.sun.enterprise.admin.util; import com.sun.enterprise.security.store.AsadminTruststore; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.Console; import java.io.IOException; @@ -29,6 +28,8 @@ import javax.net.ssl.X509TrustManager; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * An implementation of {@link X509TrustManager} that provides basic support for Trust Management. It checks if the * server is trusted and displays the certificate that was received from the server. The user is then prompted to diff --git a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/Strings.java b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/Strings.java index 3276e9b680d..1812b2550a4 100644 --- a/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/Strings.java +++ b/nucleus/admin/util/src/main/java/com/sun/enterprise/admin/util/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.admin.util; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. One file with Strings So one class for messing with them! Nothing in here is public diff --git a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/Strings.java b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/Strings.java index fea82e30a4a..e58f56396fa 100644 --- a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/Strings.java +++ b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.v3.admin.cluster; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/ChangeNodeMasterPasswordCommand.java b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/ChangeNodeMasterPasswordCommand.java index be1fa1fa453..88bbf9cfd0e 100644 --- a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/ChangeNodeMasterPasswordCommand.java +++ b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/ChangeNodeMasterPasswordCommand.java @@ -21,7 +21,6 @@ import com.sun.enterprise.admin.servermgmt.RepositoryConfig; import com.sun.enterprise.admin.util.CommandModelData.ParamModelData; import com.sun.enterprise.security.store.PasswordAdapter; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.universal.xml.MiniXmlParser; import com.sun.enterprise.universal.xml.MiniXmlParserException; @@ -34,6 +33,7 @@ import org.glassfish.api.Param; import org.glassfish.api.admin.CommandException; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/Strings.java b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/Strings.java index d4406a2d5dd..e84dd79aab0 100644 --- a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/Strings.java +++ b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/Strings.java @@ -17,7 +17,7 @@ package com.sun.enterprise.admin.cli.cluster; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/cluster/common/src/main/java/com/sun/enterprise/util/cluster/Strings.java b/nucleus/cluster/common/src/main/java/com/sun/enterprise/util/cluster/Strings.java index 71d503b6c11..68a3f2364a2 100644 --- a/nucleus/cluster/common/src/main/java/com/sun/enterprise/util/cluster/Strings.java +++ b/nucleus/cluster/common/src/main/java/com/sun/enterprise/util/cluster/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.util.cluster; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/connect/Strings.java b/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/connect/Strings.java index 3ab558f840e..7dc731122ae 100644 --- a/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/connect/Strings.java +++ b/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/connect/Strings.java @@ -15,7 +15,7 @@ */ package org.glassfish.cluster.ssh.connect; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/Strings.java b/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/Strings.java index 44665db5ef7..a7b94716b6e 100644 --- a/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/Strings.java +++ b/nucleus/cluster/ssh/src/main/java/org/glassfish/cluster/ssh/util/Strings.java @@ -16,7 +16,7 @@ package org.glassfish.cluster.ssh.util; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java index 3630f39725a..993c9ce78df 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java @@ -68,8 +68,8 @@ import java.util.zip.ZipEntry; import org.glassfish.api.deployment.InstrumentableClassLoader; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.hk2.api.PreDestroy; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import static java.util.logging.Level.INFO; diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/AsadminSecurityUtil.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/AsadminSecurityUtil.java index 064f7a8372e..4e4b23e6a31 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/AsadminSecurityUtil.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/security/store/AsadminSecurityUtil.java @@ -17,7 +17,6 @@ package com.sun.enterprise.security.store; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.CULoggerInfo; import com.sun.enterprise.util.io.FileUtils; @@ -36,6 +35,8 @@ import java.security.cert.CertificateException; import java.util.logging.Logger; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + import static com.sun.enterprise.util.SystemPropertyConstants.CLIENT_TRUSTSTORE_PASSWORD_PROPERTY; import static com.sun.enterprise.util.SystemPropertyConstants.KEYSTORE_PROPERTY; diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/Duration.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/Duration.java index 21f2cfcffa2..64230ba4285 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/Duration.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/Duration.java @@ -16,7 +16,7 @@ package com.sun.enterprise.universal; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Convert a msec duration into weeks, hours, minutes, seconds diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java index ea2c1510adb..f0d62a62045 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/xml/MiniXmlParser.java @@ -19,7 +19,6 @@ import com.sun.common.util.logging.LoggingConfigImpl; import com.sun.enterprise.universal.glassfish.GFLauncherUtils; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.HostAndPort; import com.sun.enterprise.util.StringUtils; @@ -42,6 +41,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.glassfish.main.jul.handler.GlassFishLogHandlerProperty; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/Strings.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/Strings.java index a9b82595974..65c2f0c6b13 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/Strings.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.util; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/DomainDirs.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/DomainDirs.java index be1ba3c6452..df1ea203d85 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/DomainDirs.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/DomainDirs.java @@ -17,7 +17,6 @@ package com.sun.enterprise.util.io; import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.SystemPropertyConstants; import java.io.File; @@ -25,6 +24,8 @@ import java.io.IOException; import java.util.Map; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + /** * A class for keeping track of the directories that a domain lives in and under. * diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java index e8d9ebaa232..2698bc493dd 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/ServerDirs.java @@ -17,7 +17,6 @@ package com.sun.enterprise.util.io; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.ObjectAnalyzer; @@ -26,6 +25,8 @@ import java.io.FileReader; import java.io.IOException; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; + import static java.nio.charset.StandardCharsets.UTF_8; /** diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/Strings.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/Strings.java index 300ee6699fb..acbc05aa8a7 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/Strings.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/io/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.util.io; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/reflect/Strings.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/reflect/Strings.java index 7b4e0015f4d..a7129aea5fa 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/reflect/Strings.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/reflect/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.util.reflect; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/admin/ServerEnvironment.java b/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/admin/ServerEnvironment.java index c9c2ea36f4f..3368aa1d5a9 100644 --- a/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/admin/ServerEnvironment.java +++ b/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/admin/ServerEnvironment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -32,7 +32,7 @@ */ @Contract public interface ServerEnvironment { - public enum Status { + enum Status { starting, started, stopping, stopped } diff --git a/nucleus/common/glassfish-jdk-extensions/pom.xml b/nucleus/common/glassfish-jdk-extensions/pom.xml new file mode 100755 index 00000000000..c93e0d96ee0 --- /dev/null +++ b/nucleus/common/glassfish-jdk-extensions/pom.xml @@ -0,0 +1,44 @@ + + + + + 4.0.0 + + + org.glassfish.main.common + nucleus-common + 7.0.19-SNAPSHOT + + + glassfish-jdk-extensions + glassfish-jar + + GlassFish JDK Extensions + Things we would like to see in JDK + + + + org.junit.jupiter + junit-jupiter-engine + + + org.hamcrest + hamcrest + + + diff --git a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/GlassfishUrlClassLoader.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/cl/GlassfishUrlClassLoader.java similarity index 88% rename from nucleus/common/common-util/src/main/java/org/glassfish/common/util/GlassfishUrlClassLoader.java rename to nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/cl/GlassfishUrlClassLoader.java index 0024da32ac2..9e3a9997a74 100644 --- a/nucleus/common/common-util/src/main/java/org/glassfish/common/util/GlassfishUrlClassLoader.java +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/cl/GlassfishUrlClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package org.glassfish.common.util; +package org.glassfish.main.jdke.cl; import java.io.Closeable; import java.io.IOException; @@ -51,33 +51,36 @@ public class GlassfishUrlClassLoader extends URLClassLoader { /** * Initializes the internal classpath. * + * @param name * @param urls */ - public GlassfishUrlClassLoader(URL[] urls) { - super(urls); + public GlassfishUrlClassLoader(String name, URL[] urls) { + super(name, urls, ClassLoader.getSystemClassLoader()); } /** * Initializes the internal classpath. * + * @param name * @param urls * @param parent */ - public GlassfishUrlClassLoader(URL[] urls, ClassLoader parent) { - super(urls, parent); + public GlassfishUrlClassLoader(String name, URL[] urls, ClassLoader parent) { + super(name, urls, parent); } /** * Initializes the internal classpath. * + * @param name * @param urls * @param parent * @param factory */ - public GlassfishUrlClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { - super(urls, parent, factory); + public GlassfishUrlClassLoader(String name, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { + super(name, urls, parent, factory); } // turn protected to public diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/i18n/LocalStrings.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStrings.java similarity index 97% rename from nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/i18n/LocalStrings.java rename to nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStrings.java index 40140b99b30..872749533d9 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/i18n/LocalStrings.java +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStrings.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -14,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.universal.i18n; +package org.glassfish.main.jdke.i18n; /** * This class makes getting localized strings super-simple. All methods are static. diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/i18n/LocalStringsImpl.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java similarity index 98% rename from nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/i18n/LocalStringsImpl.java rename to nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java index c837d3e0e0a..019ef61e35f 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/i18n/LocalStringsImpl.java +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.universal.i18n; +package org.glassfish.main.jdke.i18n; import java.text.MessageFormat; import java.util.Locale; diff --git a/nucleus/common/common-util/src/test/java/org/glassfish/common/util/GlassfishUrlClassLoaderTest.java b/nucleus/common/glassfish-jdk-extensions/src/test/java/org/glassfish/main/jdke/cl/GlassfishUrlClassLoaderTest.java similarity index 80% rename from nucleus/common/common-util/src/test/java/org/glassfish/common/util/GlassfishUrlClassLoaderTest.java rename to nucleus/common/glassfish-jdk-extensions/src/test/java/org/glassfish/main/jdke/cl/GlassfishUrlClassLoaderTest.java index 9b879fe6962..ee87e481f43 100644 --- a/nucleus/common/common-util/src/test/java/org/glassfish/common/util/GlassfishUrlClassLoaderTest.java +++ b/nucleus/common/glassfish-jdk-extensions/src/test/java/org/glassfish/main/jdke/cl/GlassfishUrlClassLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package org.glassfish.common.util; +package org.glassfish.main.jdke.cl; import java.net.URL; import java.net.URLClassLoader; @@ -33,7 +33,7 @@ public class GlassfishUrlClassLoaderTest { public void isParallel() { assertAll( () -> assertTrue(new URLClassLoader(new URL[0]).isRegisteredAsParallelCapable()), - () -> assertTrue(new GlassfishUrlClassLoader(new URL[0]).isRegisteredAsParallelCapable()) + () -> assertTrue(new GlassfishUrlClassLoader("GlassfishUrlClassLoaderTest", new URL[0]).isRegisteredAsParallelCapable()) ); } } diff --git a/nucleus/common/pom.xml b/nucleus/common/pom.xml index 3d26271ee8a..c56252eeb32 100755 --- a/nucleus/common/pom.xml +++ b/nucleus/common/pom.xml @@ -33,6 +33,7 @@ GlassFish Nucleus Common modules + glassfish-jdk-extensions simple-glassfish-api internal-api common-util diff --git a/nucleus/common/simple-glassfish-api/README b/nucleus/common/simple-glassfish-api/README deleted file mode 100644 index 324394082ff..00000000000 --- a/nucleus/common/simple-glassfish-api/README +++ /dev/null @@ -1 +0,0 @@ -The contents of this module is bundled by core/bootstrap module viz., glassfish.jar diff --git a/nucleus/core/bootstrap-osgi/pom.xml b/nucleus/core/bootstrap-osgi/pom.xml new file mode 100755 index 00000000000..3dd32a7cc52 --- /dev/null +++ b/nucleus/core/bootstrap-osgi/pom.xml @@ -0,0 +1,112 @@ + + + + + 4.0.0 + + + org.glassfish.main.core + nucleus-core + 7.0.19-SNAPSHOT + + + glassfish-osgi-bootstrap + glassfish-jar + + Appserver Core OSGI Bootstraping + + + + org.glassfish.main.core + glassfish + ${project.version} + provided + + + org.glassfish.hk2 + hk2-core + + + org.glassfish.hk2 + hk2-extras + provided + + + org.osgi + osgi.core + provided + + + + org.glassfish.main.common + simple-glassfish-api + ${project.version} + + + org.glassfish.main.common + common-util + ${project.version} + + + org.glassfish.main.common + glassfish-api + + + + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + provided + + + org.glassfish.annotations + logging-annotation-processor + true + + + + org.junit.jupiter + junit-jupiter-engine + + + org.hamcrest + hamcrest + + + org.apache.felix + org.apache.felix.main + test + + + + + + + org.apache.felix + maven-bundle-plugin + + + org.glassfish.main.boot.osgi.GlassFishMainActivator + + + + + + diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/AutoDisposableGlassFish.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/AutoDisposableGlassFish.java similarity index 96% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/AutoDisposableGlassFish.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/AutoDisposableGlassFish.java index f9eb3420c1a..3daebd3bab0 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/AutoDisposableGlassFish.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/AutoDisposableGlassFish.java @@ -14,9 +14,8 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.embedded; +package org.glassfish.main.boot.embedded; -import com.sun.enterprise.glassfish.bootstrap.GlassFishImpl; import com.sun.enterprise.module.bootstrap.ModuleStartup; import java.io.File; @@ -33,6 +32,7 @@ import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishProperties; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.boot.impl.GlassFishImpl; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.AUTO_DELETE; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedGlassFishRuntime.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntime.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedGlassFishRuntime.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntime.java index 68c3b46af53..ddc5142167b 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedGlassFishRuntime.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntime.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.embedded; +package org.glassfish.main.boot.embedded; import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; @@ -64,7 +64,7 @@ class EmbeddedGlassFishRuntime extends GlassFishRuntime { private final Map glassFishInstances = new ConcurrentHashMap<>(); private final Main main; - public EmbeddedGlassFishRuntime(Main main) { + EmbeddedGlassFishRuntime(Main main) { this.main = main; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedGlassFishRuntimeBuilder.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntimeBuilder.java similarity index 83% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedGlassFishRuntimeBuilder.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntimeBuilder.java index 63681e82857..c86c6ae4d81 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedGlassFishRuntimeBuilder.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntimeBuilder.java @@ -15,14 +15,13 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.embedded; +package org.glassfish.main.boot.embedded; import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; -import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextUtil; +import com.sun.enterprise.glassfish.bootstrap.cfg.ServerFiles; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; import com.sun.enterprise.module.ModulesRegistry; -import com.sun.enterprise.module.bootstrap.Main; import com.sun.enterprise.module.common_impl.AbstractFactory; import java.io.File; @@ -34,11 +33,11 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.embeddable.BootstrapProperties; import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishRuntime; import org.glassfish.embeddable.spi.RuntimeBuilder; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; /** * @author bhavanishankar@dev.java.net @@ -53,13 +52,8 @@ public class EmbeddedGlassFishRuntimeBuilder implements RuntimeBuilder { @Override public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishException { - /* Step 1. Build the classloader. */ - // The classloader should contain installRoot/modules/**/*.jar files. String installRoot = getInstallRoot(bsProps); - if (installRoot != null) { - System.setProperty("org.glassfish.embeddable.installRoot", installRoot); - } - // Required to add moduleJarURLs to support 'java -jar modules/glassfish.jar case' + // Required to add moduleJarURLs to support 'java -jar glassfish.jar case' List moduleJarURLs = getModuleJarURLs(installRoot); final ClassLoader cl; if (moduleJarURLs.isEmpty()) { @@ -67,21 +61,30 @@ public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishExcep } else { cl = new EmbeddedClassLoader(getClass().getClassLoader(), moduleJarURLs); } + return build(bsProps, cl, installRoot); + } + + @Override + public GlassFishRuntime build(BootstrapProperties bsProps, ClassLoader cl) throws GlassFishException { + String installRoot = getInstallRoot(bsProps); + return build(bsProps, cl, installRoot); + } + + private GlassFishRuntime build(BootstrapProperties bsProps, ClassLoader cl, String installRoot) { + if (installRoot != null) { + System.setProperty("org.glassfish.embeddable.installRoot", installRoot); + } // Step 2. Setup the module subsystem. - Main main = new EmbeddedMain(); SingleHK2Factory.initialize(cl); ModulesRegistry modulesRegistry = AbstractFactory.getInstance().createModulesRegistry(); modulesRegistry.setParentClassLoader(cl); // Step 3. Create NonOSGIGlassFishRuntime - GlassFishRuntime glassFishRuntime = new EmbeddedGlassFishRuntime(main); - LOG.logp(Level.FINER, getClass().getName(), "build", - "Created GlassFishRuntime {0} with InstallRoot {1}, Bootstrap Options {2}", - new Object[]{glassFishRuntime, installRoot, bsProps}); - return glassFishRuntime; + return new EmbeddedGlassFishRuntime(new EmbeddedMain()); } + @Override public boolean handles(BootstrapProperties bsProps) { // See GLASSFISH-16743 for the reason behind additional check @@ -97,7 +100,7 @@ public boolean handles(BootstrapProperties bsProps) { private String getInstallRoot(BootstrapProperties props) { String installRootProp = props.getInstallRoot(); if (installRootProp == null) { - File installRoot = StartupContextUtil.detectInstallRoot(); + File installRoot = ServerFiles.detectInstallRoot(); if (isValidInstallRoot(installRoot)) { installRootProp = installRoot.getAbsolutePath(); } @@ -144,9 +147,12 @@ private boolean isValidInstallRoot(File installRoot) { } private static class EmbeddedClassLoader extends GlassfishUrlClassLoader { + static { + registerAsParallelCapable(); + } - EmbeddedClassLoader(ClassLoader parent, List moduleJarURLs) { - super(moduleJarURLs.toArray(URL[]::new), parent); + private EmbeddedClassLoader(ClassLoader parent, List moduleJarURLs) { + super("EmbeddedCL", moduleJarURLs.toArray(URL[]::new), parent); } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedInhabitantsParser.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedInhabitantsParser.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedInhabitantsParser.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedInhabitantsParser.java index c44dc4b7bee..357a9a45014 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedInhabitantsParser.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedInhabitantsParser.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.embedded; +package org.glassfish.main.boot.embedded; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedMain.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedMain.java similarity index 96% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedMain.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedMain.java index 867f24dfe26..628263ad4d7 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/EmbeddedMain.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedMain.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.embedded; +package org.glassfish.main.boot.embedded; import com.sun.enterprise.module.bootstrap.BootException; import com.sun.enterprise.module.bootstrap.Main; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/JarUtil.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/JarUtil.java similarity index 99% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/JarUtil.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/JarUtil.java index 10bd0dc6fd4..08959c3e13a 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/JarUtil.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/JarUtil.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.embedded; +package org.glassfish.main.boot.embedded; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/SingleHK2Factory.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/SingleHK2Factory.java similarity index 97% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/SingleHK2Factory.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/SingleHK2Factory.java index 69b57f035d8..ec56fc1061b 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/embedded/SingleHK2Factory.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/SingleHK2Factory.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.embedded; +package org.glassfish.main.boot.embedded; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; import com.sun.enterprise.module.ModuleDefinition; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishImpl.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/impl/GlassFishImpl.java similarity index 99% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishImpl.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/impl/GlassFishImpl.java index 0587528d6fe..fbf2b930325 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishImpl.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/impl/GlassFishImpl.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap; +package org.glassfish.main.boot.impl; import com.sun.enterprise.module.bootstrap.ModuleStartup; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisioner.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisioner.java similarity index 99% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisioner.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisioner.java index 9509601a45e..e8355f0bc07 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisioner.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisioner.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisionerCustomizer.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisionerCustomizer.java similarity index 97% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisionerCustomizer.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisionerCustomizer.java index 4d8e20bc477..984f14dfbcb 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisionerCustomizer.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisionerCustomizer.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import java.net.URI; import java.util.List; @@ -66,4 +66,4 @@ interface BundleProvisionerCustomizer { * @return start level of this bundle. -1 if not known */ Integer getStartLevel(Jar jar); -} \ No newline at end of file +} diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/DefaultBundleProvisionerCustomizer.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/DefaultBundleProvisionerCustomizer.java similarity index 96% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/DefaultBundleProvisionerCustomizer.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/DefaultBundleProvisionerCustomizer.java index 8e0c69401e6..d7f809e7a75 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/DefaultBundleProvisionerCustomizer.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/DefaultBundleProvisionerCustomizer.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; @@ -85,8 +85,11 @@ class DefaultBundleProvisionerCustomizer implements BundleProvisionerCustomizer this.config = config; // for optimization reasons, process these properties once and store their values processAutoInstallLocations(); + LOG.log(Level.CONFIG, () -> "autoInstallLocations:\n" + autoInstallLocations); processAutoStartLocations(); + LOG.log(Level.CONFIG, () -> "autoStartLocations:\n" + autoStartLocations); processStartLevels(); + LOG.log(Level.CONFIG, () -> "configuredAutoInstallLocations:\n" + configuredAutoInstallLocations); } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishImpl.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishImpl.java index ce1a19b2592..29d7785d9e0 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishImpl.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishImpl.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishRuntime.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntime.java similarity index 96% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishRuntime.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntime.java index 3e3631c49ec..499e8bd771d 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishRuntime.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntime.java @@ -15,11 +15,9 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.GlassFishImpl; import com.sun.enterprise.glassfish.bootstrap.cfg.AsenvConf; -import com.sun.enterprise.glassfish.bootstrap.cp.GlassfishBootstrapClassLoader; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.bootstrap.BootException; import com.sun.enterprise.module.bootstrap.Main; @@ -41,13 +39,14 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.embeddable.GlassFish; import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishProperties; import org.glassfish.embeddable.GlassFishRuntime; import org.glassfish.hk2.api.MultiException; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.boot.impl.GlassFishImpl; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; @@ -269,7 +268,7 @@ private void logCL(final Logger logger, final String label, final ClassLoader cl private String toString(final ClassLoader classLoader) { - if (classLoader instanceof GlassfishBootstrapClassLoader || classLoader instanceof GlassfishUrlClassLoader) { + if (classLoader instanceof GlassfishUrlClassLoader) { return classLoader.toString(); } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishRuntimeBuilder.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntimeBuilder.java similarity index 79% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishRuntimeBuilder.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntimeBuilder.java index 94f5785ea3e..bb5c5d543f6 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/EmbeddedOSGiGlassFishRuntimeBuilder.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishRuntimeBuilder.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; @@ -54,11 +54,12 @@ public boolean handles(BootstrapProperties bsProps) { } @Override - public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishException { + public GlassFishRuntime build(BootstrapProperties bsProps, ClassLoader classloader) throws GlassFishException { configureBundles(bsProps); - provisionBundles(bsProps); - GlassFishRuntime gfr = new EmbeddedOSGiGlassFishRuntime(getBundleContext()); - getBundleContext().registerService(GlassFishRuntime.class.getName(), gfr, (Hashtable) bsProps.getProperties()); + provisionBundles(bsProps, classloader); + BundleContext bundleContext = getBundleContext(classloader); + GlassFishRuntime gfr = new EmbeddedOSGiGlassFishRuntime(bundleContext); + bundleContext.registerService(GlassFishRuntime.class.getName(), gfr, (Hashtable) bsProps.getProperties()); return gfr; } @@ -68,12 +69,12 @@ private void configureBundles(BootstrapProperties bsProps) { } } - private BundleContext getBundleContext() { - return BundleReference.class.cast(getClass().getClassLoader()).getBundle().getBundleContext(); + private BundleContext getBundleContext(ClassLoader classloader) { + return BundleReference.class.cast(classloader).getBundle().getBundleContext(); } - private void provisionBundles(BootstrapProperties bsProps) { - BundleProvisioner bundleProvisioner = new BundleProvisioner(getBundleContext(), bsProps.getProperties()); + private void provisionBundles(BootstrapProperties bsProps, ClassLoader classloader) { + BundleProvisioner bundleProvisioner = new BundleProvisioner(getBundleContext(classloader), bsProps.getProperties()); bundleProvisioner.installBundles(); bundleProvisioner.startBundles(); } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishBundleContext.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishBundleContext.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishBundleContext.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishBundleContext.java index a04ca78fdbb..0db2f95753d 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishBundleContext.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishBundleContext.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishDecorator.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishDecorator.java similarity index 97% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishDecorator.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishDecorator.java index 2020a637641..12069c5d860 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishDecorator.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishDecorator.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import org.glassfish.embeddable.CommandRunner; import org.glassfish.embeddable.Deployer; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishMainActivator.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishMainActivator.java similarity index 82% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishMainActivator.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishMainActivator.java index 4ba09919104..d8ddbb32f1d 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/GlassFishMainActivator.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishMainActivator.java @@ -15,14 +15,13 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import java.io.File; import java.lang.System.Logger; import java.net.URI; -import java.nio.file.Path; import java.util.Properties; import org.glassfish.embeddable.BootstrapProperties; @@ -30,7 +29,6 @@ import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishProperties; import org.glassfish.embeddable.GlassFishRuntime; -import org.glassfish.main.jul.JULHelperFactory; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -61,7 +59,7 @@ */ public class GlassFishMainActivator implements BundleActivator { - private static final Logger LOG = JULHelperFactory.getHelper().getSystemLogger(GlassFishMainActivator.class); + private static final Logger LOG = System.getLogger(GlassFishMainActivator.class.getName()); private static final String[] DEFAULT_INSTALLATION_LOCATIONS_RELATIVE = new String[]{ // Order is important. @@ -175,8 +173,8 @@ private GlassFishRuntime lookupGfr(BundleContext context) { if (context == null) { return null; } - final ServiceReference serviceReference = context.getServiceReference(GlassFishRuntime.class.getName()); - return serviceReference == null ? null : (GlassFishRuntime) context.getService(serviceReference); + final ServiceReference serviceReference = context.getServiceReference(GlassFishRuntime.class); + return serviceReference == null ? null : context.getService(serviceReference); } @@ -193,24 +191,8 @@ private Properties prepareStartupContext(final BundleContext context) { } installRoot = context.getProperty(BootstrapKeys.INSTALL_ROOT_PROP_NAME); - - if (installRoot == null) { - installRoot = guessInstallRoot(context); - if (installRoot == null) { - throw new RuntimeException("Property named " + BootstrapKeys.INSTALL_ROOT_PROP_NAME + " is not set."); - } - LOG.log(DEBUG, "Deduced install root as: {0} from location of bundle. " - + "If this is not correct, set correct value in a property called " + BootstrapKeys.INSTALL_ROOT_PROP_NAME, - installRoot); - } - if (!new File(installRoot).exists()) { - throw new RuntimeException("No such directory: [" + installRoot + "]"); - } properties.setProperty(BootstrapKeys.INSTALL_ROOT_PROP_NAME, installRoot); String instanceRoot = context.getProperty(BootstrapKeys.INSTANCE_ROOT_PROP_NAME); - if (instanceRoot == null) { - instanceRoot = new File(installRoot, "domains/domain1/").getAbsolutePath(); - } properties.setProperty(BootstrapKeys.INSTANCE_ROOT_PROP_NAME, instanceRoot); properties.putAll(makeProvisioningOptions(context)); @@ -219,28 +201,6 @@ private Properties prepareStartupContext(final BundleContext context) { return properties; } - /** - * This method tries to guess install root based on location of the bundle. Please note, because location of a - * bundle is free form string, this method can come to very wrong conclusion if user wants to fool us. - * - * @param context - * @return - */ - private String guessInstallRoot(BundleContext context) { - String location = context.getBundle().getLocation(); - try { - final URI uri = URI.create(location); - File f = new File(uri); - // We can't assume it is glassfish/modules/glassfish.jar. - // Bare nucleus is installed as nucleus/modules/glassfish.jar. - if (f.exists() && f.isFile() && f.getParentFile().toPath().endsWith(Path.of("modules"))) { - return f.getParentFile().getParentFile().getAbsolutePath(); - } - } catch (Exception e) { - } - return null; - } - private Properties makeProvisioningOptions(BundleContext context) { Properties provisioningOptions = new Properties(); URI installURI = new File(installRoot).toURI(); diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/Launcher.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishOsgiLauncher.java similarity index 91% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/Launcher.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishOsgiLauncher.java index f60b11b10e0..77b69874ef3 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/Launcher.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/GlassFishOsgiLauncher.java @@ -14,7 +14,9 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap; +package org.glassfish.main.boot.osgi; + +import com.sun.enterprise.glassfish.bootstrap.launch.Launcher; import java.io.BufferedReader; import java.io.IOException; @@ -30,12 +32,11 @@ import org.glassfish.embeddable.CommandRunner; import org.glassfish.embeddable.Deployer; import org.glassfish.embeddable.GlassFish; -import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishProperties; import org.glassfish.embeddable.GlassFishRuntime; // must be public to be accessible for reflection -public class Launcher { +public class GlassFishOsgiLauncher implements Launcher { // logging system may override original output streams. private static final PrintStream STDOUT = System.out; @@ -44,6 +45,17 @@ public class Launcher { private volatile GlassFish gf; private volatile GlassFishRuntime gfr; + public GlassFishOsgiLauncher(ClassLoader classloader) { + // Why this - it is too easy to load this class by wrong classloader. + // That has consequences (CNFE for other required classes) and here it is + // quite easy to check. + if (getClass().getClassLoader() != classloader) { + throw new IllegalStateException( + "The class " + getClass() + " was not loaded by the same classloader as given in constructor!"); + } + } + + @Override public void launch(final Properties properties) throws Exception { addShutdownHook(); gfr = GlassFishRuntime.bootstrap(new BootstrapProperties(properties), getClass().getClassLoader()); @@ -147,7 +159,7 @@ public void run() { } - private void runCommand(final CommandRunner cmdRunner, final String command) throws GlassFishException { + private void runCommand(final CommandRunner cmdRunner, final String command) { String[] tokens = command.split("\\s"); CommandResult result = cmdRunner.run(tokens[0], Arrays.copyOfRange(tokens, 1, tokens.length)); System.out.println(result.getExitStatus()); diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/Jar.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/Jar.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/Jar.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/Jar.java index 96870c3d981..dc0d4f5b11a 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/Jar.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/Jar.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import java.io.File; import java.net.URI; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/MinimalBundleProvisioner.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisioner.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/MinimalBundleProvisioner.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisioner.java index 4c241559425..c3be576dd86 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/MinimalBundleProvisioner.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisioner.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/MinimalBundleProvisionerCustomizer.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisionerCustomizer.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/MinimalBundleProvisionerCustomizer.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisionerCustomizer.java index 27fb4542c7b..24311e45cef 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/MinimalBundleProvisionerCustomizer.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisionerCustomizer.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiFrameworkLauncher.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiFrameworkLauncher.java similarity index 85% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiFrameworkLauncher.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiFrameworkLauncher.java index e62d634f6a5..377654031e8 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiFrameworkLauncher.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiFrameworkLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import java.util.HashMap; import java.util.Map; @@ -41,10 +41,17 @@ public class OSGiFrameworkLauncher { private final Properties properties; + private final ClassLoader classloader; private Framework framework; - public OSGiFrameworkLauncher(Properties properties) { + public OSGiFrameworkLauncher(Properties properties, ClassLoader classloader) { this.properties = properties; + this.classloader = classloader; + } + + + public ClassLoader getClassLoader() { + return classloader; } @@ -53,8 +60,7 @@ public Framework launchOSGiFrameWork() throws Exception { throw new IllegalStateException("An OSGi framework is already running..."); } // Locate an OSGi framework and initialize it - ServiceLoader frameworkFactories = ServiceLoader.load(FrameworkFactory.class, - getClass().getClassLoader()); + ServiceLoader frameworkFactories = ServiceLoader.load(FrameworkFactory.class, classloader); Map mm = new HashMap<>(); for (Map.Entry e : properties.entrySet()) { mm.put((String) e.getKey(), (String) e.getValue()); @@ -91,10 +97,10 @@ public T getService(Class type) throws Exception { throw new IllegalStateException("OSGi framework has not yet been launched."); } final BundleContext context = framework.getBundleContext(); - ServiceTracker tracker = new ServiceTracker(context, type.getName(), null); + ServiceTracker tracker = new ServiceTracker<>(context, type.getName(), null); try { tracker.open(true); - return type.cast(tracker.waitForService(0)); + return tracker.waitForService(0); } finally { tracker.close(); } @@ -108,6 +114,6 @@ public T getService(Class type) throws Exception { * @return false if we are already called in the context of OSGi framework, else true. */ private boolean isOSGiEnv() { - return getClass().getClassLoader() instanceof BundleReference; + return classloader instanceof BundleReference; } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishImpl.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishImpl.java similarity index 97% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishImpl.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishImpl.java index 7bfad830c15..35075efbfc1 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishImpl.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishImpl.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import org.glassfish.embeddable.GlassFish; import org.glassfish.embeddable.GlassFishException; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishRuntime.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntime.java similarity index 98% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishRuntime.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntime.java index 8b992e3adb9..081994f8c43 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishRuntime.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntime.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import org.glassfish.embeddable.GlassFish; import org.glassfish.embeddable.GlassFishException; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishRuntimeBuilder.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntimeBuilder.java similarity index 92% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishRuntimeBuilder.java rename to nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntimeBuilder.java index 42a313e3ec9..eacc8f90286 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/osgi/OSGiGlassFishRuntimeBuilder.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntimeBuilder.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; @@ -82,22 +82,15 @@ public final class OSGiGlassFishRuntimeBuilder implements RuntimeBuilder { private static final Logger LOG = LogFacade.BOOTSTRAP_LOGGER; - private Framework framework; - - private Properties oldProvisioningOptions; private Properties newProvisioningOptions; // These two should be a part of an external interface of HK2, but they are not, so we have to duplicate them here. private OSGiFrameworkLauncher fwLauncher; - - /** - * Default constructor needed for meta-inf/service lookup to work - */ - public OSGiGlassFishRuntimeBuilder() {} + private Framework framework; @Override - public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishException { + public GlassFishRuntime build(BootstrapProperties bsProps, ClassLoader classloader) throws GlassFishException { try { Properties properties = bsProps.getProperties(); @@ -106,7 +99,7 @@ public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishExcep properties.setProperty(BootstrapKeys.BUILDER_NAME_PROPERTY, getClass().getName()); // Step 0: Locate and launch a framework long t0 = System.currentTimeMillis(); - fwLauncher = new OSGiFrameworkLauncher(properties); + fwLauncher = new OSGiFrameworkLauncher(properties, classloader); framework = fwLauncher.launchOSGiFrameWork(); long t1 = System.currentTimeMillis(); LOG.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "build", "Launched {0}", framework); @@ -116,7 +109,7 @@ public GlassFishRuntime build(BootstrapProperties bsProps) throws GlassFishExcep storeProvisioningOptions(properties); } else { // this will reconfigure if any provisioning options have changed. - reconfigure(properties); + reconfigure(properties, classloader); } BundleProvisioner bundleProvisioner = createBundleProvisioner(framework.getBundleContext(), properties); LOG.log(Level.CONFIG, LogFacade.CREATE_BUNDLE_PROVISIONER, bundleProvisioner); @@ -228,28 +221,28 @@ private boolean newFramework() { * This method helps in situations where glassfish installation directory has been moved or * certain initial provisoning options have changed, etc. If such thing has happened, it uninstalls * all the bundles that were installed from GlassFish installation location. + * @param classloader */ - private void reconfigure(Properties properties) throws Exception { + private void reconfigure(Properties properties, ClassLoader classloader) throws Exception { if (hasBeenReconfigured(properties)) { LOG.log(Level.INFO, LogFacade.PROVISIONING_OPTIONS_CHANGED); framework.stop(); framework.waitForStop(0); - properties.setProperty(FRAMEWORK_STORAGE_CLEAN, - FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT); - fwLauncher = new OSGiFrameworkLauncher(properties); + properties.setProperty(FRAMEWORK_STORAGE_CLEAN, FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT); + fwLauncher = new OSGiFrameworkLauncher(properties, classloader); framework = fwLauncher.launchOSGiFrameWork(); - LOG.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "reconfigure", "Launched {0}", - new Object[]{framework}); + LOG.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "reconfigure", "Launched {0}", framework); storeProvisioningOptions(properties); } } private boolean hasBeenReconfigured(Properties properties) { LOG.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "hasBeenReconfigured", "oldProvisioningOptions = {0}", - new Object[]{getOldProvisioningOptions()}); + getOldProvisioningOptions()); + Properties newOptions = getNewProvisioningOptions(properties); LOG.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "hasBeenReconfigured", "newProvisioningOptions = {0}", - new Object[]{getNewProvisioningOptions(properties)}); - return !getNewProvisioningOptions(properties).equals(getOldProvisioningOptions()); + newOptions); + return !newOptions.equals(getOldProvisioningOptions()); } /** @@ -298,7 +291,7 @@ private void storeProvisioningOptions(Properties properties) { getNewProvisioningOptions(properties).store(os, ""); os.flush(); LOG.logp(Level.CONFIG, "OSGiGlassFishRuntimeBuilder", "storeProvisioningOptions", - "Stored provisioning options in {0}", new Object[] {f.getAbsolutePath()}); + "Stored provisioning options in {0}", f); } catch (IOException e) { LOG.log(Level.WARNING, "Storing provisioning options failed.", e); } @@ -312,7 +305,7 @@ private Properties getOldProvisioningOptions() { if (f != null && f.exists()) { options.load(new FileInputStream(f)); LOG.logp(Level.FINE, "OSGiGlassFishRuntimeBuilder", "getOldProvisioningOptions", - "Read provisioning options from {0}", new Object[]{f.getAbsolutePath()}); + "Read provisioning options from {0}", f); oldProvisioningOptions = options; } } catch (Exception e) { @@ -324,8 +317,7 @@ private Properties getOldProvisioningOptions() { private static BundleProvisioner createBundleProvisioner(BundleContext bctx, Properties props) { - final boolean ondemandProvisioning = Boolean - .parseBoolean(props.getProperty(ONDEMAND_BUNDLE_PROVISIONING)); + final boolean ondemandProvisioning = Boolean.parseBoolean(props.getProperty(ONDEMAND_BUNDLE_PROVISIONING)); if (ondemandProvisioning) { return new MinimalBundleProvisioner(bctx, props); } diff --git a/nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder b/nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder new file mode 100644 index 00000000000..ac251a4959a --- /dev/null +++ b/nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder @@ -0,0 +1,3 @@ +org.glassfish.main.boot.osgi.OSGiGlassFishRuntimeBuilder +org.glassfish.main.boot.osgi.EmbeddedOSGiGlassFishRuntimeBuilder +org.glassfish.main.boot.embedded.EmbeddedGlassFishRuntimeBuilder diff --git a/nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor b/nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor new file mode 100644 index 00000000000..6c473f9b2ba --- /dev/null +++ b/nucleus/core/bootstrap-osgi/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor @@ -0,0 +1 @@ +org.glassfish.main.boot.embedded.EmbeddedInhabitantsParser diff --git a/nucleus/core/bootstrap-osgi/src/main/resources/logging.properties b/nucleus/core/bootstrap-osgi/src/main/resources/logging.properties new file mode 100644 index 00000000000..987ee7d5e47 --- /dev/null +++ b/nucleus/core/bootstrap-osgi/src/main/resources/logging.properties @@ -0,0 +1,8 @@ +handlers=org.glassfish.main.jul.handler.SimpleLogHandler +org.glassfish.main.jul.handler.SimpleLogHandler.level=ALL +org.glassfish.main.jul.handler.SimpleLogHandler.formatter=org.glassfish.main.jul.formatter.UniformLogFormatter + +systemRootLogger.level=FINEST +.level=FINEST + +org.glassfish.main.jul.record.resolveLevelWithIncompleteConfiguration=true diff --git a/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisionerTest.java b/nucleus/core/bootstrap-osgi/src/test/java/org/glassfish/main/boot/osgi/BundleProvisionerTest.java similarity index 98% rename from nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisionerTest.java rename to nucleus/core/bootstrap-osgi/src/test/java/org/glassfish/main/boot/osgi/BundleProvisionerTest.java index 3d6a4d81041..3923b7f6891 100644 --- a/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/osgi/BundleProvisionerTest.java +++ b/nucleus/core/bootstrap-osgi/src/test/java/org/glassfish/main/boot/osgi/BundleProvisionerTest.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.osgi; +package org.glassfish.main.boot.osgi; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java index 0ea5ef8835b..129a6617023 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java @@ -18,28 +18,24 @@ package com.sun.enterprise.glassfish.bootstrap; import com.sun.enterprise.glassfish.bootstrap.cfg.AsenvConf; +import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; import com.sun.enterprise.glassfish.bootstrap.cfg.ServerFiles; import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextCfg; -import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextUtil; -import com.sun.enterprise.glassfish.bootstrap.cp.ClassLoaderBuilder; -import com.sun.enterprise.glassfish.bootstrap.cp.GlassfishBootstrapClassLoader; +import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextCfgFactory; +import com.sun.enterprise.glassfish.bootstrap.launch.GlassfishOsgiBootstrapClassLoader; import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; import java.io.File; import java.io.PrintStream; -import java.lang.reflect.Method; import java.nio.file.Path; import java.util.Properties; -import java.util.logging.Level; -import static com.sun.enterprise.glassfish.bootstrap.StartupContextCfgFactory.createStartupContextCfg; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.PLATFORM_PROPERTY_KEY; +import static com.sun.enterprise.glassfish.bootstrap.cp.ClassLoaderBuilder.createOSGiFrameworkLauncherCL; import static com.sun.enterprise.glassfish.bootstrap.log.LogFacade.BOOTSTRAP_LOGGER; -import static com.sun.enterprise.module.bootstrap.ArgumentManager.argsToMap; +import static java.lang.ClassLoader.getSystemClassLoader; import static java.util.logging.Level.SEVERE; -import static org.glassfish.main.jul.cfg.GlassFishLoggingConstants.CLASS_INITIALIZER; -import static org.glassfish.main.jul.cfg.GlassFishLoggingConstants.KEY_TRACING_ENABLED; /** * @author Sanjeeb.Sahoo@Sun.COM @@ -47,20 +43,6 @@ */ public class GlassFishMain { - /** - * true enable 'logging of logging' so you can watch the order of actions in standard outputs. - */ - private static final String ENV_AS_TRACE_LOGGING = "AS_TRACE_LOGGING"; - /** - *
    - *
  • true defers log record resolution to a moment when logging configuration is loaded from - * logging.properties. - *
  • false means that log record's level is compared with default logger settings which is - * usually INFO/WARNING. Records with FINE, FINER, FINEST will be lost. - *
- */ - private static final String ENV_AS_TRACE_BOOTSTRAP = "AS_TRACE_BOOTSTRAP"; - private static final String DEFAULT_DOMAINS_DIR_PROPNAME = "AS_DEF_DOMAINS_PATH"; // logging system may override original output streams. @@ -68,55 +50,35 @@ public class GlassFishMain { public static void main(final String[] args) { try { - final File installRoot = StartupContextUtil.detectInstallRoot(); - final ClassLoader jdkExtensionCL = ClassLoader.getSystemClassLoader().getParent(); - final GlassfishBootstrapClassLoader gfBootCL = new GlassfishBootstrapClassLoader(installRoot, - jdkExtensionCL); - initializeLogManager(gfBootCL); - checkJdkVersion(); - final Properties argsAsProps = argsToMap(args); final String platformName = whichPlatform(); + // Set the system property to allow downstream code to know the platform on which GlassFish runs. + System.setProperty(PLATFORM_PROPERTY_KEY, platformName); final OsgiPlatform platform = OsgiPlatform.valueOf(platformName); STDOUT.println("Launching GlassFish on " + platform + " platform"); - // Set the system property to allow downstream code to know the platform on which GlassFish runs. - System.setProperty(PLATFORM_PROPERTY_KEY, platformName); + // FIXME: move to serverfiles + final File installRoot = ServerFiles.detectInstallRoot(); + STDOUT.println("Resolved GlassFish install root: " + installRoot); - final Path instanceRoot = findInstanceRoot(installRoot, argsAsProps); + final Properties properties = initProperties(args); + STDOUT.println("Resolved properties: " + properties); + final Path instanceRoot = findInstanceRoot(installRoot, properties); final ServerFiles files = new ServerFiles(installRoot.toPath(), instanceRoot); - final StartupContextCfg startupContextCfg = createStartupContextCfg(platform, files, args); - final ClassLoader launcherCL = ClassLoaderBuilder.createLauncherCL(startupContextCfg, gfBootCL); - - final Class launcherClass = launcherCL.loadClass(Launcher.class.getName()); - final Object launcher = launcherClass.getDeclaredConstructor().newInstance(); - final Method method = launcherClass.getMethod("launch", Properties.class); - - // launcherCL is used only to load the RuntimeBuilder service. - // on all other places is used classloader which loaded the GlassfishRuntime class - // -> it must not be loaded by any parent classloader, it's children would be ignored. - method.invoke(launcher, startupContextCfg.toProperties()); + final StartupContextCfg cfg = StartupContextCfgFactory.createStartupContextCfg(platform, files, properties); + final ClassLoader osgiCL = createOSGiFrameworkLauncherCL(cfg, getSystemClassLoader()); + try (GlassfishOsgiBootstrapClassLoader launcherCL = new GlassfishOsgiBootstrapClassLoader(installRoot, osgiCL)) { + launcherCL.launchGlassFishServer(cfg.toProperties()); + } - // also note that debugging is not possible until the debug port is open. + // Note: debugging is not possible until the debug port is open. } catch (Throwable t) { - t.printStackTrace(); throw new Error("Could not start the server!", t); } } - /** - * The GlassFishLogManager must be set before the first usage of any JUL component, - * it would be replaced by another implementation otherwise. - */ - private static void initializeLogManager(final GlassfishBootstrapClassLoader gfMainCL) throws Exception { - final Class loggingInitializer = gfMainCL.loadClass(CLASS_INITIALIZER); - final Properties loggingCfg = createDefaultLoggingProperties(); - loggingInitializer.getMethod("tryToSetAsDefault", Properties.class).invoke(loggingInitializer, loggingCfg); - } - - private static void checkJdkVersion() { int version = Runtime.version().feature(); if (version < 11) { @@ -125,6 +87,47 @@ private static void checkJdkVersion() { } } + private static Properties initProperties(String[] args) { + Properties map = new Properties(); + if (args.length == 0) { + return map; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < args.length; i++) { + String name = args[i]; + if (name.startsWith("-")) { + // throw it away if there is no value left + if (i + 1 < args.length) { + map.put(name, args[++i]); + } + } else { + // default --> last one wins! + map.put("default", args[i]); + } + } + if (!wasStartedByCLI(map)) { + for (int i = 0; i < args.length; i++) { + if (i > 0) { + sb.append(BootstrapKeys.ARG_SEP); + } + sb.append(args[i]); + } + map.setProperty(BootstrapKeys.ORIGINAL_ARGS, sb.toString()); + // no sense doing this if we were started by CLI... + map.setProperty(BootstrapKeys.ORIGINAL_CP, System.getProperty("java.class.path")); + map.setProperty(BootstrapKeys.ORIGINAL_CN, GlassFishMain.class.getName()); + } + return map; + } + + + private static boolean wasStartedByCLI(final Properties properties) { + // if we were started by CLI there will be some special args set... + return properties.getProperty("-asadmin-classpath") != null + && properties.getProperty("-asadmin-classname") != null + && properties.getProperty("-asadmin-args") != null; + } + private static String whichPlatform() { final String platformSysOption = System.getProperty(PLATFORM_PROPERTY_KEY); @@ -143,19 +146,19 @@ private static String whichPlatform() { * IMPORTANT - check for instance BEFORE domain. We will always come up * with a default domain but there is no such thing as a default instance. */ - private static Path findInstanceRoot(File installRoot, Properties args) { - File instanceDir = getInstanceRoot(args); + private static Path findInstanceRoot(File installRoot, Properties argsAsProps) { + File instanceDir = getInstanceRoot(argsAsProps); if (instanceDir == null) { // that means that this is a DAS. - instanceDir = getDomainRoot(args, installRoot); + instanceDir = getDomainRoot(argsAsProps, installRoot); } verifyDomainRoot(instanceDir); return instanceDir.toPath(); } - private static File getInstanceRoot(Properties args) { - String instanceDir = getParam(args, "instancedir"); + private static File getInstanceRoot(Properties argsAsProps) { + String instanceDir = getParam(argsAsProps, "instancedir"); if (isSet(instanceDir)) { return new File(instanceDir); } @@ -168,16 +171,16 @@ private static File getInstanceRoot(Properties args) { * * @param installRoot */ - private static File getDomainRoot(Properties args, File installRoot) { + private static File getDomainRoot(Properties argsAsProps, File installRoot) { // first see if it is specified directly - String domainDir = getParam(args, "domaindir"); + String domainDir = getParam(argsAsProps, "domaindir"); if (isSet(domainDir)) { return new File(domainDir); } // now see if they specified the domain name -- we will look in the default domains-dir File defDomainsRoot = getDefaultDomainsDir(installRoot); - String domainName = getParam(args, "domain"); + String domainName = getParam(argsAsProps, "domain"); if (isSet(domainName)) { return new File(defDomainsRoot, domainName); @@ -243,34 +246,11 @@ private static void verifyDomainRoot(File domainRoot) { } - private static Properties createDefaultLoggingProperties() { - final Properties cfg = new Properties(); - cfg.setProperty("handlers", - "org.glassfish.main.jul.handler.SimpleLogHandler,org.glassfish.main.jul.handler.GlassFishLogHandler"); - cfg.setProperty("org.glassfish.main.jul.handler.SimpleLogHandler.formatter", - "org.glassfish.main.jul.formatter.UniformLogFormatter"); - // useful to track any startup race conditions etc. Logging is always in game. - if ("true".equals(System.getenv(ENV_AS_TRACE_LOGGING))) { - cfg.setProperty(KEY_TRACING_ENABLED, "true"); - } - cfg.setProperty("systemRootLogger.level", Level.INFO.getName()); - cfg.setProperty(".level", Level.INFO.getName()); - // better startup performance vs. losing log records. - if ("true".equals(System.getenv(ENV_AS_TRACE_BOOTSTRAP))) { - cfg.setProperty("org.glassfish.main.jul.record.resolveLevelWithIncompleteConfiguration", "false"); - } else { - cfg.setProperty("org.glassfish.main.jul.record.resolveLevelWithIncompleteConfiguration", "true"); - } - - return cfg; - } - - - private static String getParam(Properties map, String name) { + private static String getParam(Properties argsAsProps, String name) { // allow both "-" and "--" - String val = map.getProperty("-" + name); + String val = argsAsProps.getProperty("-" + name); if (val == null) { - val = map.getProperty("--" + name); + val = argsAsProps.getProperty("--" + name); } return val; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java index f93e5c405fc..6a42e2f8120 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java @@ -31,6 +31,8 @@ /** * The asenv.conf file content. */ +// FIXME: duplicates AsenvPropertyReader, but cannot resolve bash defaults. +@Deprecated public class AsenvConf { private static final Pattern LINE = Pattern.compile("(?i)(set +)?([^=]*)=\"?([^\"]*)\"?"); diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java index 8b2cfbd92fd..e6f2331ea14 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java @@ -25,6 +25,11 @@ public final class BootstrapKeys { public static final String PLATFORM_PROPERTY_KEY = "GlassFish_Platform"; /** bundle containing module startup */ public static final String GF_KERNEL = "org.glassfish.core.kernel"; + + public static final String ASADMIN_CP = "-asadmin-classpath"; + public static final String ASADMIN_CN = "-asadmin-classname"; + public static final String ASADMIN_ARGS = "-asadmin-args"; + public static final String ORIGINAL_CP = "-startup-classpath"; public static final String ORIGINAL_CN = "-startup-classname"; public static final String ORIGINAL_ARGS = "-startup-args"; @@ -72,6 +77,12 @@ public final class BootstrapKeys { public static final String AUTO_DELETE = "org.glassfish.embeddable.autoDelete"; + // Following constants were copy-pasted from com.sun.enterprise.module.bootstrap.StartupContext + // to avoid dependency on HK2 jar files. + public final static String TIME_ZERO_NAME = "__time_zero"; + public final static String STARTUP_MODULE_NAME = "hk2.startup.context.mainModule"; + public final static String STARTUP_MODULESTARTUP_NAME = "hk2.startup.context.moduleStartup"; + public static final String DERBY_ROOT_PROP_NAME = "com.sun.aas.derbyRoot"; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/FelixUtil.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/FelixUtil.java similarity index 99% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/FelixUtil.java rename to nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/FelixUtil.java index 24eff6f183b..6ae9eedcd93 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/FelixUtil.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/FelixUtil.java @@ -17,7 +17,7 @@ * under the License. */ -package com.sun.enterprise.glassfish.bootstrap; +package com.sun.enterprise.glassfish.bootstrap.cfg; import java.util.HashMap; import java.util.Map; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/ServerFiles.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/ServerFiles.java index 23a831688fd..ee80eefdc6b 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/ServerFiles.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/ServerFiles.java @@ -18,6 +18,8 @@ import java.io.File; import java.io.IOException; +import java.net.URI; +import java.net.URL; import java.nio.file.Path; public class ServerFiles { @@ -85,4 +87,23 @@ private static File toExistingFile(String path) throws IllegalArgumentException throw new IllegalArgumentException("Invalid path: " + path, e); } } + + /** + * @return autodetected glassfish directory based on where usually is this class. + */ + public static File detectInstallRoot() { + // glassfish/lib/bootstrap/glassfish.jar + File bootstrapFile = findBootstrapFile(); + // glassfish/ + return bootstrapFile.getParentFile().getParentFile().getParentFile(); + } + + + /** + * @return uses this class to locate its jar file. + */ + private static File findBootstrapFile() { + URL jarUrl = ServerFiles.class.getProtectionDomain().getCodeSource().getLocation(); + return new File(URI.create(jarUrl.toExternalForm().replaceFirst("jar:", "file:"))); + } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/StartupContextCfgFactory.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/StartupContextCfgFactory.java similarity index 71% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/StartupContextCfgFactory.java rename to nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/StartupContextCfgFactory.java index bab6baa43a9..ebda3fd47db 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/StartupContextCfgFactory.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/StartupContextCfgFactory.java @@ -14,13 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap; - -import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; -import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; -import com.sun.enterprise.glassfish.bootstrap.cfg.ServerFiles; -import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextCfg; -import com.sun.enterprise.module.bootstrap.StartupContext; +package com.sun.enterprise.glassfish.bootstrap.cfg; import java.io.File; import java.io.FileInputStream; @@ -36,11 +30,11 @@ import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_URI_PROP_NAME; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTANCE_ROOT_PROP_NAME; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTANCE_ROOT_URI_PROP_NAME; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.STARTUP_MODULESTARTUP_NAME; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.STARTUP_MODULE_NAME; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.TIME_ZERO_NAME; import static com.sun.enterprise.glassfish.bootstrap.log.LogFacade.BOOTSTRAP_FMWCONF; import static com.sun.enterprise.glassfish.bootstrap.log.LogFacade.BOOTSTRAP_LOGGER; -import static com.sun.enterprise.module.bootstrap.ArgumentManager.argsToMap; -import static com.sun.enterprise.module.bootstrap.StartupContext.STARTUP_MODULE_NAME; -import static com.sun.enterprise.module.bootstrap.StartupContext.TIME_ZERO_NAME; import static java.util.logging.Level.INFO; import static org.osgi.framework.Constants.FRAMEWORK_STORAGE; @@ -54,8 +48,9 @@ private StartupContextCfgFactory() { } - public static StartupContextCfg createStartupContextCfg(OsgiPlatform platform, ServerFiles files, String[] args) { - Properties properties = argsToMap(args); + public static StartupContextCfg createStartupContextCfg(OsgiPlatform platform, ServerFiles files, Properties args) { + Properties properties = new Properties(); + properties.putAll(args); properties.setProperty(TIME_ZERO_NAME, Long.toString(System.currentTimeMillis())); File installRoot = files.getInstallRoot().toFile(); @@ -66,57 +61,17 @@ public static StartupContextCfg createStartupContextCfg(OsgiPlatform platform, S properties.setProperty(INSTANCE_ROOT_PROP_NAME, instanceRoot.getAbsolutePath()); properties.setProperty(INSTANCE_ROOT_URI_PROP_NAME, instanceRoot.toURI().toString()); - if (properties.getProperty(STARTUP_MODULE_NAME) == null) { - properties.setProperty(STARTUP_MODULE_NAME, BootstrapKeys.GF_KERNEL); - } + properties.setProperty(STARTUP_MODULE_NAME, BootstrapKeys.GF_KERNEL); // temporary hack until CLI does that for us. - for (int i = 0; i < args.length; i++) { - if (args[i].equals("-upgrade")) { - if (i + 1 < args.length && !args[i + 1].equals("false")) { - properties.setProperty(StartupContext.STARTUP_MODULESTARTUP_NAME, "upgrade"); - } - } + String upgrade = properties.getProperty("-upgrade"); + if (upgrade != null && !upgrade.equals("false")) { + properties.setProperty(STARTUP_MODULESTARTUP_NAME, "upgrade"); } - - addRawStartupInfo(args, properties); - return mergePlatformConfiguration(platform, files, properties); } - /** - * Need the raw unprocessed args for RestartDomainCommand in case we were NOT started by CLI - * - * @param args raw args to this main() - * @param cfg the properties to save as a system property - */ - private static void addRawStartupInfo(final String[] args, final Properties properties) { - if (wasStartedByCLI(properties)) { - return; - } - // no sense doing this if we were started by CLI... - properties.setProperty(BootstrapKeys.ORIGINAL_CP, System.getProperty("java.class.path")); - properties.setProperty(BootstrapKeys.ORIGINAL_CN, ASMain.class.getName()); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < args.length; i++) { - if (i > 0) { - sb.append(BootstrapKeys.ARG_SEP); - } - sb.append(args[i]); - } - properties.setProperty(BootstrapKeys.ORIGINAL_ARGS, sb.toString()); - } - - - private static boolean wasStartedByCLI(final Properties properties) { - // if we were started by CLI there will be some special args set... - return properties.getProperty("-asadmin-classpath") != null - && properties.getProperty("-asadmin-classname") != null - && properties.getProperty("-asadmin-args") != null; - } - - private static StartupContextCfg mergePlatformConfiguration(OsgiPlatform platform, ServerFiles files, Properties properties) { final Properties platformCfg; @@ -193,5 +148,4 @@ private static void overrideBySystemProps(Properties osgiCfg, Collection } } } - } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/StartupContextUtil.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/StartupContextUtil.java deleted file mode 100644 index 10d0acd4b6b..00000000000 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/StartupContextUtil.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2024 Contributors to the Eclipse Foundation. - * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.enterprise.glassfish.bootstrap.cfg; - -import com.sun.enterprise.module.bootstrap.StartupContext; -import com.sun.enterprise.module.bootstrap.Which; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.StringTokenizer; - -import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.ARG_SEP; -import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_PROP_NAME; -import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTANCE_ROOT_PROP_NAME; -import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.ORIGINAL_ARGS; - -/** - * This encapsulates the behavior of the properties object that's part of - * {@link com.sun.enterprise.module.bootstrap.StartupContext}. - * - * @author Sanjeeb.Sahoo@Sun.COM - */ -public final class StartupContextUtil { - - // this contains utility methods only - private StartupContextUtil() { - } - - - /** - * @return autodetected glassfish directory based on where usually is this class. - */ - public static File detectInstallRoot() { - // glassfish/modules/glassfish.jar - File bootstrapFile = findBootstrapFile(); - // glassfish/ - return bootstrapFile.getParentFile().getParentFile(); - } - - - /** - * @return uses this class to locate its jar file. - */ - private static File findBootstrapFile() { - try { - return Which.jarFile(StartupContextUtil.class); - } catch (IOException e) { - throw new Error("Cannot get bootstrap path from " + StartupContextUtil.class + " class location, aborting", - e); - } - } - - - /** - * @param context - * @return absolute glassfish directory aka install root. - */ - public static File getInstallRoot(StartupContext context) { - return getInstallRoot(context.getArguments()); - } - - - /** - * @param properties - * @return absolute glassfish directory aka install root. - */ - public static File getInstallRoot(Properties properties) { - return absolutize(new File(properties.getProperty(INSTALL_ROOT_PROP_NAME))); - - } - - - /** - * @param context - * @return absolute domain or instance directory aka instance root. - */ - public static File getInstanceRoot(StartupContext context) { - return getInstanceRoot(context.getArguments()); - } - - - /** - * @param properties - * @return absolute domain or instance directory aka instance root. - */ - public static File getInstanceRoot(Properties properties) { - return absolutize(new File(properties.getProperty(INSTANCE_ROOT_PROP_NAME))); - } - - - /** - * @param context - * @return parsed array of arguments saved as {@link #ORIGINAL_ARGS} - */ - public static String[] getOriginalArguments(StartupContext context) { - Properties args = context.getArguments(); - // See how ASMain packages the arguments - String s = args.getProperty(ORIGINAL_ARGS); - if (s == null) { - return new String[0]; - } - StringTokenizer st = new StringTokenizer(s, ARG_SEP, false); - List result = new ArrayList<>(); - while (st.hasMoreTokens()) { - result.add(st.nextToken()); - } - return result.toArray(new String[result.size()]); - } - - - private static File absolutize(File f) { - try { - return f.getCanonicalFile(); - } catch (IOException e) { - return f.getAbsoluteFile(); - } - } -} diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilder.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilder.java index a304025fbe8..20c45e55c37 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilder.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilder.java @@ -17,12 +17,10 @@ package com.sun.enterprise.glassfish.bootstrap.cp; import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextCfg; -import com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.nio.file.Path; import java.util.HashSet; import java.util.Set; import java.util.jar.Attributes; @@ -34,67 +32,6 @@ public class ClassLoaderBuilder { - private final ClassPathBuilder cpBuilder; - private final StartupContextCfg cfg; - - private ClassLoaderBuilder(StartupContextCfg cfg) { - this.cfg = cfg; - this.cpBuilder = new ClassPathBuilder(); - } - - private void addPlatformDependencies() throws IOException { - getOsgiPlatformAdapter(cfg).addFrameworkJars(cpBuilder); - } - - private ClassLoader build(ClassLoader delegate) { - return cpBuilder.build(delegate); - } - - private void addLauncherDependencies() throws IOException { - cpBuilder.addJar(cfg.getFileUnderInstallRoot(Path.of("modules", "glassfish.jar"))); - } - - private void addServerBootstrapDependencies() throws IOException { - cpBuilder.addJar(cfg.getFileUnderInstallRoot(Path.of("modules", "simple-glassfish-api.jar"))); - cpBuilder.addJar(cfg.getFileUnderInstallRoot(Path.of("lib", "bootstrap", "glassfish-jul-extension.jar"))); - } - - - /** - * This method is responsible setting up launcher class loader which is then used while calling - * {@link org.glassfish.embeddable.GlassFishRuntime#bootstrap(org.glassfish.embeddable.BootstrapProperties, ClassLoader)}. - * - * This launcher class loader's delegation hierarchy looks like this: - * launcher class loader - * -> OSGi framework launcher class loader - * -> extension class loader - * -> null (bootstrap loader) - * We first create what we call "OSGi framework launcher class loader," that has - * classes that we want to be visible via system bundle. - * Then we create launcher class loader which has {@link OSGiGlassFishRuntimeBuilder} and its dependencies in - * its search path. We set the former one as the parent of this, there by sharing the same copy of - * GlassFish API classes and also making OSGi classes visible to OSGiGlassFishRuntimeBuilder. - * - * We could have merged all the jars into one class loader and called it the launcher class loader, but - * then such a loader, when set as the bundle parent loader for all OSGi classloading delegations, would make - * more things visible than desired. Please note, glassfish.jar has a very long dependency chain. See - * glassfish issue 13287 for the kinds of problems it can create. - * - * @see #createOSGiFrameworkLauncherCL(StartupContextCfg, ClassLoader) - * @param delegate Parent class loader for the launcher class loader. - */ - public static ClassLoader createLauncherCL(StartupContextCfg cfg, ClassLoader delegate) { - try { - ClassLoader osgiFWLauncherCL = createOSGiFrameworkLauncherCL(cfg, delegate); - ClassLoaderBuilder clb = new ClassLoaderBuilder(cfg); - clb.addLauncherDependencies(); - return clb.build(osgiFWLauncherCL); - } catch (IOException e) { - throw new Error(e); - } - } - - /** * This method is responsible for setting up the what we call "OSGi framework launcher class loader." It has * the following classes/jars in its search path: @@ -103,7 +40,7 @@ public static ClassLoader createLauncherCL(StartupContextCfg cfg, ClassLoader de * - jdk tools.jar classpath. * OSGi framework classes are there because we want to launch the framework. * simple-glassfish-api.jar is needed, because we need those classes higher up in the class loader chain otherwise - * {@link com.sun.enterprise.glassfish.bootstrap.Launcher} won't be able to see the same copy that's + * {@link com.sun.enterprise.glassfish.bootstrap.launch.Launcher} won't be able to see the same copy that's * used by rest of the system. * tools.jar is needed because its packages, which are exported via system bundle, are consumed by EJBC. * This class loader is configured to be the delegate for all bundle class loaders by setting @@ -111,49 +48,38 @@ public static ClassLoader createLauncherCL(StartupContextCfg cfg, ClassLoader de * class loaders, one should be very careful about adding stuff here, as it not only affects performance, it also * affects functionality as explained in GlassFish issue 13287. * - * @param delegate Parent class loader for this class loader. + * @param parent Parent class loader for this class loader. + * @throws IOException */ - private static ClassLoader createOSGiFrameworkLauncherCL(StartupContextCfg cfg, ClassLoader delegate) { - try { - ClassLoaderBuilder clb = new ClassLoaderBuilder(cfg); - clb.addPlatformDependencies(); - clb.addServerBootstrapDependencies(); - ClassLoader classLoader = clb.build(delegate); - String osgiPackages = classLoader.resources("META-INF/MANIFEST.MF").map(ClassLoaderBuilder::loadExports) - .collect(Collectors.joining(", ")); - // FIXME: This will not be printed anywhere after failure, because logging could not be configured. -// BOOTSTRAP_LOGGER.log(INFO, "OSGI framework packages:\n{0}", osgiPackages); - System.err.println("OSGI framework packages:\n" + osgiPackages); - String javaPackages = detectJavaPackages(); - System.err.println("JDK provided packages:\n" + javaPackages); - cfg.setProperty(FRAMEWORK_SYSTEMPACKAGES, osgiPackages + ", " + javaPackages); - return classLoader; - } catch (IOException e) { - throw new Error(e); - } + public static ClassLoader createOSGiFrameworkLauncherCL(StartupContextCfg cfg, ClassLoader parent) + throws IOException { + ClassLoader classLoader = getOsgiPlatformAdapter(cfg).addFrameworkJars(new ClassPathBuilder()).build(parent); + String osgiPackages = classLoader.resources("META-INF/MANIFEST.MF").map(ClassLoaderBuilder::loadExports) + .collect(Collectors.joining(", ")); + // FIXME: This will not be printed anywhere after failure, because logging could not be configured. + // BOOTSTRAP_LOGGER.log(INFO, "OSGI framework packages:\n{0}", osgiPackages); + System.err.println("OSGI framework packages:\n" + osgiPackages); + String javaPackages = detectJavaPackages(); + System.err.println("JDK provided packages:\n" + javaPackages); + cfg.setProperty(FRAMEWORK_SYSTEMPACKAGES, osgiPackages + ", " + javaPackages); + return classLoader; } private static OsgiPlatformAdapter getOsgiPlatformAdapter(StartupContextCfg cfg) { - OsgiPlatformAdapter osgiPlatformAdapter; switch (cfg.getPlatform()) { case Felix: - osgiPlatformAdapter = new FelixAdapter(cfg); - break; + return new FelixAdapter(cfg); case Knopflerfish: - osgiPlatformAdapter = new KnopflerfishAdapter(cfg); - break; + return new KnopflerfishAdapter(cfg); case Equinox: - osgiPlatformAdapter = new EquinoxAdapter(cfg); - break; + return new EquinoxAdapter(cfg); case Embedded: case Static: - osgiPlatformAdapter = new EmbeddedAdapter(); - break; + return new EmbeddedAdapter(); default: throw new RuntimeException("Unsupported platform " + cfg.getPlatform()); } - return osgiPlatformAdapter; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassPathBuilder.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassPathBuilder.java index ea4cd407e99..7178c05b19b 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassPathBuilder.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassPathBuilder.java @@ -26,40 +26,44 @@ import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.List; -import java.util.regex.Pattern; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; /** * Builds up a {@link ClassLoader}. * * @author Kohsuke Kawaguchi */ -public final class ClassPathBuilder { +final class ClassPathBuilder { private final List files = new ArrayList<>(); /** * Adds a single jar. * * @param jar + * @return this * @throws IOException if the file doesn't exist. */ - public void addJar(File jar) throws IOException { + ClassPathBuilder addJar(File jar) throws IOException { if (!jar.exists()) { throw new IOException("No such file: " + jar); } files.add(jar); + return this; } + /** * Adds all jars in the given folder. * * @param folder - * A directory that contains a bunch of jar files. + * A directory that contains a bunch of jar files. * @param excludes - * List of jars to be excluded + * List of jars to be excluded + * @return this + * @throws IOException */ - public void addJarFolder(File folder, final String... excludes) throws IOException { + ClassPathBuilder addJarFolder(File folder, final String... excludes) throws IOException { if (!folder.isDirectory()) { throw new IOException("Not a directory " + folder); } @@ -77,45 +81,20 @@ public void addJarFolder(File folder, final String... excludes) throws IOExcepti if (children == null) { // in a very rare race condition, the directory can disappear after we checked. - return; + return this; } for (File child : children) { addJar(child); } + return this; } - /** - * Looks for the child files/directories in the given folder that matches the specified GLOB patterns - * (like "foo-*.jar") and adds them to the classpath. - */ - public void addGlob(File folder, String... masks) throws IOException { - StringBuilder regexp = new StringBuilder(); - for (String mask : masks) { - if (regexp.length() > 0) { - regexp.append('|'); - } - regexp.append("(\\Q"); - regexp.append(mask.replace("?","\\E.\\Q").replace("*","\\E.*\\Q")); - regexp.append("\\E)"); - } - Pattern p = Pattern.compile(regexp.toString()); - File[] children = folder.listFiles(); - if (children == null) { - return; - } - for (File child : children) { - if (p.matcher(child.getName()).matches()) { - addJar(child); - } - } - } - - public ClassLoader build(final ClassLoader parent) { + ClassLoader build(final ClassLoader parent) { PrivilegedAction action = () -> { URL[] urls = files.stream().map(ClassPathBuilder::toURL).toArray(URL[]::new); - return new GlassfishUrlClassLoader(urls, parent); + return new GlassfishUrlClassLoader("OSGi", urls, parent); }; return AccessController.doPrivileged(action); } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EmbeddedAdapter.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EmbeddedAdapter.java index 629a6ac9765..360f94bd536 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EmbeddedAdapter.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EmbeddedAdapter.java @@ -26,7 +26,8 @@ public class EmbeddedAdapter implements OsgiPlatformAdapter { * Noop. */ @Override - public void addFrameworkJars(ClassPathBuilder cpb) { + public ClassPathBuilder addFrameworkJars(ClassPathBuilder builder) { // nothing to do + return builder; } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EquinoxAdapter.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EquinoxAdapter.java index e395963827b..5a99bad5225 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EquinoxAdapter.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/EquinoxAdapter.java @@ -33,7 +33,7 @@ public EquinoxAdapter(StartupContextCfg cfg) { } @Override - public void addFrameworkJars(ClassPathBuilder builder) throws IOException { - builder.addJarFolder(equinoxHome); + public ClassPathBuilder addFrameworkJars(ClassPathBuilder builder) throws IOException { + return builder.addJarFolder(equinoxHome); } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/FelixAdapter.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/FelixAdapter.java index a23bf3466e0..028eef451ec 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/FelixAdapter.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/FelixAdapter.java @@ -33,7 +33,7 @@ public FelixAdapter(StartupContextCfg cfg) { @Override - public void addFrameworkJars(ClassPathBuilder cpb) throws IOException { - cpb.addJar(new File(felixHome, "bin/felix.jar")); + public ClassPathBuilder addFrameworkJars(ClassPathBuilder builder) throws IOException { + return builder.addJar(new File(felixHome, "bin/felix.jar")); } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/KnopflerfishAdapter.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/KnopflerfishAdapter.java index 9498aa606dd..f0a860d19ce 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/KnopflerfishAdapter.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/KnopflerfishAdapter.java @@ -33,7 +33,7 @@ public KnopflerfishAdapter(StartupContextCfg cfg) { @Override - public void addFrameworkJars(ClassPathBuilder cpb) throws IOException { - cpb.addJar(new File(kfHome, "framework.jar")); + public ClassPathBuilder addFrameworkJars(ClassPathBuilder cpb) throws IOException { + return cpb.addJar(new File(kfHome, "framework.jar")); } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/OsgiPlatformAdapter.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/OsgiPlatformAdapter.java index 03ae296a16f..cc4fddeefb9 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/OsgiPlatformAdapter.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/OsgiPlatformAdapter.java @@ -22,7 +22,9 @@ interface OsgiPlatformAdapter { /** * Adds the jar files of the OSGi platform to the given {@link ClassPathBuilder} + * + * @return the parameter to allow fluent api call */ - void addFrameworkJars(ClassPathBuilder builder) throws IOException; + ClassPathBuilder addFrameworkJars(ClassPathBuilder builder) throws IOException; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/GlassfishBootstrapClassLoader.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/GlassfishOsgiBootstrapClassLoader.java similarity index 61% rename from nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/GlassfishBootstrapClassLoader.java rename to nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/GlassfishOsgiBootstrapClassLoader.java index 480594306f9..73548358a33 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cp/GlassfishBootstrapClassLoader.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/GlassfishOsgiBootstrapClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -14,18 +14,18 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package com.sun.enterprise.glassfish.bootstrap.cp; +package com.sun.enterprise.glassfish.bootstrap.launch; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.net.URLClassLoader; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; +import java.util.Properties; + +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; /** @@ -34,13 +34,12 @@ *

* List: *

    - *
  • GlassFish Java Util Logging Extension - *
  • Grizzly NPN API + *
  • GlassFish OSGI Bootstrap *
* * @author David Matejcek */ -public class GlassfishBootstrapClassLoader extends URLClassLoader { +public class GlassfishOsgiBootstrapClassLoader extends GlassfishUrlClassLoader { static { registerAsParallelCapable(); @@ -53,26 +52,29 @@ public class GlassfishBootstrapClassLoader extends URLClassLoader { * @param parent - parent classloader * @throws IOException - if required libraries (internally listed) could not be read */ - public GlassfishBootstrapClassLoader(final File glassfishDir, final ClassLoader parent) throws IOException { - super(createUrls(glassfishDir), parent); + public GlassfishOsgiBootstrapClassLoader(final File glassfishDir, final ClassLoader parent) throws IOException { + super("GlassFishOsgiBootstrap", createUrls(glassfishDir), parent); } - /** - * Returns class name, hash code and list of managed urls. - */ - @Override - public String toString() { - return getClass().getName() + "@" + Integer.toHexString(hashCode()) + ": " - + Arrays.stream(getURLs()).collect(Collectors.toList()); + public void launchGlassFishServer(final Properties properties) { + try { + @SuppressWarnings("unchecked") + final Class launcherClass = (Class) loadClass( + "org.glassfish.main.boot.osgi.GlassFishOsgiLauncher"); + final Launcher launcher = launcherClass.getDeclaredConstructor(ClassLoader.class).newInstance(this); + launcher.launch(properties); + } catch (Exception e) { + throw new Error("Failed to launch GlassFish Server!", e); + } } private static URL[] createUrls(final File glassfishDir) throws IOException { final List urls = new ArrayList<>(); - final File libDir = glassfishDir.toPath().resolve(Paths.get("lib", "bootstrap")).toFile(); - urls.add(getURL(libDir, "glassfish-jul-extension")); - return urls.toArray(new URL[urls.size()]); + final File libDir = glassfishDir.toPath().resolve(Path.of("lib", "bootstrap")).toFile(); + urls.add(getURL(libDir, "glassfish-osgi-bootstrap")); + return urls.toArray(URL[]::new); } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/Launcher.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/Launcher.java new file mode 100644 index 00000000000..f43b5a05d06 --- /dev/null +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/Launcher.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.enterprise.glassfish.bootstrap.launch; + +import java.util.Properties; + +public interface Launcher { + + void launch(Properties properties) throws Exception; +} diff --git a/nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder b/nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder deleted file mode 100644 index 99bcf4338ed..00000000000 --- a/nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.embeddable.spi.RuntimeBuilder +++ /dev/null @@ -1,3 +0,0 @@ -com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishRuntimeBuilder -com.sun.enterprise.glassfish.bootstrap.embedded.EmbeddedGlassFishRuntimeBuilder -com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntimeBuilder diff --git a/nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor b/nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor deleted file mode 100644 index f1caf75c33c..00000000000 --- a/nucleus/core/bootstrap/src/main/resources/META-INF/services/org.glassfish.hk2.api.PopulatorPostProcessor +++ /dev/null @@ -1 +0,0 @@ -com.sun.enterprise.glassfish.bootstrap.embedded.EmbeddedInhabitantsParser diff --git a/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilderIT.java b/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilderIT.java index 691855555ea..346e06eca90 100644 --- a/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilderIT.java +++ b/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cp/ClassLoaderBuilderIT.java @@ -17,10 +17,10 @@ package com.sun.enterprise.glassfish.bootstrap.cp; -import com.sun.enterprise.glassfish.bootstrap.StartupContextCfgFactory; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; import com.sun.enterprise.glassfish.bootstrap.cfg.ServerFiles; import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextCfg; +import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextCfgFactory; import java.io.File; import java.io.IOException; @@ -30,6 +30,7 @@ import org.junit.jupiter.api.Test; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.ASADMIN_ARGS; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_PROP_NAME; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTANCE_ROOT_PROP_NAME; import static org.hamcrest.CoreMatchers.anyOf; @@ -37,6 +38,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.stringContainsInOrder; import static org.junit.jupiter.api.Assertions.assertAll; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.osgi.framework.Constants.FRAMEWORK_SYSTEMPACKAGES; @@ -48,9 +50,11 @@ class ClassLoaderBuilderIT { @Test void createLauncher_Felix() throws Exception { StartupContextCfg cfg = createStartupContextCfg(); - ClassLoader loader = ClassLoaderBuilder.createLauncherCL(cfg, ClassLoader.getPlatformClassLoader()); + assertEquals("-something", cfg.getProperty(ASADMIN_ARGS), + ASADMIN_ARGS + " wasn't written through to startup context cfg."); + ClassLoader loader = ClassLoaderBuilder.createOSGiFrameworkLauncherCL(cfg, ClassLoader.getPlatformClassLoader()); assertNotNull(loader); - Class osgiClass = loader.loadClass("org.osgi.framework.Bundle"); + Class osgiClass = loader.loadClass("org.osgi.framework.BundleReference"); assertNotNull(osgiClass); Class clazz = loader.loadClass("org.apache.felix.framework.Felix"); assertNotNull(clazz); @@ -81,17 +85,17 @@ private StartupContextCfg createStartupContextCfg() throws IOException { Path jarFilesDir = detectBasedir().toPath().resolve(Path.of("target", "test-osgi")); Files.copy(jarFilesDir.resolve("glassfish-jul-extension.jar"), bootstrapDir.resolve("glassfish-jul-extension.jar")); Files.copy(jarFilesDir.resolve("org.apache.felix.main.jar"), felixBin.resolve("felix.jar")); - Files.copy(jarFilesDir.resolve("simple-glassfish-api.jar"), modulesDir.resolve("simple-glassfish-api.jar")); - Files.copy(jarFilesDir.resolve(Path.of("..", "glassfish.jar")), modulesDir.resolve("glassfish.jar")); + Files.copy(jarFilesDir.resolve("simple-glassfish-api.jar"), bootstrapDir.resolve("simple-glassfish-api.jar")); + Files.copy(jarFilesDir.resolve(Path.of("..", "glassfish.jar")), bootstrapDir.resolve("glassfish.jar")); - Properties properties = new Properties(); + Properties args = new Properties(); Path cfgDir = Files.createDirectories(installRoot.resolve(Path.of("config"))); Files.createFile(cfgDir.resolve("osgi.properties")); - properties.setProperty(INSTALL_ROOT_PROP_NAME, installRoot.toFile().getAbsolutePath()); + args.setProperty(INSTALL_ROOT_PROP_NAME, installRoot.toFile().getAbsolutePath()); + args.setProperty(INSTANCE_ROOT_PROP_NAME, instanceRoot.toFile().getAbsolutePath()); + args.setProperty(ASADMIN_ARGS, "-something"); - properties.setProperty(INSTANCE_ROOT_PROP_NAME, instanceRoot.toFile().getAbsolutePath()); - - return StartupContextCfgFactory.createStartupContextCfg(OsgiPlatform.Felix, files, new String[0]); + return StartupContextCfgFactory.createStartupContextCfg(OsgiPlatform.Felix, files, args); } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java index 707d1a9d09f..45686919b3d 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -16,7 +17,6 @@ package com.sun.enterprise.v3.admin; -import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextUtil; import com.sun.enterprise.module.bootstrap.StartupContext; import com.sun.enterprise.security.store.IdentityManagement; @@ -27,8 +27,11 @@ import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Properties; +import java.util.StringTokenizer; import java.util.logging.Logger; import org.glassfish.api.admin.PasswordAliasStore; @@ -38,6 +41,9 @@ import org.glassfish.server.ServerEnvironmentImpl; import org.jvnet.hk2.annotations.Service; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.ARG_SEP; +import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.ORIGINAL_ARGS; + /** * An implementation of the @link {IdentityManagement} that manages the password needs of the server. This * implementation consults the Java KeyStore and assumes that the stores are available in server's configuration area. @@ -47,22 +53,22 @@ @Service(name = "jks-based") public class IdmService implements PostConstruct, IdentityManagement { + private static final String FIXED_KEY = "master-password"; // the fixed key for master-password file + private static final String PASSWORDFILE_OPTION_TO_ASMAIN = "-passwordfile"; // note single hyphen, in line with other args to ASMain! + private static final String STDIN_OPTION_TO_ASMAIN = "-read-stdin"; // note single hyphen, in line with other args to ASMain! + + private static final String MP_PROPERTY = "AS_ADMIN_MASTERPASSWORD"; + private final Logger logger = Logger.getAnonymousLogger(); @Inject - private volatile StartupContext sc = null; + private volatile StartupContext sc; @Inject - private volatile ServerEnvironmentImpl env = null; + private volatile ServerEnvironmentImpl env; private char[] masterPassword; - private static final String FIXED_KEY = "master-password"; // the fixed key for master-password file - private static final String PASSWORDFILE_OPTION_TO_ASMAIN = "-passwordfile"; // note single hyphen, in line with other args to ASMain! - private static final String STDIN_OPTION_TO_ASMAIN = "-read-stdin"; // note single hyphen, in line with other args to ASMain! - - private static final String MP_PROPERTY = "AS_ADMIN_MASTERPASSWORD"; - @Override public void postConstruct() { boolean success; @@ -113,7 +119,7 @@ private boolean setFromMasterPasswordFile() { private boolean setFromAsMainArguments() { File pwf = null; try { - String[] args = StartupContextUtil.getOriginalArguments(sc); + String[] args = getOriginalArguments(sc); int index = 0; for (String arg : args) { if (PASSWORDFILE_OPTION_TO_ASMAIN.equals(arg)) { @@ -187,4 +193,21 @@ private boolean setFromStdin() { } } + /** + * @param context + * @return parsed array of arguments saved as {@link #ORIGINAL_ARGS} + */ + private static String[] getOriginalArguments(StartupContext context) { + Properties args = context.getArguments(); + String s = args.getProperty(ORIGINAL_ARGS); + if (s == null) { + return new String[0]; + } + StringTokenizer st = new StringTokenizer(s, ARG_SEP, false); + List result = new ArrayList<>(); + while (st.hasMoreTokens()) { + result.add(st.nextToken()); + } + return result.toArray(new String[result.size()]); + } } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocationsCommand.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocationsCommand.java index 22687ce801e..94919c81ffd 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocationsCommand.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/LocationsCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -18,7 +18,6 @@ package com.sun.enterprise.v3.admin; import com.sun.enterprise.config.serverbeans.Domain; -import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextUtil; import jakarta.inject.Inject; import jakarta.inject.Singleton; @@ -34,8 +33,9 @@ import org.glassfish.api.admin.CommandLock; import org.glassfish.api.admin.RestEndpoint; import org.glassfish.api.admin.RestEndpoints; +import org.glassfish.api.admin.ServerEnvironment; +import org.glassfish.internal.api.ServerContext; import org.glassfish.internal.config.UnprocessedConfigListener; -import org.glassfish.server.ServerEnvironmentImpl; import org.jvnet.hk2.annotations.Service; import static org.glassfish.api.ActionReport.ExitCode.SUCCESS; @@ -58,7 +58,10 @@ public class LocationsCommand implements AdminCommand { @Inject - ServerEnvironmentImpl serverEnvironment; + private ServerEnvironment serverEnvironment; + + @Inject + private ServerContext server; @Inject private UnprocessedConfigListener ucl; @@ -70,13 +73,13 @@ public void execute(AdminCommandContext context) { report.setMessage(serverEnvironment.getInstanceRoot().getAbsolutePath().replace('\\', '/')); MessagePart messagePart = report.getTopMessagePart(); - messagePart.addProperty("Base-Root", StartupContextUtil.getInstallRoot(serverEnvironment.getStartupContext()).getAbsolutePath()); + messagePart.addProperty("Base-Root", server.getInstallRoot().getAbsolutePath()); messagePart.addProperty("Domain-Root", serverEnvironment.getInstanceRoot().getAbsolutePath()); messagePart.addProperty("Instance-Root", serverEnvironment.getInstanceRoot().getAbsolutePath()); messagePart.addProperty("Config-Dir", serverEnvironment.getConfigDirPath().getAbsolutePath()); - messagePart.addProperty("Uptime", "" + getUptime()); + messagePart.addProperty("Uptime", Long.toString(getUptime())); messagePart.addProperty("Pid", Long.toString(ProcessHandle.current().pid())); - messagePart.addProperty("Restart-Required", "" + ucl.serverRequiresRestart()); + messagePart.addProperty("Restart-Required", Boolean.toString(ucl.serverRequiresRestart())); } private long getUptime() { diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java index 1dbedaea7d2..5eb65d270f2 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,9 +17,9 @@ package com.sun.enterprise.v3.admin; +import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.bootstrap.StartupContext; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.JavaClassRunner; import com.sun.enterprise.util.StringUtils; @@ -32,6 +32,7 @@ import org.glassfish.api.admin.AdminCommandContext; import org.glassfish.embeddable.GlassFish; import org.glassfish.internal.api.Globals; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * For non-verbose mode: Stop this server, spawn a new JVM that will wait for this JVM to die. The new JVM then starts @@ -158,18 +159,18 @@ private void doReincarnation() throws RDCException { } private boolean setupReincarnationWithAsadmin() throws RDCException { - classpath = props.getProperty("-asadmin-classpath"); - classname = props.getProperty("-asadmin-classname"); - argsString = props.getProperty("-asadmin-args"); + classpath = props.getProperty(BootstrapKeys.ASADMIN_CP); + classname = props.getProperty(BootstrapKeys.ASADMIN_CN); + argsString = props.getProperty(BootstrapKeys.ASADMIN_ARGS); return verify("restart.server.asadminError"); } private boolean setupReincarnationWithOther() throws RDCException { - classpath = props.getProperty("-startup-classpath"); - classname = props.getProperty("-startup-classname"); - argsString = props.getProperty("-startup-args"); + classpath = props.getProperty(BootstrapKeys.ORIGINAL_CP); + classname = props.getProperty(BootstrapKeys.ORIGINAL_CN); + argsString = props.getProperty(BootstrapKeys.ORIGINAL_ARGS); return verify("restart.server.nonAsadminError"); } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/Strings.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/Strings.java index aaf287d6c64..d876d2c2876 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/Strings.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.v3.admin; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. One file with Strings So one class for messing with them! Nothing in here is public diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java index a5ca84c32a5..67ab9fd7ce1 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java @@ -59,11 +59,11 @@ import org.glassfish.api.event.EventListener; import org.glassfish.api.event.Events; import org.glassfish.api.event.RestrictTo; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.internal.api.ClassLoaderHierarchy; import org.glassfish.internal.api.DelegatingClassLoader; import org.glassfish.internal.api.DelegatingClassLoader.ClassFinder; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.jvnet.hk2.annotations.Service; import static java.lang.System.Logger.Level.DEBUG; @@ -316,7 +316,7 @@ private static class NonCachedURLConnection extends JarURLConnection { private JarURLConnection jarURLConnection; - public NonCachedURLConnection(URL url) throws MalformedURLException { + private NonCachedURLConnection(URL url) throws MalformedURLException { super(url); } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java index eb9e2149719..7c3be3683d3 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppServerStartup.java @@ -148,7 +148,7 @@ public void setStartupContext(StartupContext context) { * A keep alive thread that keeps the server JVM from going down as long as GlassFish kernel is up. */ private Thread serverThread; - private boolean shutdownSignal = false; + private boolean shutdownSignal; private final static String THREAD_POLICY_PROPERTY = "org.glassfish.startupThreadPolicy"; private final static String MAX_STARTUP_THREAD_PROPERTY = "org.glassfish.maxStartupThreads"; 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 da264b68132..e25856033d3 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 @@ -17,6 +17,7 @@ package com.sun.enterprise.v3.server; +import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import java.io.File; @@ -38,9 +39,8 @@ import java.util.stream.Stream; import org.glassfish.api.admin.ServerEnvironment; -import org.glassfish.common.util.GlassfishUrlClassLoader; -import org.glassfish.hk2.api.PostConstruct; import org.glassfish.kernel.KernelLoggerInfo; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.jvnet.hk2.annotations.Service; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; @@ -70,28 +70,27 @@ * @author Sanjeeb.Sahoo@Sun.COM */ @Service -public class CommonClassLoaderServiceImpl implements PostConstruct { +public class CommonClassLoaderServiceImpl { private static final Logger LOG = KernelLoggerInfo.getLogger(); - /** - * The common classloader. - */ - private GlassfishUrlClassLoader commonClassLoader; - @Inject private APIClassLoaderServiceImpl acls; @Inject private ServerEnvironment env; + /** + * The common classloader. + */ + private GlassfishUrlClassLoader commonClassLoader; private ClassLoader apiClassLoader; private String commonClassPath = ""; private static final String SERVER_EXCLUDED_ATTR_NAME = "GlassFish-ServerExcluded"; - @Override - public void postConstruct() { + @PostConstruct + private void postConstruct() { apiClassLoader = Objects.requireNonNull(acls.getAPIClassLoader(), "API ClassLoader is null!"); createCommonClassLoader(); } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerContextImpl.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerContextImpl.java index 73c564b60e2..c07e82dc034 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerContextImpl.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerContextImpl.java @@ -17,7 +17,7 @@ package com.sun.enterprise.v3.server; -import com.sun.enterprise.glassfish.bootstrap.cfg.StartupContextUtil; +import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.module.bootstrap.StartupContext; import jakarta.inject.Inject; @@ -81,7 +81,7 @@ public String[] getCmdLineArgs() { @Override public File getInstallRoot() { - return StartupContextUtil.getInstallRoot(startupContext); + return new File(startupContext.getArguments().getProperty(BootstrapKeys.INSTALL_ROOT_PROP_NAME)); } @Override diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java index 4e4d38f9885..a9ec100d521 100755 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java @@ -33,10 +33,10 @@ import java.util.logging.Logger; import org.glassfish.api.logging.LogHelper; -import org.glassfish.common.util.GlassfishUrlClassLoader; import org.glassfish.internal.api.ServerContext; import org.glassfish.kernel.KernelLoggerInfo; import org.glassfish.loader.util.ASClassLoaderUtil; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; /** * @author Sridatta Viswanath diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SystemTasksImpl.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SystemTasksImpl.java index 3f73c85ecd5..df0d175f35e 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SystemTasksImpl.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/SystemTasksImpl.java @@ -25,7 +25,6 @@ import com.sun.enterprise.config.serverbeans.JavaConfig; import com.sun.enterprise.config.serverbeans.Server; import com.sun.enterprise.config.serverbeans.SystemProperty; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.universal.process.ProcessUtils; import com.sun.enterprise.util.SystemPropertyConstants; import com.sun.enterprise.util.io.ServerDirs; @@ -48,6 +47,7 @@ import org.glassfish.hk2.runlevel.RunLevel; import org.glassfish.internal.api.InitRunLevel; import org.glassfish.kernel.KernelLoggerInfo; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Optional; import org.jvnet.hk2.annotations.Service; diff --git a/nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/UberMain.java b/nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/UberMain.java index 45f0df07b9c..2b23e8985aa 100644 --- a/nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/UberMain.java +++ b/nucleus/core/kernel/src/main/java/org/glassfish/runnablejar/UberMain.java @@ -18,7 +18,6 @@ import com.sun.enterprise.config.serverbeans.Application; import com.sun.enterprise.config.serverbeans.Domain; -import com.sun.enterprise.glassfish.bootstrap.embedded.EmbeddedGlassFishRuntimeBuilder; import java.io.BufferedReader; import java.io.IOException; @@ -36,6 +35,7 @@ import org.glassfish.embeddable.GlassFishProperties; import org.glassfish.embeddable.GlassFishRuntime; import org.glassfish.grizzly.config.dom.NetworkListener; +import org.glassfish.main.boot.embedded.EmbeddedGlassFishRuntimeBuilder; import org.glassfish.runnablejar.commandline.Arguments; import org.glassfish.runnablejar.commandline.CommandLineParser; @@ -43,7 +43,6 @@ import static java.util.logging.Level.FINE; import static java.util.logging.Level.INFO; import static java.util.logging.Level.SEVERE; -import static org.glassfish.embeddable.CommandResult.ExitStatus.SUCCESS; /** * This is main class for the uber jars viz., glassfish-embedded-all.jar and diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/runnablejar/UberMainTest.java b/nucleus/core/kernel/src/test/java/org/glassfish/runnablejar/UberMainTest.java index 4fa56c05527..c740a8eb212 100644 --- a/nucleus/core/kernel/src/test/java/org/glassfish/runnablejar/UberMainTest.java +++ b/nucleus/core/kernel/src/test/java/org/glassfish/runnablejar/UberMainTest.java @@ -42,21 +42,21 @@ */ public class UberMainTest { - @Test - public void getInfoAfterStartup() throws GlassFishException { + @Test + public void getInfoAfterStartup() throws GlassFishException { + String info = new InfoPrinter().getInfoAfterStartup(List.of(app("/app1"), app("application")), + List.of(listener(8080, false), listener(8181, true))); + System.out.println(info); + } - String info = new InfoPrinter().getInfoAfterStartup(List.of(app("/app1"), app("application")), - List.of(listener(8080, false), listener(8181, true))); - System.out.println(info); - } - @Test - public void getInfoAfterStartup_noApps() throws GlassFishException { + @Test + public void getInfoAfterStartup_noApps() throws GlassFishException { + String info = new InfoPrinter().getInfoAfterStartup(List.of(), + List.of(listener(8080, false), listener(8181, true))); + System.out.println(info); + } - String info = new InfoPrinter().getInfoAfterStartup(List.of(), - List.of(listener(8080, false), listener(8181, true))); - System.out.println(info); - } private MockListener listener(int port, boolean secure) { return new MockListener(port, secure); @@ -68,7 +68,7 @@ private MockApplication app(String app) { private class MockApplication implements Application { - private String name; + private final String name; public MockApplication(String name) { this.name = name; @@ -91,157 +91,157 @@ public String getEnabled() { @Override public void setContextRoot(String contextRoot) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getLocation() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setLocation(String location) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getObjectType() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setObjectType(String objectType) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setEnabled(String enabled) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getLibraries() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setLibraries(String libraries) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getAvailabilityEnabled() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setAvailabilityEnabled(String availabilityEnabled) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getAsyncReplication() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setAsyncReplication(String asyncReplication) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getDirectoryDeployed() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setDirectoryDeployed(String directoryDeployed) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getDescription() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setDescription(String description) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getDeploymentOrder() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setDeploymentOrder(String deploymentOrder) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public List getModule() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public List getEngine() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Resources getResources() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setResources(Resources resources) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public AppTenants getAppTenants() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setAppTenants(AppTenants appTenants) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public List getExtensions() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public List getProperty() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setName(String name) throws PropertyVetoException { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property addProperty(Property property) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property lookupProperty(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property removeProperty(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property removeProperty(Property property) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } } @@ -275,209 +275,209 @@ public String getSecurityEnabled() { @Override public Http getHttp() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setHttp(Http http) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getName() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setName(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public PortUnification getPortUnification() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setPortUnification(PortUnification portUnification) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public HttpRedirect getHttpRedirect() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setHttpRedirect(HttpRedirect httpRedirect) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public ProtocolChainInstanceHandler getProtocolChainInstanceHandler() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setProtocolChainInstanceHandler(ProtocolChainInstanceHandler protocolChainHandler) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setSecurityEnabled(String securityEnabled) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Ssl getSsl() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setSsl(Ssl ssl) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public List getProperty() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property addProperty(Property property) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property lookupProperty(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property removeProperty(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property removeProperty(Property property) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } }; } @Override public String getAddress() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setAddress(String address) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setEnabled(String enabled) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getJkConfigurationFile() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setJkConfigurationFile(String configFile) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getJkEnabled() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setJkEnabled(String jkEnabled) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getName() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setName(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getType() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setType(String type) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setPort(String port) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getProtocol() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setProtocol(String protocol) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getThreadPool() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setThreadPool(String threadPool) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public String getTransport() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public void setTransport(String transport) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public List getProperty() { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property addProperty(Property property) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property lookupProperty(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property removeProperty(String name) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } @Override public Property removeProperty(Property property) { - throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + throw new UnsupportedOperationException("Not supported yet."); } } } diff --git a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java index e7354030591..95343fd3769 100644 --- a/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java +++ b/nucleus/core/kernel/src/test/java/org/glassfish/tests/kernel/deployment/EventsTest.java @@ -84,11 +84,12 @@ public void setup() throws Exception { events.register(listener); } + @AfterEach public void deleteApplications() { - if (application != null) { - application.delete(); - } + if (application != null) { + application.delete(); + } } diff --git a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java index 795e9d8187f..a14fd6595a1 100644 --- a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java +++ b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java @@ -39,7 +39,7 @@ import java.util.ResourceBundle; import java.util.Set; -import org.glassfish.common.util.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.jvnet.hk2.annotations.Service; @Service diff --git a/nucleus/core/pom.xml b/nucleus/core/pom.xml index 8053254c20b..16c00abd7a5 100644 --- a/nucleus/core/pom.xml +++ b/nucleus/core/pom.xml @@ -34,6 +34,7 @@ bootstrap + bootstrap-osgi kernel api-exporter extra-jre-packages diff --git a/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/InstanceValidateRemoteDirDeploymentCommand.java b/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/InstanceValidateRemoteDirDeploymentCommand.java index 89fd152a004..cd27b8b3774 100644 --- a/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/InstanceValidateRemoteDirDeploymentCommand.java +++ b/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/InstanceValidateRemoteDirDeploymentCommand.java @@ -17,7 +17,6 @@ package org.glassfish.deployment.admin; import com.sun.enterprise.config.serverbeans.Domain; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import java.io.File; import java.util.logging.Level; @@ -33,6 +32,7 @@ import org.glassfish.api.admin.RuntimeType; import org.glassfish.deployment.common.DeploymentUtils; import org.glassfish.hk2.api.PerLookup; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jvnet.hk2.annotations.Service; /** diff --git a/nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight/impl/client/Strings.java b/nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight/impl/client/Strings.java index 1825e14eb5a..b5ed12e50bc 100644 --- a/nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight/impl/client/Strings.java +++ b/nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight/impl/client/Strings.java @@ -16,7 +16,7 @@ package org.glassfish.flashlight.impl.client; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. diff --git a/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java b/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java index 20c8338e187..2dc210fe511 100644 --- a/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java +++ b/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java @@ -26,7 +26,6 @@ import com.sun.enterprise.admin.cli.ProgramOptions; import com.sun.enterprise.admin.cli.remote.RemoteCLICommand; import com.sun.enterprise.admin.util.CommandModelData.ParamModelData; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; import jakarta.inject.Inject; @@ -54,6 +53,7 @@ import org.glassfish.hk2.api.MultiException; import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.jline.reader.Completer; import org.jline.reader.EndOfFileException; import org.jline.reader.LineReader; diff --git a/nucleus/security/core/src/main/java/com/sun/enterprise/security/admin/cli/Strings.java b/nucleus/security/core/src/main/java/com/sun/enterprise/security/admin/cli/Strings.java index df84b178d0d..6326f4135fd 100644 --- a/nucleus/security/core/src/main/java/com/sun/enterprise/security/admin/cli/Strings.java +++ b/nucleus/security/core/src/main/java/com/sun/enterprise/security/admin/cli/Strings.java @@ -16,7 +16,7 @@ package com.sun.enterprise.security.admin.cli; -import com.sun.enterprise.universal.i18n.LocalStringsImpl; +import org.glassfish.main.jdke.i18n.LocalStringsImpl; /** * Strings -- Get your Strings here. One file with Strings So one class for messing with them! Nothing in here is public From 21ae0cd925a512cb82a607c0fe4c32787bef3d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 9 Oct 2024 23:55:14 +0200 Subject: [PATCH 10/38] Updated POM and assembly files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - For CLI I tried to eliminate what is not required. - It should be refactored later, so CLI would have much cleaner dependency tree Signed-off-by: David Matějček --- appserver/admin/cli/pom.xml | 2 +- appserver/appclient/client/acc/pom.xml | 5 + appserver/appclient/server/core/pom.xml | 2 +- .../connectors/connectors-runtime/pom.xml | 5 + .../glassfish/src/main/assembly/glassfish.xml | 10 +- .../web/src/main/assembly/web.xml | 10 +- appserver/extras/embedded/all/pom.xml | 12 ++ .../extras/embedded/common/bootstrap/pom.xml | 8 +- appserver/extras/embedded/nucleus/pom.xml | 12 ++ appserver/extras/embedded/web/pom.xml | 12 ++ appserver/web/war-util/pom.xml | 5 + appserver/web/weld-integration/pom.xml | 5 + appserver/webservices/jsr109-impl/pom.xml | 5 + nucleus/admin/cli/pom.xml | 113 +++++++++++++++--- nucleus/admin/config-api/pom.xml | 2 +- nucleus/admin/server-mgmt/pom.xml | 2 +- nucleus/common/common-util/pom.xml | 5 + nucleus/core/bootstrap/pom.xml | 35 +----- nucleus/core/kernel/pom.xml | 21 +++- .../kernel/src/test/resources/DomainTest.xml | 2 + nucleus/core/logging/pom.xml | 5 + .../atomic/src/main/assembly/atomic.xml | 8 ++ .../nucleus/src/main/assembly/nucleus-new.xml | 8 ++ nucleus/featuresets/atomic/pom.xml | 16 +++ .../osgi-cli-interactive/pom.xml | 7 +- nucleus/parent/pom.xml | 2 +- 26 files changed, 259 insertions(+), 60 deletions(-) diff --git a/appserver/admin/cli/pom.xml b/appserver/admin/cli/pom.xml index fc0d76684bc..869737d386b 100755 --- a/appserver/admin/cli/pom.xml +++ b/appserver/admin/cli/pom.xml @@ -65,7 +65,7 @@ ../../modules - ../../lib/bootstrap/glassfish-jul-extension.jar + ../bootstrap/glassfish-jul-extension.jar ../bootstrap/glassfish-jdk-extensions.jar ../bootstrap/simple-glassfish-api.jar
diff --git a/appserver/appclient/client/acc/pom.xml b/appserver/appclient/client/acc/pom.xml index f29aa1976b9..3a611bd7fe3 100755 --- a/appserver/appclient/client/acc/pom.xml +++ b/appserver/appclient/client/acc/pom.xml @@ -77,6 +77,11 @@ glassfish-jul-extension compile + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + org.glassfish.hk2 hk2-core diff --git a/appserver/appclient/server/core/pom.xml b/appserver/appclient/server/core/pom.xml index 1b55cd99a2c..394a26983e6 100644 --- a/appserver/appclient/server/core/pom.xml +++ b/appserver/appclient/server/core/pom.xml @@ -50,7 +50,7 @@ org.glassfish.main.common - common-util + glassfish-jdk-extensions ${project.version} diff --git a/appserver/connectors/connectors-runtime/pom.xml b/appserver/connectors/connectors-runtime/pom.xml index 48f97dca425..916084f04dc 100644 --- a/appserver/connectors/connectors-runtime/pom.xml +++ b/appserver/connectors/connectors-runtime/pom.xml @@ -66,6 +66,11 @@ common-util ${project.version} + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + org.glassfish.main.deployment deployment-common diff --git a/appserver/distributions/glassfish/src/main/assembly/glassfish.xml b/appserver/distributions/glassfish/src/main/assembly/glassfish.xml index 743a0f2ae89..fd96e2b1848 100644 --- a/appserver/distributions/glassfish/src/main/assembly/glassfish.xml +++ b/appserver/distributions/glassfish/src/main/assembly/glassfish.xml @@ -1,7 +1,7 @@ compile + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + org.glassfish.hk2 hk2-core diff --git a/nucleus/core/bootstrap/pom.xml b/nucleus/core/bootstrap/pom.xml index 58dde84f9f2..ae38deb29cf 100755 --- a/nucleus/core/bootstrap/pom.xml +++ b/nucleus/core/bootstrap/pom.xml @@ -60,12 +60,9 @@ provided - org.glassfish.hk2 - hk2-core - - - org.glassfish.hk2 - hk2-extras + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} provided @@ -74,25 +71,11 @@ provided - org.glassfish.main.common simple-glassfish-api ${project.version} - - org.glassfish.main.common - common-util - ${project.version} - - - org.glassfish.main.common - glassfish-api - - - org.glassfish.annotations logging-annotation-processor @@ -126,16 +109,6 @@ - - org.apache.felix - maven-bundle-plugin - - - com.sun.enterprise.glassfish.bootstrap.osgi.GlassFishMainActivator - - - - maven-dependency-plugin @@ -146,7 +119,7 @@ pre-integration-test - org.apache.felix.main,simple-glassfish-api,glassfish-jul-extension + org.apache.felix.main,simple-glassfish-api,glassfish-jul-extension,glassfish-jdk-extensions ${project.build.directory}/test-osgi true diff --git a/nucleus/core/kernel/pom.xml b/nucleus/core/kernel/pom.xml index 0087ca35369..b5a701507e6 100755 --- a/nucleus/core/kernel/pom.xml +++ b/nucleus/core/kernel/pom.xml @@ -31,9 +31,10 @@ glassfish-jar Kernel Classes - + false + org.glassfish.main.jul.GlassFishLogManager @@ -105,6 +106,11 @@ common-util ${project.version} + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + org.glassfish.main.common simple-glassfish-api @@ -116,6 +122,11 @@ glassfish ${project.version} + + org.glassfish.main.core + glassfish-osgi-bootstrap + ${project.version} + org.glassfish.main.core logging @@ -188,6 +199,11 @@ org.hamcrest hamcrest + + org.glassfish.main + glassfish-jul-extension + test + org.glassfish.expressly @@ -266,7 +282,6 @@ maven-assembly-plugin - 3.7.1 commonClassLoader tests @@ -317,7 +332,7 @@ - + fastest diff --git a/nucleus/core/kernel/src/test/resources/DomainTest.xml b/nucleus/core/kernel/src/test/resources/DomainTest.xml index 3c1ab6f7bad..d6d938780a3 100644 --- a/nucleus/core/kernel/src/test/resources/DomainTest.xml +++ b/nucleus/core/kernel/src/test/resources/DomainTest.xml @@ -113,6 +113,8 @@ + -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager + -Djava.util.logging.config.block=true -Djava.awt.headless=true -Djdk.corba.allowOutputStreamSubclass=true -Djdk.tls.rejectClientInitiatedRenegotiation=true diff --git a/nucleus/core/logging/pom.xml b/nucleus/core/logging/pom.xml index b48049e8637..17d3ff5c065 100755 --- a/nucleus/core/logging/pom.xml +++ b/nucleus/core/logging/pom.xml @@ -43,6 +43,11 @@ glassfish-jul-extension compile + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + org.glassfish.main.common glassfish-api diff --git a/nucleus/distributions/atomic/src/main/assembly/atomic.xml b/nucleus/distributions/atomic/src/main/assembly/atomic.xml index 54e0c73b433..bd585499e9a 100644 --- a/nucleus/distributions/atomic/src/main/assembly/atomic.xml +++ b/nucleus/distributions/atomic/src/main/assembly/atomic.xml @@ -74,7 +74,11 @@ ${temp.dir} + glassfish.jar + glassfish-osgi-bootstrap.jar + glassfish-jdk-extensions.jar glassfish-jul-extension.jar + simple-glassfish-api.jar ${install.dir.name}/lib/bootstrap @@ -140,7 +144,11 @@ org.osgi.util.promise.jar felix.jar nucleus-domain.jar + glassfish.jar + glassfish-osgi-bootstrap.jar + glassfish-jdk-extensions.jar glassfish-jul-extension.jar + simple-glassfish-api.jar ${install.dir.name}/modules diff --git a/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml b/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml index 6dfda6eb9bb..ae7d1e9f305 100644 --- a/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml +++ b/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml @@ -99,7 +99,11 @@ ${temp.dir} + glassfish.jar + glassfish-osgi-bootstrap.jar + glassfish-jdk-extensions.jar glassfish-jul-extension.jar + simple-glassfish-api.jar ${install.dir.name}/lib/bootstrap @@ -143,7 +147,11 @@ org.apache.felix.scr.jar org.osgi.util.function.jar org.osgi.util.promise.jar + glassfish.jar + glassfish-osgi-bootstrap.jar + glassfish-jdk-extensions.jar glassfish-jul-extension.jar + simple-glassfish-api.jar felix.jar nucleus-domain.jar cluster-cli.jar diff --git a/nucleus/featuresets/atomic/pom.xml b/nucleus/featuresets/atomic/pom.xml index d4e882130c2..eef18eef943 100644 --- a/nucleus/featuresets/atomic/pom.xml +++ b/nucleus/featuresets/atomic/pom.xml @@ -464,6 +464,17 @@ + + org.glassfish.main.core + glassfish-osgi-bootstrap + ${project.version} + + + * + * + + + org.glassfish.main.core kernel @@ -508,6 +519,11 @@ + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + org.glassfish.main.admin config-api diff --git a/nucleus/osgi-platforms/osgi-cli-interactive/pom.xml b/nucleus/osgi-platforms/osgi-cli-interactive/pom.xml index 9bfd3ae67df..4ca5b933553 100644 --- a/nucleus/osgi-platforms/osgi-cli-interactive/pom.xml +++ b/nucleus/osgi-platforms/osgi-cli-interactive/pom.xml @@ -39,6 +39,12 @@ + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + provided + org.glassfish.main.admin admin-cli @@ -48,7 +54,6 @@ org.jline jline provided - true diff --git a/nucleus/parent/pom.xml b/nucleus/parent/pom.xml index 5f747eb70f6..a5c183b6883 100644 --- a/nucleus/parent/pom.xml +++ b/nucleus/parent/pom.xml @@ -401,10 +401,10 @@ pom import + org.glassfish.grizzly grizzly-npn-api - ${grizzly.npn.version} From 9e285ae870146ebdb6e1c30108ed66a86a6f97f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 00:09:46 +0200 Subject: [PATCH 11/38] All GlassFish classloaders are parallelCapable and have names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../appclient/client/AppClientFacade.java | 4 +-- .../appclient/client/acc/ACCClassLoader.java | 9 ++++--- .../client/acc/JWSACCClassLoader.java | 7 +++-- .../ProviderContainerContractInfoImpl.java | 3 ++- .../core/AppClientServerApplication.java | 9 +++---- .../appclient/server/core/CarHandler.java | 10 +++---- .../internal/api/ConnectorClassFinder.java | 8 ++++-- .../connectors/util/ConnectorClassLoader.java | 11 +++++--- .../util/ConnectorRARClassLoader.java | 11 +++++--- .../enterprise/connectors/util/RARUtils.java | 7 +++-- .../full/deployment/EarClassLoader.java | 15 +++++------ .../full/deployment/EarLibClassLoader.java | 13 +++++---- .../ejb/deployment/EjbJarHandler.java | 2 +- .../ServletContainerInitializerUtil.java | 8 +++--- .../web/loader/WebappClassLoader.java | 6 +++-- .../web/loader/WebappClassLoaderTest.java | 2 +- .../com/sun/enterprise/web/WebModule.java | 4 +-- .../weld/BeanDeploymentArchiveImpl.java | 4 +-- .../webservices/WebServicesDeployer.java | 4 +-- .../monitoring/WebServiceTesterServlet.java | 4 ++- .../enterprise/admin/cli/CLIContainer.java | 8 +++--- .../admin/cli/DirectoryClassLoader.java | 8 ++++-- .../CustomizationTokensProvider.java | 2 +- .../cli/VerifyDomainXmlCommand.java | 3 ++- .../main/resources/config/logging.properties | 1 + .../enterprise/loader/ASURLClassLoader.java | 27 +++++++------------ .../internal/api/DelegatingClassLoader.java | 5 ++++ .../embeddable/GlassFishRuntime.java | 9 +++---- .../embeddable/spi/RuntimeBuilder.java | 8 +++++- .../server/AppLibClassLoaderServiceImpl.java | 10 ++++++- .../server/CommonClassLoaderServiceImpl.java | 6 ++--- .../v3/server/ServerLifecycleModule.java | 2 +- .../logging/LoggerInfoMetadataService.java | 3 ++- 33 files changed, 131 insertions(+), 102 deletions(-) diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java index b780cc3794c..5ae868dc7ad 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java @@ -379,8 +379,8 @@ private static AppClientContainer createContainerForClassName(Builder builder, S private static ClassLoader prepareLoaderToFindClassFile(final ClassLoader currentLoader) throws MalformedURLException { File currentDirPath = new File(System.getProperty("user.dir")); - ClassLoader newLoader = new GlassfishUrlClassLoader(new URL[] { currentDirPath.toURI().toURL() }, currentLoader); - return newLoader; + return new GlassfishUrlClassLoader("AppClientFacade(" + currentDirPath + ")", + new URL[] {currentDirPath.toURI().toURL()}, currentLoader); } private static AppClientContainer createContainerForClassFile(Builder builder, String classFilePath) diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java index cc02431ddcf..0cbb5695175 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java @@ -1,7 +1,6 @@ /* * Copyright (c) 2021, 2024 Contributors to Eclipse Foundation. * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2022 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -50,6 +49,10 @@ */ public class ACCClassLoader extends GlassfishUrlClassLoader { + static { + registerAsParallelCapable(); + } + private static final String AGENT_LOADER_CLASS_NAME = "org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader"; private static ACCClassLoader instance; @@ -108,13 +111,13 @@ private static void adjustACCAgentClassLoaderParent(ACCClassLoader instance) thr public ACCClassLoader(ClassLoader parent, final boolean shouldTransform) { - super(new URL[0], parent); + super("ApplicationClient", new URL[0], parent); this.shouldTransform = shouldTransform; clientCLDelegate = new ClientClassLoaderDelegate(this); } public ACCClassLoader(URL[] urls, ClassLoader parent) { - super(urls, parent); + super("ApplicationClient", urls, parent); clientCLDelegate = new ClientClassLoaderDelegate(this); } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java index f7aa8132bc6..b058a506a94 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/JWSACCClassLoader.java @@ -26,11 +26,14 @@ public class JWSACCClassLoader extends GlassfishUrlClassLoader { + static { + registerAsParallelCapable(); + } + private final ClientClassLoaderDelegate clientCLDelegate; public JWSACCClassLoader(URL[] urls, ClassLoader parent) { - super(urls, parent); - + super("JWS-ACC", urls, parent); clientCLDelegate = new ClientClassLoaderDelegate(this); } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java index fc7fa5581d7..a4eb7cf63cd 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java @@ -80,7 +80,8 @@ public ClassLoader getClassLoader() { @Override public ClassLoader getTempClassloader() { - PrivilegedAction action = () -> new GlassfishUrlClassLoader(classLoader.getURLs()); + PrivilegedAction action = () -> new GlassfishUrlClassLoader("PersistenceTmp", + classLoader.getURLs()); return AccessController.doPrivileged(action); } diff --git a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java index 5969dbf113a..5552193e5b0 100644 --- a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java +++ b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/AppClientServerApplication.java @@ -157,11 +157,10 @@ public boolean resume() throws Exception { @Override public ClassLoader getClassLoader() { - /* - * This cannot be null or it prevents the framework from invoking unload - * on the deployer for this app. - */ - PrivilegedAction action = () -> new GlassfishUrlClassLoader(new URL[0]); + // This cannot be null or it prevents the framework from invoking unload + // on the deployer for this app. + PrivilegedAction action = () -> new GlassfishUrlClassLoader( + "AppClientServer(" + deployedAppName + ")", new URL[0]); return AccessController.doPrivileged(action); } diff --git a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.java b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.java index 1138835bf87..6d2c138a6ab 100644 --- a/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.java +++ b/appserver/appclient/server/core/src/main/java/org/glassfish/appclient/server/core/CarHandler.java @@ -89,7 +89,7 @@ public boolean handles(ReadableArchive archive) throws IOException { @Override public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) { - PrivilegedAction action = () -> new ASURLClassLoader(parent); + PrivilegedAction action = () -> new ASURLClassLoader("CarHandler", parent); ASURLClassLoader cloader = AccessController.doPrivileged(action); try { cloader.addURL(context.getSource().getURI().toURL()); @@ -99,12 +99,8 @@ public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext co } try { - final DeploymentContext dc = context; - final ClassLoader cl = cloader; - - AccessController.doPrivileged( - new PermsArchiveDelegate.SetPermissionsAction( - SMGlobalPolicyUtil.CommponentType.car, dc, cl)); + AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction( + SMGlobalPolicyUtil.CommponentType.car, context, cloader)); } catch (PrivilegedActionException e) { throw new SecurityException(e.getException()); } diff --git a/appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorClassFinder.java b/appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorClassFinder.java index 78fc7b32abf..b2d00cf9d9f 100644 --- a/appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorClassFinder.java +++ b/appserver/connectors/connectors-internal-api/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorClassFinder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -28,11 +28,15 @@ */ public class ConnectorClassFinder extends ASURLClassLoader implements DelegatingClassLoader.ClassFinder { + static { + registerAsParallelCapable(); + } + private final DelegatingClassLoader.ClassFinder librariesClassFinder; private volatile String raName; public ConnectorClassFinder(ClassLoader parent, String raName, DelegatingClassLoader.ClassFinder finder) { - super(parent); + super("Connector(" + raName + ')', parent); this.raName = raName; // There should be better approach to skip libraries Classloader when none specified. diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorClassLoader.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorClassLoader.java index dd510a96f73..47f4ab729aa 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorClassLoader.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -42,6 +42,10 @@ */ public class ConnectorClassLoader extends ASURLClassLoader { + static { + registerAsParallelCapable(); + } + private static final Logger _logger = LogDomains.getLogger(ConnectorClassLoader.class, LogDomains.RSR_LOGGER); private volatile static ConnectorClassLoader classLoader; @@ -73,10 +77,11 @@ public static synchronized ConnectorClassLoader getInstance() { } private ConnectorClassLoader() { + super("Connector", ClassLoader.getSystemClassLoader()); } private ConnectorClassLoader(ClassLoader parent) { - super(parent); + super("Connector", parent); this.parent = parent; } @@ -111,7 +116,7 @@ public void addResourceAdapter(String rarName, String moduleDir) { try { File file = new File(moduleDir); - PrivilegedAction action = () -> new ASURLClassLoader(parent); + PrivilegedAction action = () -> new ASURLClassLoader("ResourceAdapter(" + rarName + ")", parent); ASURLClassLoader cl = AccessController.doPrivileged(action); cl.appendURL(file.toURI().toURL()); diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorRARClassLoader.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorRARClassLoader.java index 9cff65dadd6..97d03e633e4 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorRARClassLoader.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/ConnectorRARClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -30,10 +30,15 @@ * @author Sivakumar Thyagarajan */ public class ConnectorRARClassLoader extends SecureClassLoader{ - private JarResourceExtractor jarResources; + + static { + registerAsParallelCapable(); + } + + private final JarResourceExtractor jarResources; public ConnectorRARClassLoader(String jarName, ClassLoader parent) { - super(parent); + super(jarName, parent); // Create the JarResource and suck in the .jar file. jarResources = new JarResourceExtractor(jarName); } diff --git a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java index 619c0d91d2a..6501ad8ad00 100644 --- a/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java +++ b/appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/connectors/util/RARUtils.java @@ -168,15 +168,14 @@ private static ClassLoader getClassLoader(String file) throws ConnectorRuntimeEx File f = new File(file); validateRARLocation(f); try { - ClassLoader commonClassLoader = - ConnectorRuntime.getRuntime().getClassLoaderHierarchy().getCommonClassLoader(); + ClassLoader commonCL = ConnectorRuntime.getRuntime().getClassLoaderHierarchy().getCommonClassLoader(); if (f.isDirectory()) { List urls = new ArrayList<>(); urls.add(f.toURI().toURL()); appendURLs(urls, f); - return new GlassfishUrlClassLoader(urls.toArray(URL[]::new), commonClassLoader); + return new GlassfishUrlClassLoader("ResourceAdapterDir(" + f.getName() + ")", urls.toArray(URL[]::new), commonCL); } - return new ConnectorRARClassLoader(file, commonClassLoader); + return new ConnectorRARClassLoader(file, commonCL); } catch (IOException ioe) { throw new ConnectorRuntimeException("unable to read connector descriptor from " + file, ioe); } diff --git a/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarClassLoader.java b/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarClassLoader.java index 0b3041aa2b4..3659bfeb781 100644 --- a/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarClassLoader.java +++ b/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -32,11 +32,15 @@ */ public class EarClassLoader extends ASURLClassLoader { + static { + registerAsParallelCapable(); + } + private List moduleClassLoaders = new LinkedList<>(); - boolean isPreDestroyCalled = false; + boolean isPreDestroyCalled; public EarClassLoader(ClassLoader classLoader) { - super(classLoader); + super("Ear", classLoader); } public void addModuleClassLoader(String moduleName, ClassLoader cl) { @@ -114,9 +118,4 @@ private ClassLoaderHolder(String moduleName, ClassLoader loader) { this.moduleName = moduleName; } } - - @Override - protected String getClassLoaderName() { - return "EarClassLoader"; - } } diff --git a/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarLibClassLoader.java b/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarLibClassLoader.java index 9a192ebef63..7835d2b254c 100644 --- a/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarLibClassLoader.java +++ b/appserver/deployment/jakartaee-full/src/main/java/org/glassfish/javaee/full/deployment/EarLibClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation. + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -26,16 +26,15 @@ */ public class EarLibClassLoader extends ASURLClassLoader { + static { + registerAsParallelCapable(); + } + public EarLibClassLoader(URL[] urls, ClassLoader classLoader) { - super(classLoader); + super("EarLib", classLoader); for (URL url : urls) { addURL(url); } } - - @Override - protected String getClassLoaderName() { - return "EarLibClassLoader"; - } } diff --git a/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.java b/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.java index 1365a43ae98..9c1cdf084b6 100644 --- a/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.java +++ b/appserver/ejb/ejb-container/src/main/java/org/glassfish/ejb/deployment/EjbJarHandler.java @@ -101,7 +101,7 @@ public String getVersionIdentifier(ReadableArchive archive) { @Override public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) { - PrivilegedAction action = () -> new ASURLClassLoader(parent); + PrivilegedAction action = () -> new ASURLClassLoader("EjbJarHandler", parent); ASURLClassLoader cloader = AccessController.doPrivileged(action); try { diff --git a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java index 3c0861cf543..f58852feb8f 100644 --- a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java +++ b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java @@ -92,9 +92,8 @@ default Level getNonCriticalClassloadingErrorLogLevel() { * * @return Iterable over all ServletContainerInitializers that were found */ - public static ServiceLoader getServletContainerInitializers( - Map webFragmentMap, List absoluteOrderingList, - boolean hasOthers, ClassLoader cl) { + public static ServiceLoader getServletContainerInitializers(String containerName, + Map webFragmentMap, List absoluteOrderingList, boolean hasOthers, ClassLoader cl) { /* * If there is an absoluteOrderingList specified, then make sure that * any ServletContainerInitializers included in fragment JARs @@ -139,7 +138,8 @@ public static ServiceLoader getServletContainerInit // Create temporary classloader for ServiceLoader#load // TODO: Have temporary classloader honor delegate flag from sun-web.xml final URL[] urlArray = newClassLoaderUrlList.toArray(URL[]::new); - PrivilegedAction action = () -> new GlassfishUrlClassLoader(urlArray, webAppCl.getParent()); + PrivilegedAction action = () -> new GlassfishUrlClassLoader( + "ServletContainerInitializer(" + containerName + ")", urlArray, webAppCl.getParent()); cl = AccessController.doPrivileged(action); } diff --git a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java index a6d2c9bf685..e332c27fb1b 100644 --- a/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java +++ b/appserver/web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java @@ -268,7 +268,8 @@ public final class WebappClassLoader extends GlassfishUrlClassLoader * but no defined repositories. */ public WebappClassLoader(ClassLoader parent) { - super(new URL[0], parent); + // We overload getName(), however we don't know the name at this moment. + super("WebappClassLoader", new URL[0], parent); this.cleaner = new ReferenceCleaner(this); this.system = WebappClassLoader.class.getClassLoader(); if (SECURITY_MANAGER != null) { @@ -1125,7 +1126,7 @@ public void reload() { public ClassLoader copy() { LOG.log(DEBUG, "copy()"); // set getParent() as the parent of the cloned class loader - PrivilegedAction action = () -> new GlassfishUrlClassLoader(getURLs(), getParent()); + PrivilegedAction action = () -> new GlassfishUrlClassLoader(getName(), getURLs(), getParent()); return AccessController.doPrivileged(action); } @@ -1190,6 +1191,7 @@ public String toString() { } + @Override public void preDestroy() { LOG.log(TRACE, "preDestroy()"); try { diff --git a/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java b/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java index 1a53a9c5ce4..57a52adbccc 100644 --- a/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java +++ b/appserver/web/war-util/src/test/java/org/glassfish/web/loader/WebappClassLoaderTest.java @@ -66,7 +66,7 @@ static void removeRepositories() throws Exception { public void isParallel() { assertAll( () -> assertTrue(new URLClassLoader(new URL[0]).isRegisteredAsParallelCapable()), - () -> assertTrue(new GlassfishUrlClassLoader(new URL[0]).isRegisteredAsParallelCapable()), + () -> assertTrue(new GlassfishUrlClassLoader("WebappClassLoaderTest", new URL[0]).isRegisteredAsParallelCapable()), () -> assertTrue(new WebappClassLoader(null).isRegisteredAsParallelCapable()) ); } diff --git a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java index 0dbc1a809a2..e1076804c71 100644 --- a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java +++ b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/WebModule.java @@ -531,8 +531,8 @@ public synchronized void start() throws LifecycleException { webFragmentMap = webBundleDescriptor.getJarNameToWebFragmentNameMap(); } - setServletContainerInitializerInterestList( - getServletContainerInitializers(webFragmentMap, orderingList, hasOthers, webModuleConfig.getAppClassLoader())); + setServletContainerInitializerInterestList(getServletContainerInitializers(getName(), webFragmentMap, + orderingList, hasOthers, webModuleConfig.getAppClassLoader())); DeploymentContext deploymentContext = getWebModuleConfig().getDeploymentContext(); if (deploymentContext != null) { diff --git a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java index 6963e67c795..be78efdcce3 100644 --- a/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java +++ b/appserver/web/weld-integration/src/main/java/org/glassfish/weld/BeanDeploymentArchiveImpl.java @@ -616,9 +616,9 @@ private void handleEntry(ReadableArchive archive, String entry, boolean isBeanAr try { // use a throwaway classloader to load the application's beans.xml final URL beansXmlUrl; - try (GlassfishUrlClassLoader throwAwayClassLoader = new GlassfishUrlClassLoader( + try (GlassfishUrlClassLoader classloader = new GlassfishUrlClassLoader("BeanXml", new URL[] {archive.getURI().toURL()}, null)) { - beansXmlUrl = throwAwayClassLoader.getResource(entry); + beansXmlUrl = classloader.getResource(entry); } if (beansXmlUrl != null && !beansXmlURLs.contains(beansXmlUrl)) { beansXmlURLs.add(beansXmlUrl); diff --git a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java index 42b3e415d01..3591a682c72 100644 --- a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java +++ b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/WebServicesDeployer.java @@ -147,10 +147,10 @@ public boolean prepare(DeploymentContext dc) { } BundleDescriptor bundle = DOLUtils.getCurrentBundleForContext(dc); - String moduleCP = getModuleClassPath(dc); + final String moduleCP = getModuleClassPath(dc); final List moduleCPUrls = ASClassLoaderUtil.getURLsFromClasspath(moduleCP, File.pathSeparator, null); final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); - PrivilegedAction action = () -> new GlassfishUrlClassLoader( + PrivilegedAction action = () -> new GlassfishUrlClassLoader("WebServicesDeployer(" + app.getName() + ")", ASClassLoaderUtil.convertURLListToArray(moduleCPUrls), oldCl); URLClassLoader newCl = AccessController.doPrivileged(action); diff --git a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java index 10511928890..9c16b5d436c 100644 --- a/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java +++ b/appserver/webservices/jsr109-impl/src/main/java/org/glassfish/webservices/monitoring/WebServiceTesterServlet.java @@ -63,6 +63,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static org.glassfish.common.util.HttpParser.getCharsetFromHeader; + /** * This servlet is responsible for testing web-services. * @@ -525,7 +526,8 @@ private void initializePort(HttpServletRequest req,HttpServletResponse res) // classes clashes. // the immediate classloader is the WebApp classloader, its parent is the // application classloader, we want the parent of that one - try (GlassfishUrlClassLoader testerCL = new GlassfishUrlClassLoader(urls, currentLoader.getParent())) { + try (GlassfishUrlClassLoader testerCL = new GlassfishUrlClassLoader("SoapWsTester(" + serviceName + ")", urls, + currentLoader.getParent())) { Thread.currentThread().setContextClassLoader(testerCL); String serviceClassName = getServiceClass( JAXBRIContext.mangleNameToClassName(serviceName.getLocalPart()), diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java index 6c6df0ff18f..273f2183be2 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java @@ -61,7 +61,7 @@ * * @author martinmares */ -public final class CLIContainer { +final class CLIContainer { private static final InjectionManager injectionMgr = new InjectionManager(); @@ -75,7 +75,7 @@ public final class CLIContainer { private Map cliCommandsNames; - public CLIContainer(final ClassLoader classLoader, final Set extensions, final Logger logger) { + CLIContainer(final ClassLoader classLoader, final Set extensions, final Logger logger) { this.classLoader = classLoader; this.extensions = extensions; this.logger = logger; @@ -91,7 +91,7 @@ private Object createInstance(String name) throws ReflectiveOperationException { if (name == null) { return null; } - Class clazz = Class.forName(name); + Class clazz = classLoader.loadClass(name); if (clazz.getAnnotation(PerLookup.class) == null) { //Other scopes => HK2 return null; @@ -124,7 +124,7 @@ private Set expandExtensions() throws IOException { File inst = new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY)); File adminCliJar = new File(new File(inst, "modules"), "admin-cli.jar"); if (!adminCliJar.exists()) { - throw new IOException(adminCliJar.getCanonicalPath()); + throw new IOException(adminCliJar.getAbsolutePath()); } result.add(adminCliJar); return result; diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java index 505236ad25b..077481f2cd8 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java @@ -37,6 +37,10 @@ */ public class DirectoryClassLoader extends GlassfishUrlClassLoader { + static { + registerAsParallelCapable(); + } + private static final LocalStringsImpl STRINGS = new LocalStringsImpl(DirectoryClassLoader.class); private static final int MAX_DEPTH = 5; private static final Comparator FILENAME_COMPARATOR = Comparator.comparing(Path::getFileName); @@ -56,7 +60,7 @@ public class DirectoryClassLoader extends GlassfishUrlClassLoader { * @param parent - parent has higher priority. */ public DirectoryClassLoader(final Set jarsAndDirs, final ClassLoader parent) { - super(getJars(jarsAndDirs), parent); + super("AdminCli", getJars(jarsAndDirs), parent); } @@ -68,7 +72,7 @@ public DirectoryClassLoader(final Set jarsAndDirs, final ClassLoader paren * @param parent the parent class loader */ public DirectoryClassLoader(final File dir, final ClassLoader parent) { - super(getJars(dir), parent); + super("AdminCli(" + dir.getName() + ")", getJars(dir), parent); } diff --git a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java index 671360f1192..15831b86992 100644 --- a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java +++ b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/modularity/customization/CustomizationTokensProvider.java @@ -120,7 +120,7 @@ protected void initializeLocator() { if (ext.isDirectory()) { PrivilegedAction action = () -> { try { - GlassfishUrlClassLoader classLoader = new GlassfishUrlClassLoader(getJars(ext)); + GlassfishUrlClassLoader classLoader = new GlassfishUrlClassLoader("HK2Modules", getJars(ext)); ModulesRegistry registry = new StaticModulesRegistry(classLoader); locator = registry.createServiceLocator("default"); } catch (IOException ex) { diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java index 221ecc5a044..c659f29210e 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java @@ -84,7 +84,8 @@ protected int executeCommand() throws CommandException, CommandValidationExcepti final URL[] urlsA = urls.toArray(new URL[urls.size()]); - PrivilegedAction action = () -> new GlassfishUrlClassLoader(urlsA, Globals.class.getClassLoader()); + PrivilegedAction action = () -> new GlassfishUrlClassLoader("DomainXmlVerifier", urlsA, + Globals.class.getClassLoader()); ClassLoader cl = AccessController.doPrivileged(action); ModulesRegistry registry = new StaticModulesRegistry(cl); ServiceLocator serviceLocator = registry.createServiceLocator("default"); diff --git a/nucleus/admin/template/src/main/resources/config/logging.properties b/nucleus/admin/template/src/main/resources/config/logging.properties index fbc3d7fe202..994b4210752 100644 --- a/nucleus/admin/template/src/main/resources/config/logging.properties +++ b/nucleus/admin/template/src/main/resources/config/logging.properties @@ -207,6 +207,7 @@ org.glassfish.hk2.classmodel.level=INFO org.glassfish.jersey.level=INFO org.glassfish.jersey.message.internal.TracingLogger.level=INFO org.glassfish.main.level=INFO +org.glassfish.main.jdke=INFO org.glassfish.naming.level=INFO org.glassfish.persistence.level=INFO org.glassfish.resourcebase.level=INFO diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java index 993c9ce78df..f354583c143 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/loader/ASURLClassLoader.java @@ -86,6 +86,10 @@ public class ASURLClassLoader extends GlassfishUrlClassLoader implements JasperAdapter, InstrumentableClassLoader, PreDestroy, DDPermissionsLoader { + static { + registerAsParallelCapable(); + } + /** logger for this class */ private static final Logger _logger = CULoggerInfo.getLogger(); @@ -122,24 +126,16 @@ public class ASURLClassLoader extends GlassfishUrlClassLoader //holder for declared and ee permissions private final PermsHolder permissionsHolder; - /** - * Constructor. - */ - public ASURLClassLoader() { - super(new URL[0]); - permissionsHolder = new PermsHolder(); - _logger.log(Level.FINE, "ClassLoader: {0} is getting created.", this); - } - - /** * Constructor. * + * @param name * @param parent parent class loader */ - public ASURLClassLoader(ClassLoader parent) { - super(new URL[0], parent); + public ASURLClassLoader(String name, ClassLoader parent) { + super(name, new URL[0], parent); permissionsHolder = new PermsHolder(); + _logger.log(Level.FINE, "ClassLoader: {0} is getting created.", this); } @@ -791,18 +787,13 @@ private byte[] getClassData(InputStream istream) throws IOException { } - protected String getClassLoaderName() { - return "ASURLClassLoader"; - } - - /** * Returns a string representation of this class loader */ @Override public String toString() { StringBuilder buffer = new StringBuilder(); - buffer.append(getClassLoaderName()).append(" :\n"); + buffer.append(getName()).append(" :\n"); if (doneCalled) { buffer.append("doneCalled = true").append('\n'); buffer.append("doneSnapshot = ").append(doneSnapshot); diff --git a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/DelegatingClassLoader.java b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/DelegatingClassLoader.java index 2b0de80a8ac..0e050a20ca6 100644 --- a/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/DelegatingClassLoader.java +++ b/nucleus/common/internal-api/src/main/java/org/glassfish/internal/api/DelegatingClassLoader.java @@ -45,6 +45,10 @@ */ public class DelegatingClassLoader extends ClassLoader { + static { + registerAsParallelCapable(); + } + /** * This interface is an optimization. *

@@ -215,6 +219,7 @@ protected Enumeration findResources(String name) throws IOException { return new CompositeEnumeration(enumerators); } + @Override public String getName() { return name; } diff --git a/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/GlassFishRuntime.java b/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/GlassFishRuntime.java index 3ceca71df50..a418c7a52e9 100644 --- a/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/GlassFishRuntime.java +++ b/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/GlassFishRuntime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,7 +17,6 @@ package org.glassfish.embeddable; -import java.util.Iterator; import java.util.ServiceConfigurationError; import java.util.ServiceLoader; import java.util.logging.Level; @@ -130,7 +129,7 @@ private synchronized static GlassFishRuntime _bootstrap(BootstrapProperties boot } ClassLoader classLoader = cl == null ? GlassFishRuntime.class.getClassLoader() : cl; RuntimeBuilder runtimeBuilder = getRuntimeBuilder(bootstrapProperties, classLoader); - me = runtimeBuilder.build(bootstrapProperties); + me = runtimeBuilder.build(bootstrapProperties, classLoader); return me; } @@ -146,10 +145,8 @@ protected synchronized static void shutdownInternal() throws GlassFishException private static RuntimeBuilder getRuntimeBuilder(BootstrapProperties bootstrapProperties, ClassLoader classLoader) throws GlassFishException { logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "classloader={0}", classLoader); - Iterator runtimeBuilders = ServiceLoader.load(RuntimeBuilder.class, classLoader).iterator(); - while (runtimeBuilders.hasNext()) { + for (RuntimeBuilder builder : ServiceLoader.load(RuntimeBuilder.class, classLoader)) { try { - RuntimeBuilder builder = runtimeBuilders.next(); logger.logp(Level.FINE, "GlassFishRuntime", "getRuntimeBuilder", "builder = {0}", builder); if (builder.handles(bootstrapProperties)) { return builder; diff --git a/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/spi/RuntimeBuilder.java b/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/spi/RuntimeBuilder.java index 41386c97726..9604e67f4c1 100644 --- a/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/spi/RuntimeBuilder.java +++ b/nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/spi/RuntimeBuilder.java @@ -36,7 +36,13 @@ public interface RuntimeBuilder { * @return * @throws GlassFishException */ - GlassFishRuntime build(BootstrapProperties options) throws GlassFishException; + default GlassFishRuntime build(BootstrapProperties options) throws GlassFishException { + return build(options, getClass().getClassLoader()); + } + + + GlassFishRuntime build(BootstrapProperties options, ClassLoader classloader) throws GlassFishException; + /** * Returns true if this RuntimeBuilder is capable of creating a GlassFishRuntime diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java index 67ab9fd7ce1..140c7cd5d25 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/AppLibClassLoaderServiceImpl.java @@ -219,12 +219,16 @@ private void addDelegates(Collection libURIs, DelegatingClassLoader holder) */ private static class URLClassFinder extends GlassfishUrlClassLoader implements ClassFinder { + static { + registerAsParallelCapable(); + } + private static final URLStreamHandler urlStreamHandler = new NonCachingURLStreamHandler(); private final Set notFoundResources = ConcurrentHashMap.newKeySet(); URLClassFinder(URL url, ClassLoader parent) { - super(new URL[] {url}, parent); + super("AppLib(" + url.getFile() + ")", new URL[] {url}, parent); } /** @@ -353,6 +357,10 @@ public void setUseCaches(boolean useCaches) { */ private static class DelegatingClassFinder extends DelegatingClassLoader implements ClassFinder { + static { + registerAsParallelCapable(); + } + DelegatingClassFinder(ClassLoader parent) { super(parent); } 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 e25856033d3..009a64fa7b8 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 @@ -129,9 +129,7 @@ private void createCommonClassLoader() { LOG.logp(Level.FINE, "CommonClassLoaderManager", "Skipping creation of CommonClassLoader as there are no libraries available", "urls = {0}", urls); } else { - // Skip creation of an unnecessary classloader in the hierarchy, - // when all it would have done was to delegate up. - commonClassLoader = new GlassfishUrlClassLoader(urls.toArray(URL[]::new), apiClassLoader); + commonClassLoader = new GlassfishUrlClassLoader("CommonLibs", urls.toArray(URL[]::new), apiClassLoader); LOG.log(Level.FINE, "Created common classloader: {0}", commonClassLoader); } } @@ -147,7 +145,7 @@ public ClassLoader getCommonClassLoader() { */ public void addToClassPath(URL url) { if (commonClassLoader == null) { - commonClassLoader = new GlassfishUrlClassLoader(new URL[] {url}, apiClassLoader); + commonClassLoader = new GlassfishUrlClassLoader("CommonLibs", new URL[] {url}, apiClassLoader); } else { commonClassLoader.addURL(url); } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java index a9ec100d521..47ff261299b 100755 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/server/ServerLifecycleModule.java @@ -114,7 +114,7 @@ LifecycleListener loadServerLifecycle() throws ServerLifecycleException { } else { URL[] urls = getURLs(); _logger.log(Level.FINE, "Lifecycle module = {0} has classpath URLs = {1}", new Object[] { getName(), urls }); - this.urlClassLoader = new GlassfishUrlClassLoader(urls, ctx.getLifecycleParentClassLoader()); + this.urlClassLoader = new GlassfishUrlClassLoader(getName(), urls, ctx.getLifecycleParentClassLoader()); classLoader = this.urlClassLoader; } @SuppressWarnings("unchecked") diff --git a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java index a14fd6595a1..0d931e53057 100644 --- a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java +++ b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LoggerInfoMetadataService.java @@ -182,7 +182,8 @@ private void initialize() { urls[i] = uris[i].toURL(); } ResourceBundle rb; - try (GlassfishUrlClassLoader loader = new GlassfishUrlClassLoader(urls, new NullClassLoader())) { + try (GlassfishUrlClassLoader loader = new GlassfishUrlClassLoader("LoggerInfoMetadata", urls, + new NullClassLoader())) { rb = ResourceBundle.getBundle(RBNAME, locale, loader); } for (String key : rb.keySet()) { From 8de2e0ec8338ef0f77c577b8538c39396fda5395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 00:11:28 +0200 Subject: [PATCH 12/38] Add missing JVM options when doing migration of older domain.xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../enterprise/admin/launcher/JvmOptions.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/JvmOptions.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/JvmOptions.java index 479b4b1a4bc..a4827ff8d7d 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/JvmOptions.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/JvmOptions.java @@ -29,6 +29,9 @@ import java.util.regex.Pattern; import static com.sun.enterprise.util.StringUtils.ok; +import static org.glassfish.main.jul.cfg.GlassFishLoggingConstants.CLASS_LOG_MANAGER_GLASSFISH; +import static org.glassfish.main.jul.cfg.GlassFishLoggingConstants.JVM_OPT_LOGGING_CFG_BLOCK; +import static org.glassfish.main.jul.cfg.GlassFishLoggingConstants.JVM_OPT_LOGGING_MANAGER; /** * @@ -68,6 +71,7 @@ class JvmOptions { } filter(); + addMissing(); setOsgiPort(); } @@ -259,6 +263,21 @@ private void filter() { } } + + /** + * Add missing options which were not set in the domain.xml - usually if user copy pasted + * domain.xml from an older version. + */ + private void addMissing() { + if (sysProps.get(JVM_OPT_LOGGING_MANAGER) == null) { + sysProps.put(JVM_OPT_LOGGING_MANAGER, CLASS_LOG_MANAGER_GLASSFISH); + } + if (sysProps.get(JVM_OPT_LOGGING_CFG_BLOCK) == null + && sysProps.get(JVM_OPT_LOGGING_MANAGER).equals(CLASS_LOG_MANAGER_GLASSFISH)) { + sysProps.put(JVM_OPT_LOGGING_CFG_BLOCK, "true"); + } + } + private void setOsgiPort() { String s = sysProps.get("osgi.shell.telnet.port"); From c8654399bb3a066e0b4889c9a904fc2b44cf9b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 00:13:36 +0200 Subject: [PATCH 13/38] Updated osgi.properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - When I remove the jar file from any of those two lines, GF cannot start. Signed-off-by: David Matějček --- .../nucleus-common/src/main/resources/config/osgi.properties | 3 ++- .../felix/src/main/resources/config/osgi.properties | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties b/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties index 0cb1c791cdc..bd5744cacc4 100755 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties @@ -100,6 +100,7 @@ com.sun.enterprise.hk2.cacheDir=${org.osgi.framework.storage} # Then we autostart GlassFish core bundles followed by optional services. # The reason for using installRootURI is to make sure any char like white space is properly encoded. glassfish.osgi.auto.install=\ + ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar \ ${com.sun.aas.installRootURI}modules/osgi-resource-locator.jar \ ${com.sun.aas.installRootURI}modules/ \ ${com.sun.aas.installRootURI}modules/autostart/ @@ -130,7 +131,7 @@ hk2.bundles=\ core.bundles=\ ${hk2.bundles} \ - ${com.sun.aas.installRootURI}modules/glassfish.jar + ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar autostart.bundles=${com.sun.aas.installRootURI}modules/autostart/ diff --git a/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties b/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties index 0cb1c791cdc..bd5744cacc4 100755 --- a/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties +++ b/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties @@ -100,6 +100,7 @@ com.sun.enterprise.hk2.cacheDir=${org.osgi.framework.storage} # Then we autostart GlassFish core bundles followed by optional services. # The reason for using installRootURI is to make sure any char like white space is properly encoded. glassfish.osgi.auto.install=\ + ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar \ ${com.sun.aas.installRootURI}modules/osgi-resource-locator.jar \ ${com.sun.aas.installRootURI}modules/ \ ${com.sun.aas.installRootURI}modules/autostart/ @@ -130,7 +131,7 @@ hk2.bundles=\ core.bundles=\ ${hk2.bundles} \ - ${com.sun.aas.installRootURI}modules/glassfish.jar + ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar autostart.bundles=${com.sun.aas.installRootURI}modules/autostart/ From 954e436eb54ace984374b30c9eb224d3214aeecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 00:34:08 +0200 Subject: [PATCH 14/38] Updated GlassFishMainLauncher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - just 4 jars to start GlassFish are required: - glassfish.jar contains non-osgi GlassFishMain class and Launcher interface - glassfish-jul-extensions.jar for logging in every phase with same set of available features. - glassfish-jdk-extensions - basic tools used on all layers: i18n class, classloader, we will migrate more in the future. - simple-glassfish-api.jar - basic GF apis, no other dependencies. Signed-off-by: David Matějček --- .../admin/launcher/GlassFishMainLauncher.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) 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 8c826b2cbbc..4789bfa4bd4 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 @@ -20,8 +20,11 @@ import com.sun.enterprise.universal.io.SmartFile; import java.io.File; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; @@ -34,7 +37,6 @@ class GlassFishMainLauncher extends GFLauncher { private static final String MAIN_CLASS = "com.sun.enterprise.glassfish.bootstrap.GlassFishMain"; - private static final String BOOTSTRAP_JAR = "glassfish.jar"; // sample profiler config // @@ -62,17 +64,24 @@ void internalLaunch() throws GFLauncherException { @Override List getMainClasspath() throws GFLauncherException { - File dir = new File(getEnvProps().get(INSTALL_ROOT_PROPERTY), "modules"); - File bootjar = new File(dir, BOOTSTRAP_JAR); - if (!bootjar.exists() && !isFakeLaunch()) { - throw new GFLauncherException("nobootjar", dir.getPath()); + Path dir = Path.of(getEnvProps().get(INSTALL_ROOT_PROPERTY), "lib", "bootstrap"); + List classpath = Stream + .of("glassfish.jar", "glassfish-jul-extension.jar", "glassfish-jdk-extensions.jar", + "simple-glassfish-api.jar") + .map(dir::resolve).map(Path::toFile).map(SmartFile::sanitize).collect(Collectors.toList()); + if (isFakeLaunch()) { + return classpath; } - - List list = new ArrayList<>(); - if (bootjar.exists()) { - list.add(SmartFile.sanitize(bootjar)); + List missing = new ArrayList<>(classpath.size()); + for (File file : classpath) { + if (!file.exists()) { + missing.add(file); + } + } + if (missing.isEmpty()) { + return classpath; } - return list; + throw new GFLauncherException("nobootjar", missing); } @Override From ea2da7f7eb3ad82f4876bd84eb3e840a2976e749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 00:37:20 +0200 Subject: [PATCH 15/38] Updated scripts to use GJULE (is always on classpath) --- .../glassfish-common/src/main/resources/bin/asadmin | 8 ++++---- .../glassfish-common/src/main/resources/bin/asadmin.bat | 5 ++--- .../glassfish-common/src/main/resources/bin/debug-asadmin | 4 ++-- .../src/main/resources/bin/debug-asadmin.bat | 5 ++--- .../glassfish-common/src/main/resources/bin/startserv | 8 ++++---- .../glassfish-common/src/main/resources/bin/startserv.bat | 3 ++- .../glassfish-common/src/main/resources/bin/stopserv | 3 ++- .../glassfish-common/src/main/resources/bin/stopserv.bat | 3 ++- .../src/main/resources/glassfish/bin/asadmin | 8 +++++--- .../src/main/resources/glassfish/bin/asadmin.bat | 5 ++--- .../nucleus-common/src/main/resources/bin/nadmin | 6 +++--- .../nucleus-common/src/main/resources/bin/nadmin.bat | 7 ++----- .../nucleus-common/src/main/resources/bin/startserv | 6 +++--- .../nucleus-common/src/main/resources/bin/startserv.bat | 3 ++- .../nucleus-common/src/main/resources/bin/stopserv | 3 ++- .../nucleus-common/src/main/resources/bin/stopserv.bat | 3 ++- 16 files changed, 41 insertions(+), 39 deletions(-) diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin index 6aefb78d505..8f7f88bbe26 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation # Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -19,13 +20,12 @@ AS_INSTALL=`dirname "$0"`/../glassfish case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac -AS_INSTALL_LIB="$AS_INSTALL/lib" . "${AS_INSTALL}/config/asenv.conf" JAVA=java -#Depends upon Java from ../config/asenv.conf +#Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi +AS_CLIENT="$AS_INSTALL/lib/client" -exec "$JAVA" -jar "$AS_INSTALL_LIB/client/appserver-cli.jar" "$@" - +exec "$JAVA" "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_CLIENT/appserver-cli.jar" "$@" 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 49a8e4e2149..5eb640e0a94 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat @@ -1,5 +1,6 @@ @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 @@ -16,8 +17,6 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM -REM Always use JDK 1.6 or higher -REM Depends on Java from ..\glassfish\config\asenv.bat VERIFY OTHER 2>nul setlocal ENABLEEXTENSIONS if ERRORLEVEL 0 goto ok @@ -31,4 +30,4 @@ goto run :UsePath set JAVA=java :run -%JAVA% -jar "%~dp0..\glassfish\lib\client\appserver-cli.jar" %* +%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\glassfish\lib\client\appserver-cli.jar" %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin index 6af531803fa..8f9fc3c7e52 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -15,7 +16,6 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -# Always use JDK 1.6 or higher AS_INSTALL=`dirname "$0"`/../glassfish AS_INSTALL_LIB="$AS_INSTALL/lib" . "${AS_INSTALL}/config/asenv.conf" @@ -25,5 +25,5 @@ if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 -jar "$AS_INSTALL_LIB/client/appserver-cli.jar" "$@" +exec "$JAVA" "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 -jar "$AS_INSTALL_LIB/client/appserver-cli.jar" "$@" 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 965e548d37c..619fa9b04cb 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 @@ -1,5 +1,6 @@ @echo off REM +REM Copyright (c) 2024 Contributors to the Eclipse Foundation REM Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. REM REM This program and the accompanying materials are made available under the @@ -16,8 +17,6 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM -REM Always use JDK 1.6 or higher -REM Depends on Java from ..\glassfish\config\asenv.bat VERIFY OTHER 2>nul setlocal ENABLEEXTENSIONS if ERRORLEVEL 0 goto ok @@ -31,4 +30,4 @@ goto run :UsePath set JAVA=java :run -%JAVA% -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 -jar "%~dp0..\glassfish\lib\client\appserver-cli.jar" %* +%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 -jar "%~dp0..\glassfish\lib\client\appserver-cli.jar" %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv index 493bb63ee77..dc28eb2beb5 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2023,2024 Contributors to the Eclipse Foundation +# Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -30,7 +30,7 @@ fi start_as_main_process () { if [[ "$@" == "--help" ]] || [[ "$@" == "--help=true" ]] || [[ "$@" == "-?" ]]; then - exec java -jar "$ASADMIN_JAR" start-domain --help + exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --help fi # Execute start-domain --dry-run and store the output line by line into an array. @@ -50,7 +50,7 @@ start_as_main_process () { else DRY_RUN_OUTPUT+=("$COM"); fi - done < <(java -jar "$ASADMIN_JAR" start-domain --dry-run "$@" || echo "FAILED" ) + done < <(java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --dry-run "$@" || echo "FAILED" ) if [[ x"$DRY_RUN_OUTPUT" == x ]] then echo -n -e "${DRY_RUN_OUTPUT_BEFORE_DUMP}" >&2 @@ -69,4 +69,4 @@ ASADMIN_JAR="$AS_INSTALL_LIB/admin-cli.jar" start_as_main_process "$@" # Alternatively, run the following: -# exec "$JAVA" -jar "$ASADMIN_JAR" start-domain --verbose "$@" \ No newline at end of file +# exec "$JAVA" -jar "$ASADMIN_JAR" start-domain --verbose "$@" 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 60829dac652..eb0b1198f6d 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat @@ -1,5 +1,6 @@ @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 @@ -16,4 +17,4 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM -java -jar "%~dp0..\glassfish\modules\admin-cli.jar" start-domain --verbose %* +java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\glassfish\modules\admin-cli.jar" 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 6fe959af7bb..bf6b38f7d09 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -18,4 +19,4 @@ AS_INSTALL=`dirname "$0"`/../glassfish AS_INSTALL_LIB="$AS_INSTALL/modules" -exec java -jar "$AS_INSTALL_LIB/admin-cli.jar" stop-domain "$@" +exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_INSTALL_LIB/admin-cli.jar" 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 575474fa500..0f7fb7bd7ea 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv.bat @@ -1,5 +1,6 @@ @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 @@ -16,4 +17,4 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM -java -jar "%~dp0..\glassfish\modules\admin-cli.jar" stop-domain %* +java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\glassfish\modules\admin-cli.jar" stop-domain %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin index 43cb5d22dc3..ecafdba4123 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -19,11 +20,12 @@ AS_INSTALL=`dirname "$0"`/.. case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac -AS_INSTALL_LIB="$AS_INSTALL/lib" . "${AS_INSTALL}/config/asenv.conf" JAVA=java -#Depends upon Java from ../config/asenv.conf +#Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" -jar "$AS_INSTALL_LIB/client/appserver-cli.jar" "$@" +AS_CLIENT=$AS_INSTALL/lib/client + +exec "$JAVA" "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_CLIENT/appserver-cli.jar" "$@" 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 ea6f018fa97..8f33452d7b8 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,5 +1,6 @@ @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 @@ -16,8 +17,6 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM -REM Always use JDK 1.6 or higher -REM Depends on Java from ..\config\asenv.bat VERIFY OTHER 2>nul setlocal ENABLEEXTENSIONS if ERRORLEVEL 0 goto ok @@ -31,4 +30,4 @@ goto run :UsePath set JAVA=java :run -%JAVA% -jar "%~dp0..\lib\client\appserver-cli.jar" %* +%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\lib\client\appserver-cli.jar" %* diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin index 6df8760eeed..9cfd62ed4c4 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -19,11 +20,10 @@ AS_INSTALL=`dirname "$0"`/.. case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac -AS_INSTALL_LIB="$AS_INSTALL/modules" . "${AS_INSTALL}/config/asenv.conf" JAVA=java -#Depends upon Java from ../config/asenv.conf +#Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" -jar "$AS_INSTALL_LIB/admin-cli.jar" "$@" +exec "$JAVA" -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager -jar "$AS_INSTALL/modules/admin-cli.jar" "$@" 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 f0a95a21c8c..1e628a33f68 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat @@ -1,5 +1,6 @@ @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 @@ -14,10 +15,6 @@ 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 - - -REM Always use JDK 1.6 or higher -REM Depends on Java from ..\config\asenv.bat VERIFY OTHER 2>nul setlocal ENABLEEXTENSIONS if ERRORLEVEL 0 goto ok @@ -31,4 +28,4 @@ goto run :UsePath set JAVA=java :run -%JAVA% -jar "%~dp0..\modules\admin-cli.jar" %* +%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%AS_INSTALL%\modules\admin-cli.jar" %* diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv index 3537bf557b7..b729e5ba6a9 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv @@ -30,7 +30,7 @@ fi start_as_main_process () { if [[ "$@" == "--help" ]] || [[ "$@" == "--help=true" ]] || [[ "$@" == "-?" ]]; then - exec java -jar "$ASADMIN_JAR" start-domain --help + exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --help fi # Execute start-domain --dry-run and store the output line by line into an array. @@ -50,7 +50,7 @@ start_as_main_process () { else DRY_RUN_OUTPUT+=("$COM"); fi - done < <(java -jar "$ASADMIN_JAR" start-domain --dry-run "$@" || echo "FAILED" ) + done < <(java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --dry-run "$@" || echo "FAILED" ) if [[ x"$DRY_RUN_OUTPUT" == x ]] then echo -n -e "${DRY_RUN_OUTPUT_BEFORE_DUMP}" >&2 @@ -69,4 +69,4 @@ ASADMIN_JAR="$AS_INSTALL_LIB/admin-cli.jar" start_as_main_process "$@" # Alternatively, run the following: -# exec "$JAVA" -jar "$ASADMIN_JAR" start-domain --verbose "$@" \ No newline at end of file +# exec "$JAVA" -jar "$ASADMIN_JAR" start-domain --verbose "$@" 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 57196df6fa3..c83f7ce9b01 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat @@ -1,5 +1,6 @@ @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 @@ -16,4 +17,4 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM -java -jar "%~dp0..\modules\admin-cli.jar" start-domain --verbose %* +java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\modules\admin-cli.jar" start-domain --verbose %* diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv index 47d70c90945..d6b9421a3ee 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -18,4 +19,4 @@ AS_INSTALL=`dirname "$0"`/.. AS_INSTALL_LIB="$AS_INSTALL/modules" -exec java -jar "$AS_INSTALL_LIB/admin-cli.jar" stop-domain "$@" +exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_INSTALL_LIB/admin-cli.jar" stop-domain "$@" diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat index aca534159c8..7a506976488 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat @@ -1,5 +1,6 @@ @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 @@ -16,4 +17,4 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM -java -jar "%~dp0..\modules\admin-cli.jar" stop-domain %* +java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\modules\admin-cli.jar" stop-domain %* From 1ec6c2aba5000a14e0b8f32e7e1aa2299cac1173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 00:38:21 +0200 Subject: [PATCH 16/38] Reproducer test for the issue when GC logging disabled glassfish logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../admin/test/GJULEvsJDKLogManagerIT.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/GJULEvsJDKLogManagerIT.java diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/GJULEvsJDKLogManagerIT.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/GJULEvsJDKLogManagerIT.java new file mode 100644 index 00000000000..5ac0e8c6039 --- /dev/null +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/GJULEvsJDKLogManagerIT.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.main.admin.test; + +import java.nio.file.Path; + +import org.glassfish.main.itest.tools.GlassFishTestEnvironment; +import org.glassfish.main.itest.tools.asadmin.Asadmin; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.glassfish.main.itest.tools.asadmin.AsadminResultMatcher.asadminOK; +import static org.hamcrest.MatcherAssert.assertThat; + +public class GJULEvsJDKLogManagerIT { + + private static final Asadmin ASADMIN = GlassFishTestEnvironment.getAsadmin(false); + private static final Path LOGDIR = GlassFishTestEnvironment.getDomain1Directory().resolve("logs").toAbsolutePath(); + private static final String SYSOPT_ERR_LOG = "'-XX:ErrorFile=" + LOGDIR + "/java_error%p.log'"; + private static final String SYSOPT_GC_LOG = "'-Xlog:gc*:file=" + LOGDIR + "/gc-%t.log:time:filecount=10'"; + + @BeforeAll + static void setAndBackup() { + assertThat(ASADMIN.exec(60000, "stop-domain"), asadminOK()); + assertThat(ASADMIN.exec(60000, "backup-domain"), asadminOK()); + assertThat(ASADMIN.exec(60000, "start-domain"), asadminOK()); + } + + + @Test + void testConfigureAndRestart() { + assertThat(ASADMIN.exec(10000, "create-jvm-options", SYSOPT_ERR_LOG), asadminOK()); + assertThat(ASADMIN.exec(10000, "create-jvm-options", SYSOPT_GC_LOG), asadminOK()); + assertThat(ASADMIN.exec(60000, "restart-domain"), asadminOK()); + } + + @AfterAll + static void revert() { + assertThat(ASADMIN.exec(60000, "stop-domain"), asadminOK()); + assertThat(ASADMIN.exec(60000, "restore-domain", "domain1"), asadminOK()); + assertThat(ASADMIN.exec(60000, "start-domain"), asadminOK()); + } +} From 07e2770c993d138c3a2cde70cc957aeb4216be02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 00:39:06 +0200 Subject: [PATCH 17/38] We have one logger less MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../org/glassfish/main/admin/test/AsadminLoggingITest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java index 12682968db3..f9141903b42 100644 --- a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Eclipse Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -117,7 +117,7 @@ public void listLoggers() { assertThat(result, asadminOK()); String[] lines = substringBefore(result.getStdOut(), "Command list-loggers executed successfully.").split("\n"); assertAll( - () -> assertThat(lines, arrayWithSize(equalTo(62))), + () -> assertThat(lines, arrayWithSize(equalTo(61))), () -> assertThat(lines[0], matchesPattern("Logger Name[ ]+Subsystem[ ]+Logger Description[ ]+")) ); Map loggers = Arrays.stream(lines).skip(1).map(line -> line.split("\\s{2,}")) From e81588a798373c468f52f2aba2fcddf25edde2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 10 Oct 2024 21:52:39 +0200 Subject: [PATCH 18/38] Added module-info files + resolved dependency on LogFacade of glassfish.jar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../extras/embedded/common/bootstrap/pom.xml | 2 +- .../main/admin/test/AsadminLoggingITest.java | 2 +- .../enterprise/util/FelixPrettyPrinter.java | 6 +- .../src/main/java/module-info.java | 26 +++ .../src/main/java/module-info.java | 27 +++ .../embedded/EmbeddedGlassFishRuntime.java | 2 +- .../EmbeddedGlassFishRuntimeBuilder.java | 2 +- .../embedded/EmbeddedInhabitantsParser.java | 3 +- .../glassfish/main/boot/embedded/JarUtil.java | 4 +- .../main/boot/embedded/SingleHK2Factory.java | 3 +- .../glassfish/main/boot/log/LogFacade.java | 183 +++++++++++++++++ .../main/boot/osgi/BundleProvisioner.java | 3 +- .../DefaultBundleProvisionerCustomizer.java | 3 +- .../boot/osgi/EmbeddedOSGiGlassFishImpl.java | 3 +- .../boot/osgi/MinimalBundleProvisioner.java | 3 +- .../MinimalBundleProvisionerCustomizer.java | 3 +- .../osgi/OSGiGlassFishRuntimeBuilder.java | 2 +- .../main/boot/osgi/BundleProvisionerTest.java | 18 +- .../glassfish/bootstrap/log/LogFacade.java | 191 +----------------- .../bootstrap/src/main/java/module-info.java | 31 +++ .../src/main/java/module-info.java | 2 +- 21 files changed, 295 insertions(+), 224 deletions(-) create mode 100644 nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java create mode 100644 nucleus/common/simple-glassfish-api/src/main/java/module-info.java create mode 100644 nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/log/LogFacade.java create mode 100644 nucleus/core/bootstrap/src/main/java/module-info.java diff --git a/appserver/extras/embedded/common/bootstrap/pom.xml b/appserver/extras/embedded/common/bootstrap/pom.xml index 886f463066d..4cd38362ad2 100644 --- a/appserver/extras/embedded/common/bootstrap/pom.xml +++ b/appserver/extras/embedded/common/bootstrap/pom.xml @@ -78,7 +78,7 @@ jar false ${project.build.directory}/classes - META-INF/** + META-INF/**,module-info.class org.glassfish.main.core diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java index f9141903b42..d5cb64c8fd9 100644 --- a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminLoggingITest.java @@ -117,7 +117,7 @@ public void listLoggers() { assertThat(result, asadminOK()); String[] lines = substringBefore(result.getStdOut(), "Command list-loggers executed successfully.").split("\n"); assertAll( - () -> assertThat(lines, arrayWithSize(equalTo(61))), + () -> assertThat(lines, arrayWithSize(equalTo(62))), () -> assertThat(lines[0], matchesPattern("Logger Name[ ]+Subsystem[ ]+Logger Description[ ]+")) ); Map loggers = Arrays.stream(lines).skip(1).map(line -> line.split("\\s{2,}")) diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/FelixPrettyPrinter.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/FelixPrettyPrinter.java index e388941891a..3619b998136 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/FelixPrettyPrinter.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/util/FelixPrettyPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -25,10 +25,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.osgi.framework.BundleException; - /** - * Tools for obtaining readable information from the {@link BundleException} + * Tools for obtaining readable information from the {@link org.osgi.framework.BundleException} */ public class FelixPrettyPrinter { diff --git a/nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java new file mode 100644 index 00000000000..5b202253adf --- /dev/null +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * @author David Matejcek + */ +module org.glassfish.main.jdke { + + requires java.base; + + exports org.glassfish.main.jdke.cl; + exports org.glassfish.main.jdke.i18n; +} diff --git a/nucleus/common/simple-glassfish-api/src/main/java/module-info.java b/nucleus/common/simple-glassfish-api/src/main/java/module-info.java new file mode 100644 index 00000000000..2892a81a8c6 --- /dev/null +++ b/nucleus/common/simple-glassfish-api/src/main/java/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * @author David Matejcek + */ +module org.glassfish.main.api.simple { + + requires java.base; + requires java.logging; + + exports org.glassfish.embeddable; + exports org.glassfish.embeddable.spi; +} diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntime.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntime.java index ddc5142167b..2cc08e7c267 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntime.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntime.java @@ -18,7 +18,6 @@ package org.glassfish.main.boot.embedded; import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.bootstrap.Main; import com.sun.enterprise.module.bootstrap.ModuleStartup; @@ -46,6 +45,7 @@ import org.glassfish.embeddable.GlassFishRuntime; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.utilities.DuplicatePostProcessor; +import org.glassfish.main.boot.log.LogFacade; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.AUTO_DELETE; import static java.util.logging.Level.FINER; diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntimeBuilder.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntimeBuilder.java index c86c6ae4d81..17f42159f07 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntimeBuilder.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedGlassFishRuntimeBuilder.java @@ -20,7 +20,6 @@ import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; import com.sun.enterprise.glassfish.bootstrap.cfg.ServerFiles; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.common_impl.AbstractFactory; @@ -37,6 +36,7 @@ import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishRuntime; import org.glassfish.embeddable.spi.RuntimeBuilder; +import org.glassfish.main.boot.log.LogFacade; import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; /** diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedInhabitantsParser.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedInhabitantsParser.java index 357a9a45014..405da792bc8 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedInhabitantsParser.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/EmbeddedInhabitantsParser.java @@ -17,8 +17,6 @@ package org.glassfish.main.boot.embedded; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.util.logging.Level; import java.util.logging.Logger; @@ -26,6 +24,7 @@ import org.glassfish.hk2.api.PopulatorPostProcessor; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.utilities.DescriptorImpl; +import org.glassfish.main.boot.log.LogFacade; /** * Kernel's decoration for embedded environment. diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/JarUtil.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/JarUtil.java index 08959c3e13a..0952aa639ba 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/JarUtil.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/JarUtil.java @@ -17,8 +17,6 @@ package org.glassfish.main.boot.embedded; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -29,6 +27,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.boot.log.LogFacade; + /** * Most part is copied from com.sun.appserv.connectors.internal.api.ConnectorsUtil *

diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/SingleHK2Factory.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/SingleHK2Factory.java index ec56fc1061b..11467f95490 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/SingleHK2Factory.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/embedded/SingleHK2Factory.java @@ -17,13 +17,14 @@ package org.glassfish.main.boot.embedded; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; import com.sun.enterprise.module.ModuleDefinition; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.common_impl.AbstractFactory; import com.sun.enterprise.module.common_impl.ModuleId; import com.sun.enterprise.module.single.SingleModulesRegistry; +import org.glassfish.main.boot.log.LogFacade; + /** * Factory which provides SingleModulesRegistry * This should actually be in HK2 workspace. diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/log/LogFacade.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/log/LogFacade.java new file mode 100644 index 00000000000..c462735f160 --- /dev/null +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/log/LogFacade.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation + * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.main.boot.log; + +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +import org.glassfish.logging.annotation.LogMessageInfo; +import org.glassfish.logging.annotation.LogMessagesResourceBundle; +import org.glassfish.logging.annotation.LoggerInfo; + +public class LogFacade { + + @LoggerInfo(subsystem = "BOOTSTRAP", description="Main bootstrap logger.") + public static final String BOOTSTRAP_LOGGER_NAME = "jakarta.enterprise.bootstrap"; + + @LogMessagesResourceBundle + public static final String RB_NAME = "org.glassfish.main.boot.log.LogMessages"; + + public static final Logger BOOTSTRAP_LOGGER = Logger.getLogger(BOOTSTRAP_LOGGER_NAME, RB_NAME); + + @LogMessageInfo( + message = "Can not start bundle {0} because it is not contained in the list of installed bundles.", + level = "WARNING") + public static final String CANT_START_BUNDLE = "NCLS-BOOTSTRAP-00005"; + + @LogMessageInfo( + message = "Failed to start {0}.", + level = "WARNING") + public static final String BUNDLE_START_FAILED = "NCLS-BOOTSTRAP-00006"; + + @LogMessageInfo( + message = "Can't uninstall bundle = {0} as it's already uninstalled.", + level = "WARNING") + public static final String BUNDLE_ALREADY_UNINSTALED = "NCLS-BOOTSTRAP-00007"; + + @LogMessageInfo( + message = "Uninstalled bundle {0} installed from {1}.", + level = "INFO") + public static final String UNINSTALLED_BUNDLE = "NCLS-BOOTSTRAP-00008"; + + @LogMessageInfo( + message = "Can't update bundle = {0} as it's already uninstalled.", + level = "WARNING") + public static final String CANT_UPDATE_ALREADY_INSTALLED = "NCLS-BOOTSTRAP-00009"; + + @LogMessageInfo( + message = "Updated bundle {0} from {1}.", + level = "INFO") + public static final String BUNDLE_UPDATED = "NCLS-BOOTSTRAP-00010"; + + @LogMessageInfo( + message = "Failed to uninstall bundle {0}.", + level = "WARNING") + public static final String BUNDLE_UNINSTALL_FAILED = "NCLS-BOOTSTRAP-00011"; + + @LogMessageInfo( + message = "Failed to update {0}.", + level = "WARNING") + public static final String UPDATE_FAILED = "NCLS-BOOTSTRAP-00012"; + + @LogMessageInfo( + message = "Failed to install {0}.", + level = "WARNING") + public static final String INSTALL_FAILED = "NCLS-BOOTSTRAP-00013"; + + @LogMessageInfo( + message = "Can not set the start level for {0} to {2} as it is already set to {1}.", + level = "WARNING") + public static final String CANT_SET_START_LEVEL = "NCLS-BOOTSTRAP-00014"; + + @LogMessageInfo( + message = "Skipping entry {0} because it is not an absolute URI.", + level = "WARNING") + public static final String ENTRY_SKIPPED = "NCLS-BOOTSTRAP-00015"; + + @LogMessageInfo( + message = "Skipping entry {0} due to exception: ", + level = "WARNING") + public static final String ENTRY_SKIPPED_DUE_TO = "NCLS-BOOTSTRAP-00016"; + + @LogMessageInfo( + message = "Create bundle provisioner {0}.", + level = "CONFIG") + public static final String CREATE_BUNDLE_PROVISIONER = "NCLS-BOOTSTRAP-00026"; + + @LogMessageInfo( + message = "Registered {0} as OSGi service registration: {1}.", + level = "CONFIG") + public static final String SERVICE_REGISTERED = "NCLS-BOOTSTRAP-00027"; + + @LogMessageInfo( + message = "Unregistered {0} from service registry.", + level = "CONFIG") + public static final String SERVICE_UNREGISTERED = "NCLS-BOOTSTRAP-00028"; + + @LogMessageInfo( + message = "Exception while unregistering: ", + level = "WARNING") + public static final String SERVICE_UNREGISTRATION_EXCEPTION = "NCLS-BOOTSTRAP-00029"; + + @LogMessageInfo( + message = "installLocations = {0}.", + level = "INFO") + public static final String SHOW_INSTALL_LOCATIONS = "NCLS-BOOTSTRAP-00030"; + + @LogMessageInfo( + message = "Unable to determine if {0} is a fragment or not due to ", + level = "INFO") + public static final String CANT_TELL_IF_FRAGMENT = "NCLS-BOOTSTRAP-00031"; + + @LogMessageInfo( + message = "Skipping starting of bundles bundles have been provisioned already.", + level = "INFO") + public static final String SKIP_STARTING_ALREADY_PROVISIONED_BUNDLES = "NCLS-BOOTSTRAP-00032"; + + @LogMessageInfo( + message = "{0} : latest file in installation location = {1} and latest installed bundle = {2} ", + level = "INFO") + public static final String LATEST_FILE_IN_INSTALL_LOCATION = "NCLS-BOOTSTRAP-00033"; + + @LogMessageInfo( + message = "Updating system bundle.", + level = "INFO") + public static final String UPDATING_SYSTEM_BUNDLE = "NCLS-BOOTSTRAP-00034"; + + @LogMessageInfo( + message = "Provisioning options have changed, recreating the framework with a clean OSGi storage(aka cache).", + level = "INFO") + public static final String PROVISIONING_OPTIONS_CHANGED = "NCLS-BOOTSTRAP-00035"; + + @LogMessageInfo( + message = "Storage support not available in framework bundle, so can't store bundle ids. This may lead to slower start up time.", + level = "WARNING") + public static final String CANT_STORE_BUNDLEIDS = "NCLS-BOOTSTRAP-00037"; + + @LogMessageInfo( + message = "Storage support not available in framework bundle, so can't store provisioning options. This may lead to slower start up time.", + level = "WARNING") + public static final String CANT_STORE_PROVISIONING_OPTIONS = "NCLS-BOOTSTRAP-00038"; + + @LogMessageInfo( + message = "Got an unexpected exception.", + level = "WARNING") + public static final String CAUGHT_EXCEPTION = "NCLS-BOOTSTRAP-00039"; + + /** + * This helper method is duplicated from org.glassfish.api.logging.LogHelper to avoid adding + * dependency on the glassfish-api bundle. + * Logs a message with the given level, message, parameters and Throwable. + * + * @param logger the Logger object to be used for logging the message. + * @param level the Level of the message to be logged. + * @param messageId the key in the resource bundle of the Logger containing the localized text. + * @param thrown the Throwable associated with the message to be logged. + * @param params the parameters to the localized text. + */ + public static void log(Logger logger, Level level, String messageId, Throwable thrown, Object... params) { + LogRecord rec = new LogRecord(level, messageId); + rec.setLoggerName(logger.getName()); + rec.setResourceBundleName(logger.getResourceBundleName()); + rec.setResourceBundle(logger.getResourceBundle()); + rec.setParameters(params); + rec.setThrown(thrown); + logger.log(rec); + } +} diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisioner.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisioner.java index e8355f0bc07..2100bd22149 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisioner.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/BundleProvisioner.java @@ -17,8 +17,6 @@ package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; @@ -31,6 +29,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.boot.log.LogFacade; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/DefaultBundleProvisionerCustomizer.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/DefaultBundleProvisionerCustomizer.java index d7f809e7a75..dd013789f71 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/DefaultBundleProvisionerCustomizer.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/DefaultBundleProvisionerCustomizer.java @@ -16,8 +16,6 @@ package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.io.File; import java.io.FileFilter; import java.net.URI; @@ -33,6 +31,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.glassfish.main.boot.log.LogFacade; import org.osgi.framework.Bundle; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.AUTO_INSTALL_PROP; diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishImpl.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishImpl.java index 29d7785d9e0..02fcc67eb13 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishImpl.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/EmbeddedOSGiGlassFishImpl.java @@ -17,13 +17,12 @@ package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.util.logging.Level; import java.util.logging.Logger; import org.glassfish.embeddable.GlassFish; import org.glassfish.embeddable.GlassFishException; +import org.glassfish.main.boot.log.LogFacade; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisioner.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisioner.java index c3be576dd86..79c6fc9d139 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisioner.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisioner.java @@ -17,14 +17,13 @@ package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.util.Collections; import java.util.List; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.boot.log.LogFacade; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisionerCustomizer.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisionerCustomizer.java index 24311e45cef..cb6eb114a76 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisionerCustomizer.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/MinimalBundleProvisionerCustomizer.java @@ -16,8 +16,6 @@ package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -30,6 +28,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.main.boot.log.LogFacade; import org.osgi.framework.Constants; class MinimalBundleProvisionerCustomizer extends DefaultBundleProvisionerCustomizer { diff --git a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntimeBuilder.java b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntimeBuilder.java index eacc8f90286..4f109b60a07 100644 --- a/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntimeBuilder.java +++ b/nucleus/core/bootstrap-osgi/src/main/java/org/glassfish/main/boot/osgi/OSGiGlassFishRuntimeBuilder.java @@ -19,7 +19,6 @@ import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; import java.io.File; import java.io.FileInputStream; @@ -35,6 +34,7 @@ import org.glassfish.embeddable.GlassFishException; import org.glassfish.embeddable.GlassFishRuntime; import org.glassfish.embeddable.spi.RuntimeBuilder; +import org.glassfish.main.boot.log.LogFacade; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import org.osgi.framework.launch.Framework; diff --git a/nucleus/core/bootstrap-osgi/src/test/java/org/glassfish/main/boot/osgi/BundleProvisionerTest.java b/nucleus/core/bootstrap-osgi/src/test/java/org/glassfish/main/boot/osgi/BundleProvisionerTest.java index 3923b7f6891..a22f85c2815 100644 --- a/nucleus/core/bootstrap-osgi/src/test/java/org/glassfish/main/boot/osgi/BundleProvisionerTest.java +++ b/nucleus/core/bootstrap-osgi/src/test/java/org/glassfish/main/boot/osgi/BundleProvisionerTest.java @@ -16,8 +16,6 @@ package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.log.LogFacade; - import java.lang.System.Logger; import java.lang.System.Logger.Level; import java.nio.file.Files; @@ -44,7 +42,7 @@ class BundleProvisionerTest { @Test void noBundles() throws Exception { - LOG.log(Level.INFO, LogFacade.STARTING_BUNDLEPROVISIONER); + LOG.log(Level.INFO, "Starting BundleProvisioner"); // TODO: add some properties, create more tests Properties props = new Properties(); Path cacheDir = Files.createTempDirectory("FelixCache"); @@ -60,14 +58,14 @@ void noBundles() throws Exception { } assertNotNull(osgiFramework, "No OSGi framwework found!"); long t1 = System.currentTimeMillis(); - LOG.log(Level.INFO, LogFacade.OSGI_LOCATE_TIME, (t1-t0)); + LOG.log(Level.INFO, "Time taken to locate OSGi framework = {0} ms.", t1 - t0); osgiFramework.init(); long t2 = System.currentTimeMillis(); - LOG.log(Level.INFO, LogFacade.OSGI_INIT_TIME, (t2-t1)); + LOG.log(Level.INFO, "Time taken to initialize OSGi framework = {0} ms.", t2 - t1); BundleProvisioner bundleProvisioner = new BundleProvisioner(osgiFramework.getBundleContext(), props); bundleProvisioner.installBundles(); long t3 = System.currentTimeMillis(); - LOG.log(Level.INFO, LogFacade.BUNDLE_INSTALLATION_TIME, (t3-t2)); + LOG.log(Level.INFO, "Time taken to finish installation of bundles = {0} ms.", t3 - t2); assertEquals(0, bundleProvisioner.getNoOfInstalledBundles()); assertEquals(0, bundleProvisioner.getNoOfUpdatedBundles()); assertEquals(0, bundleProvisioner.getNoOfUninstalledBundles()); @@ -77,13 +75,13 @@ void noBundles() throws Exception { assertEquals(Bundle.ACTIVE, osgiFramework.getState()); long t4 = System.currentTimeMillis(); - LOG.log(Level.INFO, LogFacade.BUNDLE_STARTING_TIME, (t4-t3)); - LOG.log(Level.INFO, LogFacade.TOTAL_START_TIME, (t4-t0)); + LOG.log(Level.INFO, "Time taken to finish starting bundles = {0} ms.", t4 - t3); + LOG.log(Level.INFO, "Total time taken to start = {0} ms.", t4 - t0); osgiFramework.stop(); osgiFramework.waitForStop(0); long t5 = System.currentTimeMillis(); - LOG.log(Level.INFO, LogFacade.BUNDLE_STOP_TIME, (t5 - t4)); - LOG.log(Level.INFO, LogFacade.TOTAL_TIME, (t5-t0)); + LOG.log(Level.INFO, "Time taken to stop = {0} ms.", t5 - t4); + LOG.log(Level.INFO, "Total time taken = {0}.", t5 - t0); assertEquals(Bundle.RESOLVED, osgiFramework.getState()); } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/log/LogFacade.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/log/LogFacade.java index 29c8475eecd..356dfbd4fbf 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/log/LogFacade.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/log/LogFacade.java @@ -17,8 +17,6 @@ package com.sun.enterprise.glassfish.bootstrap.log; -import java.util.logging.Level; -import java.util.logging.LogRecord; import java.util.logging.Logger; import org.glassfish.logging.annotation.LogMessageInfo; @@ -30,8 +28,8 @@ public class LogFacade { @LoggerInfo(subsystem = "BOOTSTRAP", description="Main bootstrap logger.") public static final String BOOTSTRAP_LOGGER_NAME = "jakarta.enterprise.bootstrap"; - @LogMessagesResourceBundle() - public static final String RB_NAME = "com.sun.enterprise.glassfish.bootstrap.LogMessages"; + @LogMessagesResourceBundle + public static final String RB_NAME = "com.sun.enterprise.glassfish.bootstrap.log.LogMessages"; public static final Logger BOOTSTRAP_LOGGER = Logger.getLogger(BOOTSTRAP_LOGGER_NAME, RB_NAME); @@ -47,189 +45,4 @@ public class LogFacade { level = "INFO") public static final String BOOTSTRAP_FMWCONF = "NCLS-BOOTSTRAP-00002"; - @LogMessageInfo( - message = "Can not start bundle {0} because it is not contained in the list of installed bundles.", - level = "WARNING") - public static final String CANT_START_BUNDLE = "NCLS-BOOTSTRAP-00005"; - - @LogMessageInfo( - message = "Failed to start {0}.", - level = "WARNING") - public static final String BUNDLE_START_FAILED = "NCLS-BOOTSTRAP-00006"; - - @LogMessageInfo( - message = "Can't uninstall bundle = {0} as it's already uninstalled.", - level = "WARNING") - public static final String BUNDLE_ALREADY_UNINSTALED = "NCLS-BOOTSTRAP-00007"; - - @LogMessageInfo( - message = "Uninstalled bundle {0} installed from {1}.", - level = "INFO") - public static final String UNINSTALLED_BUNDLE = "NCLS-BOOTSTRAP-00008"; - - @LogMessageInfo( - message = "Can't update bundle = {0} as it's already uninstalled.", - level = "WARNING") - public static final String CANT_UPDATE_ALREADY_INSTALLED = "NCLS-BOOTSTRAP-00009"; - - @LogMessageInfo( - message = "Updated bundle {0} from {1}.", - level = "INFO") - public static final String BUNDLE_UPDATED = "NCLS-BOOTSTRAP-00010"; - - @LogMessageInfo( - message = "Failed to uninstall bundle {0}.", - level = "WARNING") - public static final String BUNDLE_UNINSTALL_FAILED = "NCLS-BOOTSTRAP-00011"; - - @LogMessageInfo( - message = "Failed to update {0}.", - level = "WARNING") - public static final String UPDATE_FAILED = "NCLS-BOOTSTRAP-00012"; - - @LogMessageInfo( - message = "Failed to install {0}.", - level = "WARNING") - public static final String INSTALL_FAILED = "NCLS-BOOTSTRAP-00013"; - - @LogMessageInfo( - message = "Can not set the start level for {0} to {2} as it is already set to {1}.", - level = "WARNING") - public static final String CANT_SET_START_LEVEL = "NCLS-BOOTSTRAP-00014"; - - @LogMessageInfo( - message = "Skipping entry {0} because it is not an absolute URI.", - level = "WARNING") - public static final String ENTRY_SKIPPED = "NCLS-BOOTSTRAP-00015"; - - @LogMessageInfo( - message = "Skipping entry {0} due to exception: ", - level = "WARNING") - public static final String ENTRY_SKIPPED_DUE_TO = "NCLS-BOOTSTRAP-00016"; - - @LogMessageInfo( - message = "Starting BundleProvisioner.", - level = "INFO") - public static final String STARTING_BUNDLEPROVISIONER = "NCLS-BOOTSTRAP-00017"; - - @LogMessageInfo( - message = "Time taken to locate OSGi framework = {0} ms.", - level = "INFO") - public static final String OSGI_LOCATE_TIME = "NCLS-BOOTSTRAP-00018"; - - @LogMessageInfo( - message = "Time taken to initialize OSGi framework = {0} ms.", - level = "INFO") - public static final String OSGI_INIT_TIME = "NCLS-BOOTSTRAP-00020"; - - @LogMessageInfo( - message = "Time taken to finish installation of bundles = {0} ms.", - level = "INFO") - public static final String BUNDLE_INSTALLATION_TIME = "NCLS-BOOTSTRAP-00021"; - - @LogMessageInfo( - message = "Time taken to finish starting bundles = {0} ms.", - level = "INFO") - public static final String BUNDLE_STARTING_TIME = "NCLS-BOOTSTRAP-00022"; - - @LogMessageInfo( - message = "Total time taken to start = {0} ms.", - level = "INFO") - public static final String TOTAL_START_TIME = "NCLS-BOOTSTRAP-00023"; - - @LogMessageInfo( - message = "Time taken to stop = {0} ms.", - level = "INFO") - public static final String BUNDLE_STOP_TIME = "NCLS-BOOTSTRAP-00024"; - - @LogMessageInfo( - message = "Total time taken = {0}.", - level = "INFO") - public static final String TOTAL_TIME = "NCLS-BOOTSTRAP-00025"; - - @LogMessageInfo( - message = "Create bundle provisioner {0}.", - level = "CONFIG") - public static final String CREATE_BUNDLE_PROVISIONER = "NCLS-BOOTSTRAP-00026"; - - @LogMessageInfo( - message = "Registered {0} as OSGi service registration: {1}.", - level = "CONFIG") - public static final String SERVICE_REGISTERED = "NCLS-BOOTSTRAP-00027"; - - @LogMessageInfo( - message = "Unregistered {0} from service registry.", - level = "CONFIG") - public static final String SERVICE_UNREGISTERED = "NCLS-BOOTSTRAP-00028"; - - @LogMessageInfo( - message = "Exception while unregistering: ", - level = "WARNING") - public static final String SERVICE_UNREGISTRATION_EXCEPTION = "NCLS-BOOTSTRAP-00029"; - - @LogMessageInfo( - message = "installLocations = {0}.", - level = "INFO") - public static final String SHOW_INSTALL_LOCATIONS = "NCLS-BOOTSTRAP-00030"; - - @LogMessageInfo( - message = "Unable to determine if {0} is a fragment or not due to ", - level = "INFO") - public static final String CANT_TELL_IF_FRAGMENT = "NCLS-BOOTSTRAP-00031"; - - @LogMessageInfo( - message = "Skipping starting of bundles bundles have been provisioned already.", - level = "INFO") - public static final String SKIP_STARTING_ALREADY_PROVISIONED_BUNDLES = "NCLS-BOOTSTRAP-00032"; - - @LogMessageInfo( - message = "{0} : latest file in installation location = {1} and latest installed bundle = {2} ", - level = "INFO") - public static final String LATEST_FILE_IN_INSTALL_LOCATION = "NCLS-BOOTSTRAP-00033"; - - @LogMessageInfo( - message = "Updating system bundle.", - level = "INFO") - public static final String UPDATING_SYSTEM_BUNDLE = "NCLS-BOOTSTRAP-00034"; - - @LogMessageInfo( - message = "Provisioning options have changed, recreating the framework with a clean OSGi storage(aka cache).", - level = "INFO") - public static final String PROVISIONING_OPTIONS_CHANGED = "NCLS-BOOTSTRAP-00035"; - - @LogMessageInfo( - message = "Storage support not available in framework bundle, so can't store bundle ids. This may lead to slower start up time.", - level = "WARNING") - public static final String CANT_STORE_BUNDLEIDS = "NCLS-BOOTSTRAP-00037"; - - @LogMessageInfo( - message = "Storage support not available in framework bundle, so can't store provisioning options. This may lead to slower start up time.", - level = "WARNING") - public static final String CANT_STORE_PROVISIONING_OPTIONS = "NCLS-BOOTSTRAP-00038"; - - @LogMessageInfo( - message = "Got an unexpected exception.", - level = "WARNING") - public static final String CAUGHT_EXCEPTION = "NCLS-BOOTSTRAP-00039"; - - /** - * This helper method is duplicated from org.glassfish.api.logging.LogHelper to avoid adding - * dependency on the glassfish-api bundle. - * Logs a message with the given level, message, parameters and Throwable. - * - * @param logger the Logger object to be used for logging the message. - * @param level the Level of the message to be logged. - * @param messageId the key in the resource bundle of the Logger containing the localized text. - * @param thrown the Throwable associated with the message to be logged. - * @param params the parameters to the localized text. - */ - public static void log(Logger logger, Level level, String messageId, Throwable thrown, Object... params) { - LogRecord rec = new LogRecord(level, messageId); - rec.setLoggerName(logger.getName()); - rec.setResourceBundleName(logger.getResourceBundleName()); - rec.setResourceBundle(logger.getResourceBundle()); - rec.setParameters(params); - rec.setThrown(thrown); - logger.log(rec); - } } diff --git a/nucleus/core/bootstrap/src/main/java/module-info.java b/nucleus/core/bootstrap/src/main/java/module-info.java new file mode 100644 index 00000000000..8b5b5fc74f2 --- /dev/null +++ b/nucleus/core/bootstrap/src/main/java/module-info.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * @author David Matejcek + */ +module org.glassfish.main.bootstrap { + + requires java.base; + requires java.logging; + + requires org.apache.felix.framework; + requires org.glassfish.annotation.processing.logging; + requires org.glassfish.main.jdke; + + exports com.sun.enterprise.glassfish.bootstrap.cfg; + exports com.sun.enterprise.glassfish.bootstrap.launch; +} diff --git a/nucleus/glassfish-jul-extension/src/main/java/module-info.java b/nucleus/glassfish-jul-extension/src/main/java/module-info.java index 3be019be94d..47055a1c3b4 100644 --- a/nucleus/glassfish-jul-extension/src/main/java/module-info.java +++ b/nucleus/glassfish-jul-extension/src/main/java/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at From 88b35a2ee6e23199893dd0b4a89cb9545c69f487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Sat, 12 Oct 2024 13:41:26 +0200 Subject: [PATCH 19/38] LocalStringsImpl - JPMS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - removed Control, unsupported with JPMS - removed dead code - added env option to enable logging of all failed lookups Signed-off-by: David Matějček --- .../main/jdke/i18n/LocalStringsImpl.java | 166 ++++++++---------- 1 file changed, 71 insertions(+), 95 deletions(-) diff --git a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java index 019ef61e35f..e5398739f56 100644 --- a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java @@ -17,10 +17,14 @@ package org.glassfish.main.jdke.i18n; +import java.io.FileNotFoundException; +import java.io.PrintStream; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; +import static java.util.ResourceBundle.Control.FORMAT_PROPERTIES; + /** * This class makes getting localized strings super-simple. This is the companion * class to Strings. Use this class when performance may be an issue. I.e. Strings @@ -48,20 +52,31 @@ * @author bnevins 2005 */ public class LocalStringsImpl { - private ResourceBundle bundle; - private String propsName = "LocalStrings"; - private static final String thisPackage = "com.elf.util"; - private static final ResourceBundle.Control rbcontrol = ResourceBundle.Control - .getControl(ResourceBundle.Control.FORMAT_PROPERTIES); - /** - * Create a LocalStringsImpl instance. - * Automatically discover the caller's LocalStrings.properties file - */ - public LocalStringsImpl() { - setBundle(); + private static final boolean LOG_ERRORS = Boolean.parseBoolean(System.getenv("AS_LOG_I18N_ERRORS")); + private static final String LOG_TARGET_FILE = System.getenv("AS_LOG_I18N_LOG_FILE"); + private static final PrintStream LOG_TARGET; + private static final String thisPackage = "com.elf.util"; + private static final ResourceBundle.Control rbcontrol = ResourceBundle.Control.getControl(FORMAT_PROPERTIES); + static { + if (LOG_ERRORS) { + if (LOG_TARGET_FILE == null) { + LOG_TARGET = System.err; + } else { + try { + LOG_TARGET = new PrintStream(LOG_TARGET_FILE); + Runtime.getRuntime().addShutdownHook(new Thread(() -> LOG_TARGET.close())); + } catch (FileNotFoundException e) { + throw new Error(e); + } + } + } else { + LOG_TARGET = null; + } } + private final ResourceBundle bundle; + /** * Create a LocalStringsImpl instance. * use the proffered class object to find LocalStrings.properties. @@ -69,165 +84,126 @@ public LocalStringsImpl() { * the fastest performance. */ public LocalStringsImpl(Class clazz) { - setBundle(clazz); + bundle = load(clazz); } - /** - * Create a LocalStringsImpl instance. - * use the proffered String. The String is the FQN of the properties file, - * without the '.properties'. E.g. 'com.elf.something.LogStrings' - */ - public LocalStringsImpl(String packageName, String propsName) { - this.propsName = propsName; - int len = packageName.length(); - // side-effect -- make sure it ends in '.' - if (packageName.charAt(len - 1) != '.') { - packageName += '.'; + private static ResourceBundle load(Class clazz) { + try { + String className = clazz.getName(); + String props = className.substring(0, className.lastIndexOf('.')) + "." + "LocalStrings"; + return ResourceBundle.getBundle(props, Locale.getDefault(), clazz.getModule()); + } catch (Exception e) { + if (LOG_ERRORS) { + e.printStackTrace(LOG_TARGET); + } + return null; } - - setBundle(packageName); } + /** * Get a String from the caller's package's LocalStrings.properties + * * @param indexString The string index into the localized string file * @return the String from LocalStrings or the supplied String if it doesn't exist */ public String get(String indexString) { try { return getBundle().getString(indexString); - } - catch (Exception e) { + } catch (Exception e) { + if (LOG_ERRORS) { + e.printStackTrace(LOG_TARGET); + } // it is not an error to have no key... return indexString; } } + /** * Get and format a String from the caller's package's LocalStrings.properties + * * @param indexString The string index into the localized string file * @param objects The arguments to give to MessageFormat * @return the String from LocalStrings or the supplied String if it doesn't exist -- - * using the array of supplied Object arguments + * using the array of supplied Object arguments */ public String get(String indexString, Object... objects) { indexString = get(indexString); - try { MessageFormat mf = new MessageFormat(indexString); return mf.format(objects); - } - catch (Exception e) { + } catch (Exception e) { + if (LOG_ERRORS) { + e.printStackTrace(LOG_TARGET); + } return indexString; } } + /** * Get a String from the caller's package's LocalStrings.properties + * * @param indexString The string index into the localized string file * @return the String from LocalStrings or the supplied default value if it doesn't exist */ public String getString(String indexString, String defaultValue) { try { return getBundle().getString(indexString); - } - catch (Exception e) { + } catch (Exception e) { + if (LOG_ERRORS) { + e.printStackTrace(LOG_TARGET); + } // it is not an error to have no key... return defaultValue; } } + /** * Get an integer from the caller's package's LocalStrings.properties + * * @param indexString The string index into the localized string file * @return the integer value from LocalStrings or the supplied default if - * it doesn't exist or is bad. + * it doesn't exist or is bad. */ public int getInt(String indexString, int defaultValue) { try { String s = getBundle().getString(indexString); return Integer.parseInt(s); - } - catch (Exception e) { + } catch (Exception e) { + if (LOG_ERRORS) { + e.printStackTrace(LOG_TARGET); + } // it is not an error to have no key... return defaultValue; } } + /** * Get a boolean from the caller's package's LocalStrings.properties + * * @param indexString The string index into the localized string file * @return the integer value from LocalStrings or the supplied default if - * it doesn't exist or is bad. + * it doesn't exist or is bad. */ public boolean getBoolean(String indexString, boolean defaultValue) { try { return Boolean.parseBoolean(getBundle().getString(indexString)); - } - catch (Exception e) { + } catch (Exception e) { + if (LOG_ERRORS) { + e.printStackTrace(LOG_TARGET); + } // it is not an error to have no key... return defaultValue; } } + public ResourceBundle getBundle() { return bundle; } - - /////////////////////////////////////////////////////////////////////////// - private void setBundle() { - // go through the stack, top to bottom. The item that is below the LAST - // method that is in the util framework is where the logfile is. - // note that there may be more than one method from util in the stack - // because they may be calling us indirectly from LoggerHelper. Also - // note that this class won't work from any class in the util hierarchy itself. - - try { - StackTraceElement[] items = Thread.currentThread().getStackTrace(); - int lastMeOnStack = -1; - - for (int i = 0; i < items.length; i++) { - StackTraceElement item = items[i]; - if (item.getClassName().startsWith(thisPackage)) { - lastMeOnStack = i; - } - } - - String className = items[lastMeOnStack + 1].getClassName(); - setBundle(className); - } - catch (Exception e) { - bundle = null; - } - } - - private void setBundle(Class clazz) { - - try { - String className = clazz.getName(); - setBundle(className); - - // April 25, 2009 -- if OSGi is in charge then we might not have got the - // bundle! Fix: send in the class's Classloader... - if(bundle == null) { - String props = className.substring(0, className.lastIndexOf('.')) + "." + propsName; - bundle = ResourceBundle.getBundle(props, Locale.getDefault(), clazz.getClassLoader(), - rbcontrol); - } - } - catch (Exception e) { - bundle = null; - } - } - - private void setBundle(String className) { - try { - String props = className.substring(0, className.lastIndexOf('.')) + "." + propsName; - bundle = ResourceBundle.getBundle(props, rbcontrol); - } - catch (Exception e) { - bundle = null; - } - } } From e4148fdec72f647d0e3320e9410ff08a3afd4b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Sun, 13 Oct 2024 14:15:42 +0200 Subject: [PATCH 20/38] Deleted unused LocalStrings class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../main/jdke/i18n/LocalStrings.java | 103 ------------------ 1 file changed, 103 deletions(-) delete mode 100644 nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStrings.java diff --git a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStrings.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStrings.java deleted file mode 100644 index 872749533d9..00000000000 --- a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStrings.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2024 Contributors to the Eclipse Foundation. - * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package org.glassfish.main.jdke.i18n; - -/** - * This class makes getting localized strings super-simple. All methods are static. - * The reason is that that makes it much simpler to use -- you never need to create an - * instance and store it. You simply call one of the 2 methods directly. However, - * there is a performance penalty for this convenience. This class has to figure out - * what package your calling code is in (every time). My reasoning is that the emitting - * of log messages tends to be much less frequent than other normal processing steps. - * If performance is an issue -- use an instance of LocalStringsImpl. - *

Specifics: - *

    - *
  • Your calling code should have a file named LocalStrings.properties in its - * package directory. - *
  • If your localized string has no arguments call get(String) to get the localized - * String value. - *
  • If you have a parameterized string, call get(String, Object...) - *
- *

Note: You can not get an Exception out of calling this code! If the String - * or the properties file does not exist, it will return the String that you gave - * in the first place as the argument. - *

Examples: - *

    - *
  • String s = LocalStrings.get("xyz"); - *
  • String s = LocalStrings.get("xyz", new Date(), 500, "something", 2.00003); - *
  • String s = LocalStrings.get("xyz", "something", "foo", "whatever"); - *
- * - * - * - * @author bnevins - */ -public class LocalStrings { - - private LocalStrings() { - } - - /** - * Get a String from the caller's package's LocalStrings.properties - * @param indexString The string index into the localized string file - * @return the String from LocalStrings or the supplied String if it doesn't exist - */ - public static String get(String indexString) { - return new LocalStringsImpl().get(indexString); - } - - /** - * Get and format a String from the caller's package's LocalStrings.properties - * @param indexString The string index into the localized string file - * @param objects The arguments to give to MessageFormat - * @return the String from LocalStrings or the supplied String if it doesn't exist -- - * using the array of supplied Object arguments - */ - public static String get(String indexString, Object... objects) { - return new LocalStringsImpl().get(indexString, objects); - } - - /** - * Get a String from the caller's package's LocalStrings.properties - * @param indexString The string index into the localized string file - * @return the String from LocalStrings or the supplied default value if it doesn't exist - */ - public String getString(String indexString, String defaultValue) { - return new LocalStringsImpl().get(indexString, defaultValue); - } - - /** - * Get an integer from the caller's package's LocalStrings.properties - * @param indexString The string index into the localized string file - * @return the integer value from LocalStrings or the supplied default if - * it doesn't exist or is bad. - */ - public static int getInt(String indexString, int defaultValue) { - return new LocalStringsImpl().getInt(indexString, defaultValue); - } - - /** - * Get a boolean from the caller's package's LocalStrings.properties - * @param indexString The string index into the localized string file - * @return the integer value from LocalStrings or the supplied default if - * it doesn't exist or is bad. - */ - public boolean getBoolean(String indexString, boolean defaultValue) { - return new LocalStringsImpl().getBoolean(indexString, defaultValue); - } -} From e5408a92c8e8d5625fdd1a6b911f4bc9fad3d321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Mon, 14 Oct 2024 01:10:12 +0200 Subject: [PATCH 21/38] Added logging keys too as Java doesn't do that MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../main/jdke/i18n/LocalStringsImpl.java | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java index e5398739f56..ca15c89ddb9 100644 --- a/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/i18n/LocalStringsImpl.java @@ -20,6 +20,7 @@ import java.io.FileNotFoundException; import java.io.PrintStream; import java.text.MessageFormat; +import java.util.Arrays; import java.util.Locale; import java.util.ResourceBundle; @@ -89,12 +90,13 @@ public LocalStringsImpl(Class clazz) { private static ResourceBundle load(Class clazz) { + String className = clazz.getName(); + String props = className.substring(0, className.lastIndexOf('.')) + "." + "LocalStrings"; try { - String className = clazz.getName(); - String props = className.substring(0, className.lastIndexOf('.')) + "." + "LocalStrings"; return ResourceBundle.getBundle(props, Locale.getDefault(), clazz.getModule()); } catch (Exception e) { if (LOG_ERRORS) { + LOG_TARGET.println("Could not find resource bundle: " + props); e.printStackTrace(LOG_TARGET); } return null; @@ -105,18 +107,19 @@ private static ResourceBundle load(Class clazz) { /** * Get a String from the caller's package's LocalStrings.properties * - * @param indexString The string index into the localized string file + * @param key The string index into the localized string file * @return the String from LocalStrings or the supplied String if it doesn't exist */ - public String get(String indexString) { + public String get(String key) { try { - return getBundle().getString(indexString); + return getBundle().getString(key); } catch (Exception e) { if (LOG_ERRORS) { + LOG_TARGET.println("Could not resolve: " + key); e.printStackTrace(LOG_TARGET); } // it is not an error to have no key... - return indexString; + return key; } } @@ -124,21 +127,24 @@ public String get(String indexString) { /** * Get and format a String from the caller's package's LocalStrings.properties * - * @param indexString The string index into the localized string file + * @param key The string index into the localized string file * @param objects The arguments to give to MessageFormat * @return the String from LocalStrings or the supplied String if it doesn't exist -- * using the array of supplied Object arguments */ - public String get(String indexString, Object... objects) { - indexString = get(indexString); + public String get(String key, Object... objects) { + final String template = get(key); + if (template == key) { + return key + ": " + Arrays.toString(objects); + } try { - MessageFormat mf = new MessageFormat(indexString); + MessageFormat mf = new MessageFormat(template); return mf.format(objects); } catch (Exception e) { if (LOG_ERRORS) { e.printStackTrace(LOG_TARGET); } - return indexString; + return template; } } @@ -146,14 +152,15 @@ public String get(String indexString, Object... objects) { /** * Get a String from the caller's package's LocalStrings.properties * - * @param indexString The string index into the localized string file + * @param key The string index into the localized string file * @return the String from LocalStrings or the supplied default value if it doesn't exist */ - public String getString(String indexString, String defaultValue) { + public String getString(String key, String defaultValue) { try { - return getBundle().getString(indexString); + return getBundle().getString(key); } catch (Exception e) { if (LOG_ERRORS) { + LOG_TARGET.println("Could not resolve: " + key); e.printStackTrace(LOG_TARGET); } // it is not an error to have no key... @@ -165,16 +172,17 @@ public String getString(String indexString, String defaultValue) { /** * Get an integer from the caller's package's LocalStrings.properties * - * @param indexString The string index into the localized string file + * @param key The string index into the localized string file * @return the integer value from LocalStrings or the supplied default if * it doesn't exist or is bad. */ - public int getInt(String indexString, int defaultValue) { + public int getInt(String key, int defaultValue) { try { - String s = getBundle().getString(indexString); + String s = getBundle().getString(key); return Integer.parseInt(s); } catch (Exception e) { if (LOG_ERRORS) { + LOG_TARGET.println("Could not resolve: " + key); e.printStackTrace(LOG_TARGET); } // it is not an error to have no key... @@ -186,15 +194,16 @@ public int getInt(String indexString, int defaultValue) { /** * Get a boolean from the caller's package's LocalStrings.properties * - * @param indexString The string index into the localized string file + * @param key The string index into the localized string file * @return the integer value from LocalStrings or the supplied default if * it doesn't exist or is bad. */ - public boolean getBoolean(String indexString, boolean defaultValue) { + public boolean getBoolean(String key, boolean defaultValue) { try { - return Boolean.parseBoolean(getBundle().getString(indexString)); + return Boolean.parseBoolean(getBundle().getString(key)); } catch (Exception e) { if (LOG_ERRORS) { + LOG_TARGET.println("Could not resolve: " + key); e.printStackTrace(LOG_TARGET); } // it is not an error to have no key... From b78b2c2af10c0db9d536b51c2e29797d77bf777a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Mon, 14 Oct 2024 01:11:00 +0200 Subject: [PATCH 22/38] Added missing `uses org.glassfish.embeddable.spi.RuntimeBuilder` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../simple-glassfish-api/src/main/java/module-info.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nucleus/common/simple-glassfish-api/src/main/java/module-info.java b/nucleus/common/simple-glassfish-api/src/main/java/module-info.java index 2892a81a8c6..9aa97512d2d 100644 --- a/nucleus/common/simple-glassfish-api/src/main/java/module-info.java +++ b/nucleus/common/simple-glassfish-api/src/main/java/module-info.java @@ -15,6 +15,10 @@ */ /** + * Basic GlassFish interfaces and classes used by all implementations. + * + * @uses org.glassfish.embeddable.spi.RuntimeBuilder + * * @author David Matejcek */ module org.glassfish.main.api.simple { @@ -22,6 +26,8 @@ requires java.base; requires java.logging; + uses org.glassfish.embeddable.spi.RuntimeBuilder; + exports org.glassfish.embeddable; exports org.glassfish.embeddable.spi; } From ccf4500caa48a7169d6980cf375aba03f972b851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Mon, 14 Oct 2024 01:12:31 +0200 Subject: [PATCH 23/38] Removed usages of private class of gjule: GlassFishLoggingTracer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../src/main/java/com/sun/enterprise/admin/cli/AdminMain.java | 2 -- .../com/sun/enterprise/server/logging/LogManagerService.java | 3 --- 2 files changed, 5 deletions(-) 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 badc3c02b6a..b1fb6243bdf 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 @@ -58,7 +58,6 @@ import org.glassfish.main.jul.cfg.LoggingProperties; import org.glassfish.main.jul.formatter.GlassFishLogFormatter; import org.glassfish.main.jul.handler.BlockingExternallyManagedLogHandler; -import org.glassfish.main.jul.tracing.GlassFishLoggingTracer; import static com.sun.enterprise.admin.cli.CLIConstants.WALL_CLOCK_START_PROP; import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; @@ -334,7 +333,6 @@ public int executeCommand(String[] argv) { } private void configureLogging() { - GlassFishLoggingTracer.trace(AdminMain.class, "Configuring logging for asadmin."); boolean trace = env.trace(); boolean debug = env.debug(); diff --git a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java index 1f2fb7c5937..07fc8e0e4f1 100644 --- a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java +++ b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java @@ -64,7 +64,6 @@ import org.glassfish.main.jul.handler.GlassFishLogHandler; import org.glassfish.main.jul.handler.GlassFishLogHandlerConfiguration; import org.glassfish.main.jul.handler.GlassFishLogHandlerProperty; -import org.glassfish.main.jul.tracing.GlassFishLoggingTracer; import org.glassfish.server.ServerEnvironmentImpl; import org.jvnet.hk2.annotations.Service; @@ -323,7 +322,6 @@ private Map getResolvedLoggingProperties() throws IOException { private void reconfigure(final File configFile) { - GlassFishLoggingTracer.trace(getClass(), () -> "reconfigure(" + configFile + ")"); LOG.info(() -> "Using property file: " + configFile); if (!GlassFishLogManager.isGlassFishLogManager()) { try (FileInputStream configuration = new FileInputStream(configFile)) { @@ -337,7 +335,6 @@ private void reconfigure(final File configFile) { try { final GlassFishLogManagerConfiguration cfg = getRuntimeConfiguration(); if (cfg == null) { - GlassFishLoggingTracer.error(getClass(), "Logging configuration is not available!"); return; } final ReconfigurationAction reconfig = new ReconfigurationAction(cfg); From fbde9a13d3534a86a7429d6bb3aa12195fc9ed7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Mon, 14 Oct 2024 19:57:17 +0200 Subject: [PATCH 24/38] Implemented support for modulepath - bootstrap libs use it. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- appserver/admin/cli-optional/pom.xml | 16 +---- appserver/admin/cli/pom.xml | 7 -- .../src/main/resources/bin/asadmin | 5 +- .../src/main/resources/bin/asadmin.bat | 69 ++++++++++--------- .../src/main/resources/bin/debug-asadmin | 5 +- .../src/main/resources/bin/debug-asadmin.bat | 6 +- .../src/main/resources/bin/startserv | 9 +-- .../src/main/resources/bin/startserv.bat | 18 ++++- .../src/main/resources/bin/stopserv | 3 +- .../src/main/resources/bin/stopserv.bat | 40 +++++------ .../src/main/resources/glassfish/bin/asadmin | 5 +- .../main/resources/glassfish/bin/asadmin.bat | 69 ++++++++++--------- .../glassfish/src/main/assembly/glassfish.xml | 16 ++--- .../web/src/main/assembly/web.xml | 16 ++--- nucleus/admin/cli/pom.xml | 8 +-- .../sun/enterprise/admin/cli/AdminMain.java | 6 +- .../enterprise/admin/cli/CLIContainer.java | 2 +- .../admin/cli/MultimodeCommand.java | 1 + .../enterprise/admin/cli/ProgramOptions.java | 23 +++++-- .../admin/launcher/GFEmbeddedLauncher.java | 20 +++++- .../enterprise/admin/launcher/GFLauncher.java | 55 ++++++++++----- .../admin/launcher/GFLauncherInfo.java | 8 +-- .../launcher/GFLauncherNativeHelper.java | 8 ++- .../admin/launcher/GlassFishMainLauncher.java | 28 ++------ .../admin/launcher/RespawnInfo.java | 22 +++--- .../servermgmt/cli/StartDomainCommand.java | 2 +- .../v3/admin/cluster/NodeUtils.java | 2 +- nucleus/cluster/cli/pom.xml | 18 ----- .../cluster/StartLocalInstanceCommand.java | 26 ++++--- nucleus/cluster/gms-adapter/pom.xml | 10 --- .../universal/process/JavaClassRunner.java | 24 ++++--- .../glassfish/bootstrap/GlassFishMain.java | 3 +- .../bootstrap/cfg/BootstrapKeys.java | 2 + .../GlassfishOsgiBootstrapClassLoader.java | 4 +- .../enterprise/v3/admin/RestartServer.java | 9 ++- .../atomic/src/main/assembly/atomic.xml | 12 +++- .../src/main/resources/bin/nadmin | 5 +- .../src/main/resources/bin/nadmin.bat | 67 +++++++++--------- .../src/main/resources/bin/startserv | 9 +-- .../src/main/resources/bin/startserv.bat | 18 ++++- .../src/main/resources/bin/stopserv | 3 +- .../src/main/resources/bin/stopserv.bat | 40 +++++------ .../src/main/resources/config/asenv.bat | 3 + .../src/main/resources/config/asenv.conf | 3 + .../src/main/resources/config/osgi.properties | 4 +- .../nucleus/src/main/assembly/nucleus-new.xml | 13 +++- .../src/main/resources/config/osgi.properties | 4 +- .../interactive/LocalOSGiShellCommand.java | 1 + 48 files changed, 414 insertions(+), 333 deletions(-) diff --git a/appserver/admin/cli-optional/pom.xml b/appserver/admin/cli-optional/pom.xml index f3a7f29d1ff..66dc0f79af1 100755 --- a/appserver/admin/cli-optional/pom.xml +++ b/appserver/admin/cli-optional/pom.xml @@ -80,7 +80,8 @@ org.glassfish.main.admin admin-cli ${project.version} - + + org.glassfish.main.core glassfish ${project.version} @@ -138,18 +139,5 @@ - - - maven-jar-plugin - - - - true -+ ../../modules - - - - - diff --git a/appserver/admin/cli/pom.xml b/appserver/admin/cli/pom.xml index 869737d386b..6d7c86494fe 100755 --- a/appserver/admin/cli/pom.xml +++ b/appserver/admin/cli/pom.xml @@ -59,14 +59,7 @@ org.glassfish.admin.cli.AsadminMain - true - custom - ${artifact.artifactId}.${artifact.extension} - ../../modules - - ../bootstrap/glassfish-jul-extension.jar ../bootstrap/glassfish-jdk-extensions.jar ../bootstrap/simple-glassfish-api.jar - diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin index 8f7f88bbe26..77c480ad28a 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin @@ -21,11 +21,12 @@ case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac . "${AS_INSTALL}/config/asenv.conf" + JAVA=java #Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -AS_CLIENT="$AS_INSTALL/lib/client" -exec "$JAVA" "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_CLIENT/appserver-cli.jar" "$@" +ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" +exec "$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/asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat index 5eb640e0a94..50b841054a6 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat @@ -1,33 +1,36 @@ -@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 -call "%~dp0..\glassfish\config\asenv.bat" -if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" -goto run -:UsePath -set JAVA=java -:run -%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\glassfish\lib\client\appserver-cli.jar" %* +@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 +call "%~dp0..\glassfish\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:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" +%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 b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin index 8f9fc3c7e52..5c5d7552c33 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin @@ -17,13 +17,14 @@ # AS_INSTALL=`dirname "$0"`/../glassfish -AS_INSTALL_LIB="$AS_INSTALL/lib" . "${AS_INSTALL}/config/asenv.conf" + JAVA=java #Depends upon Java from ../config/asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 -jar "$AS_INSTALL_LIB/client/appserver-cli.jar" "$@" +ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" +exec "$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/debug-asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin.bat index 619fa9b04cb..dfa747bd657 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 @@ -22,12 +22,16 @@ setlocal ENABLEEXTENSIONS if ERRORLEVEL 0 goto ok echo "Unable to enable extensions" exit /B 1 + :ok call "%~dp0..\glassfish\config\asenv.bat" if "%AS_JAVA%x" == "x" goto UsePath set JAVA="%AS_JAVA%\bin\java" goto run + :UsePath set JAVA=java + :run -%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=9008 -jar "%~dp0..\glassfish\lib\client\appserver-cli.jar" %* +set ASADMIN_CLASSPATH="%AS_INSTALL%/appserver-cli.jar:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" +%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 b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv index dc28eb2beb5..3188778d880 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv @@ -20,17 +20,19 @@ AS_INSTALL=`dirname "$0"`/../glassfish case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac -AS_INSTALL_LIB="$AS_INSTALL/modules" . "${AS_INSTALL}/config/asenv.conf" + JAVA=java #Depends upon Java from ../config/asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi +ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" + start_as_main_process () { if [[ "$@" == "--help" ]] || [[ "$@" == "--help=true" ]] || [[ "$@" == "-?" ]]; then - exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --help + exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain start-domain --help fi # Execute start-domain --dry-run and store the output line by line into an array. @@ -50,7 +52,7 @@ start_as_main_process () { else DRY_RUN_OUTPUT+=("$COM"); fi - done < <(java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --dry-run "$@" || echo "FAILED" ) + done < <("$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain start-domain --dry-run "$@" || echo "FAILED") if [[ x"$DRY_RUN_OUTPUT" == x ]] then echo -n -e "${DRY_RUN_OUTPUT_BEFORE_DUMP}" >&2 @@ -65,7 +67,6 @@ start_as_main_process () { } -ASADMIN_JAR="$AS_INSTALL_LIB/admin-cli.jar" start_as_main_process "$@" # Alternatively, run the following: 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 eb0b1198f6d..65c064aba7b 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat @@ -16,5 +16,21 @@ 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 -java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\glassfish\modules\admin-cli.jar" start-domain --verbose %* +:ok +call "%~dp0..\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:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" +%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 bf6b38f7d09..fee54b1c43f 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/stopserv @@ -17,6 +17,5 @@ # AS_INSTALL=`dirname "$0"`/../glassfish -AS_INSTALL_LIB="$AS_INSTALL/modules" -exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_INSTALL_LIB/admin-cli.jar" stop-domain "$@" +exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_INSTALL/admin-cli.jar" 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 0f7fb7bd7ea..eba403e3a52 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,20 @@ -@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\modules\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 + + +java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\glassfish\admin-cli.jar" stop-domain %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin index ecafdba4123..d363ad4a57b 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin @@ -21,11 +21,12 @@ case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac . "${AS_INSTALL}/config/asenv.conf" + JAVA=java #Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -AS_CLIENT=$AS_INSTALL/lib/client -exec "$JAVA" "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_CLIENT/appserver-cli.jar" "$@" +ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" +exec "$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/glassfish/bin/asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin.bat index 8f33452d7b8..e5a2e53b0ea 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,33 +1,36 @@ -@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 -call "%~dp0..\config\asenv.bat" -if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" -goto run -:UsePath -set JAVA=java -:run -%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\lib\client\appserver-cli.jar" %* +@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 +call "%~dp0..\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:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" +%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/src/main/assembly/glassfish.xml b/appserver/distributions/glassfish/src/main/assembly/glassfish.xml index fd96e2b1848..d71bf761ee1 100644 --- a/appserver/distributions/glassfish/src/main/assembly/glassfish.xml +++ b/appserver/distributions/glassfish/src/main/assembly/glassfish.xml @@ -258,14 +258,15 @@ ${install.dir.name}/glassfish/lib/asadmin - + ${temp.dir} 640 + admin-cli.jar appserver-cli.jar - ${install.dir.name}/glassfish/lib/client + ${install.dir.name}/glassfish @@ -327,7 +328,6 @@ 640 glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar @@ -366,8 +366,12 @@ *.jar - server-mgmt.jar + admin-cli.jar + appserver-cli.jar + cli-optional.jar + cluster-cli.jar osgi-cli-interactive.jar + server-mgmt.jar flashlight-agent.jar org.apache.felix.configadmin.jar org.apache.felix.fileinstall.jar @@ -382,13 +386,9 @@ nucleus-domain.jar appserver-domain.jar glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar - cli-optional.jar - appserver-cli.jar - cluster-cli.jar glassfish-embedded-shell.jar glassfish-embedded-static-shell.jar jakartaee.jar diff --git a/appserver/distributions/web/src/main/assembly/web.xml b/appserver/distributions/web/src/main/assembly/web.xml index 36d8b692eae..a30fa39c3e9 100644 --- a/appserver/distributions/web/src/main/assembly/web.xml +++ b/appserver/distributions/web/src/main/assembly/web.xml @@ -153,14 +153,15 @@ ${install.dir.name}/glassfish/lib/asadmin - + ${temp.dir} 640 + admin-cli.jar appserver-cli.jar - ${install.dir.name}/glassfish/lib/client + ${install.dir.name}/glassfish @@ -201,7 +202,6 @@ 640 glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar @@ -240,8 +240,12 @@ *.jar - server-mgmt.jar + admin-cli.jar + appserver-cli.jar + cli-optional.jar + cluster-cli.jar osgi-cli-interactive.jar + server-mgmt.jar flashlight-agent.jar org.apache.felix.configadmin.jar org.apache.felix.fileinstall.jar @@ -256,13 +260,9 @@ nucleus-domain.jar appserver-domain.jar glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar - cli-optional.jar - appserver-cli.jar - cluster-cli.jar glassfish-embedded-shell.jar glassfish-embedded-static-shell.jar jakartaee.jar diff --git a/nucleus/admin/cli/pom.xml b/nucleus/admin/cli/pom.xml index 2242232dd7b..65f5220b537 100755 --- a/nucleus/admin/cli/pom.xml +++ b/nucleus/admin/cli/pom.xml @@ -258,7 +258,7 @@ com.sun.enterprise.admin.cli.schemadoc - + maven-jar-plugin @@ -266,13 +266,7 @@ com.sun.enterprise.admin.cli.AdminMain - true - custom - ${artifact.artifactId}.${artifact.extension} - - ../lib/bootstrap/glassfish-jul-extension.jar ../lib/bootstrap/glassfish-jdk-extensions.jar ../lib/bootstrap/simple-glassfish-api.jar - 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 b1fb6243bdf..eb4bb13d38e 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 @@ -97,6 +97,7 @@ public class AdminMain { } private final Path installRoot; + private String modulePath; private String classPath; private String className; private String command; @@ -206,10 +207,12 @@ protected final int doMain(String[] args) { cliContainer = new CLIContainer(ecl, extensions, logger); classPath = SmartFile.sanitizePaths(System.getProperty("java.class.path")); + modulePath = SmartFile.sanitize(System.getProperty("jdk.module.path")); className = AdminMain.class.getName(); if (logger.isLoggable(FINER)) { - logger.log(FINER, "Classpath: {0}\nArguments: {1}", new Object[] {classPath, Arrays.toString(args)}); + logger.log(FINER, "ModulePath: {0}\nClasspath: {1}\nArguments: {2}", + new Object[] {modulePath, classPath, Arrays.toString(args)}); } if (args.length == 0) { @@ -278,6 +281,7 @@ public int executeCommand(String[] argv) { po = new ProgramOptions(env); } po.toEnvironment(env); + po.setModulePath(modulePath); po.setClassPath(classPath); po.setClassName(className); po.setCommandName(getCommandName()); diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java index 273f2183be2..2e9b2cdd73d 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/CLIContainer.java @@ -122,7 +122,7 @@ private Set expandExtensions() throws IOException { } } File inst = new File(System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY)); - File adminCliJar = new File(new File(inst, "modules"), "admin-cli.jar"); + File adminCliJar = new File(inst, "admin-cli.jar"); if (!adminCliJar.exists()) { throw new IOException(adminCliJar.getAbsolutePath()); } diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java index 2313a69ff87..023c4704d25 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java @@ -225,6 +225,7 @@ private int executeCommands(BufferedReader reader) throws CommandException, Comm */ po = new ProgramOptions(env); // copy over AsadminMain info + po.setModulePath(programOpts.getModulePath()); po.setClassPath(programOpts.getClassPath()); po.setClassName(programOpts.getClassName()); po.setCommandName(programOpts.getCommandName()); diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java index c14f15a1628..6fb76867d3f 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/ProgramOptions.java @@ -83,15 +83,15 @@ public enum PasswordLocation { private PasswordLocation location; private String commandName; - /* + + private String modulePath; + /** * Information passed in from AsadminMain and used by start-domain. - * XXX - this is somewhat of a kludge but this seems the best place - * to put it for now */ private String classPath; private String className; - /* + /** * Define the meta-options known by the asadmin command. */ static { @@ -153,6 +153,7 @@ public ProgramOptions(ProgramOptions other) { this.options = new ParameterMap(other.options); this.env = other.env; this.password = other.password; + this.modulePath = other.modulePath; this.classPath = other.classPath; this.className = other.className; } @@ -640,6 +641,20 @@ public String getPlainOption(String name) { return options.getOne(name); } + /** + * @return the modulePath + */ + public String getModulePath() { + return modulePath; + } + + /** + * @param modulePath the modulePath to set + */ + public void setModulePath(String modulePath) { + this.modulePath = modulePath; + } + /** * @return the classPath */ diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFEmbeddedLauncher.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFEmbeddedLauncher.java index ca55951ea8b..7ae15c65b95 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFEmbeddedLauncher.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFEmbeddedLauncher.java @@ -68,9 +68,14 @@ void internalLaunch() throws GFLauncherException { } } + @Override + List getMainModulepath() throws GFLauncherException { + return List.of(); + } + @Override List getMainClasspath() throws GFLauncherException { - throw new GFLauncherException("not needed?!?"); + return List.of(); } @Override @@ -172,8 +177,16 @@ void setCommandLine() throws GFLauncherException { cmdLine.clear(); cmdLine.add(javaExe.getPath()); addThreadDump(cmdLine); - cmdLine.add("-cp"); - cmdLine.add(getClasspath()); + if (getModulepath() != null) { + cmdLine.add("--module-path"); + cmdLine.add(getModulepath()); + cmdLine.add("--add-modules"); + cmdLine.add("ALL-MODULE-PATH"); + } + if (getClasspath() != null) { + cmdLine.add("-cp"); + cmdLine.add(getClasspath()); + } addDebug(cmdLine); cmdLine.add(getMainClass()); cmdLine.add("--installdir"); @@ -221,6 +234,7 @@ private void setupFromEnv() throws GFLauncherException { setupDomainDir(); setupJavaDB(); setClasspath(); + setModulepath(); } private void setupDomainDir() throws GFLauncherException { diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java index 362ef704deb..07d821ce2d2 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java @@ -79,10 +79,8 @@ * @author bnevins */ public abstract class GFLauncher { - private static final LocalStringsImpl I18N = new LocalStringsImpl(GFLauncher.class); private static final Logger LOG = System.getLogger(GFLauncher.class.getName(), I18N.getBundle()); - private final static LocalStringsImpl strings = new LocalStringsImpl(GFLauncher.class); /** * Parameters provided by the caller of a launcher, either programmatically (for GF embedded) or as commandline @@ -138,6 +136,7 @@ public abstract class GFLauncher { private Map domainXMLSystemProperty; private String javaExe; + private String modulepath; private String classpath; private String adminFileRealmKeyFile; private boolean secureAdminEnabled; @@ -217,7 +216,7 @@ public final void launch() throws GFLauncherException { throw gfe; } catch (Throwable t) { // hk2 might throw a java.lang.Error - throw new GFLauncherException(strings.get("unknownError", t.getMessage()), t); + throw new GFLauncherException(I18N.get("unknownError", t.getMessage()), t); } finally { GFLauncherLogger.removeLogFileHandler(); } @@ -250,7 +249,7 @@ public final void launchJVM(List cmdsIn) throws GFLauncherException { throw gfe; } catch (Throwable t) { // hk2 might throw a java.lang.Error - throw new GFLauncherException(strings.get("unknownError", t.getMessage()), t); + throw new GFLauncherException(I18N.get("unknownError", t.getMessage()), t); } finally { GFLauncherLogger.removeLogFileHandler(); } @@ -307,6 +306,7 @@ public void setup() throws GFLauncherException, MiniXmlParserException { GFLauncherLogger.addLogFileHandler(logFilename); setJavaExecutable(); + setModulepath(); setClasspath(); setCommandLine(); setJvmOptions(); @@ -390,7 +390,7 @@ public final ProcessStreamDrainer getProcessStreamDrainer() throws GFLauncherExc */ public String getLogFilename() throws GFLauncherException { if (!logFilenameWasFixed) { - throw new GFLauncherException(strings.get("internalError") + " call to getLogFilename() before it has been initialized"); + throw new GFLauncherException(I18N.get("internalError") + " call to getLogFilename() before it has been initialized"); } return logFilename; @@ -540,6 +540,8 @@ final long getStartTime() { return startTime; } + abstract List getMainModulepath() throws GFLauncherException; + abstract List getMainClasspath() throws GFLauncherException; abstract String getMainClass() throws GFLauncherException; @@ -750,8 +752,12 @@ boolean setJavaExecutableIfValid(String filename) { return false; } + void setModulepath() throws GFLauncherException { + setModulepath(GFLauncherUtils.fileListToPathString(getMainModulepath())); + } + void setClasspath() throws GFLauncherException { - List mainCP = getMainClasspath(); // subclass provides this + List mainCP = getMainClasspath(); List envCP = domainXMLjavaConfig.getEnvClasspath(); List sysCP = domainXMLjavaConfig.getSystemClasspath(); List prefixCP = domainXMLjavaConfig.getPrefixClasspath(); @@ -766,15 +772,24 @@ void setClasspath() throws GFLauncherException { all.addAll(sysCP); all.addAll(envCP); all.addAll(suffixCP); - setClasspath(GFLauncherUtils.fileListToPathString(all)); + setClasspath(all.isEmpty() ? null : GFLauncherUtils.fileListToPathString(all)); } void setCommandLine() throws GFLauncherException { List cmdLine = getCommandLine(); cmdLine.clear(); addIgnoreNull(cmdLine, javaExe); - addIgnoreNull(cmdLine, "-cp"); - addIgnoreNull(cmdLine, getClasspath()); + if (getModulepath() != null) { + cmdLine.add("--module-path"); + cmdLine.add(getModulepath()); + cmdLine.add("--add-modules"); + cmdLine.add("ALL-MODULE-PATH"); + } + cmdLine.add("-verbose"); + if (getClasspath() != null) { + addIgnoreNull(cmdLine, "-cp"); + addIgnoreNull(cmdLine, getClasspath()); + } addIgnoreNull(cmdLine, domainXMLjavaConfigDebugOptions); String CLIStartTime = System.getProperty("WALL_CLOCK_START"); @@ -800,7 +815,7 @@ void setCommandLine() throws GFLauncherException { } catch (GFLauncherException gfle) { throw gfle; } catch (Exception e) { - // harmless + throw new GFLauncherException(e); } } @@ -868,7 +883,7 @@ private void setShutdownHook(final Process p) { if (processWhacker == null) { Runtime runtime = Runtime.getRuntime(); - final String msg = strings.get("serverStopped", callerParameters.getType()); + final String msg = I18N.get("serverStopped", callerParameters.getType()); processWhacker = new ProcessWhacker(p, msg); runtime.addShutdownHook(new Thread(processWhacker)); @@ -943,7 +958,7 @@ private String getDeadProcessTrace(Process sp) throws GFLauncherException { int ev = sp.exitValue(); ProcessStreamDrainer psd1 = getProcessStreamDrainer(); String output = psd1.getOutErrString(); - String trace = strings.get("server_process_died", ev, output); + String trace = I18N.get("server_process_died", ev, output); return trace; } catch (IllegalThreadStateException e) { // the glassFishProcess is still running and we are ok @@ -966,7 +981,7 @@ private void setupUpgradeSecurity() throws GFLauncherException { // the actual error is wrapped differently depending on // whether the problem was with the source or target Throwable cause = ioe.getCause() == null ? ioe : ioe.getCause(); - throw new GFLauncherException(strings.get("copy_server_policy_error", cause.getMessage()), ioe); + throw new GFLauncherException(I18N.get("copy_server_policy_error", cause.getMessage()), ioe); } } } @@ -986,7 +1001,7 @@ private void renameOsgiCache() throws GFLauncherException { if (FileUtils.renameFile(osgiCacheDir, backupOsgiCacheDir)) { GFLauncherLogger.fine("rename_osgi_cache_succeeded", osgiCacheDir, backupOsgiCacheDir); } else { - throw new GFLauncherException(strings.get("rename_osgi_cache_failed", osgiCacheDir, backupOsgiCacheDir)); + throw new GFLauncherException(I18N.get("rename_osgi_cache_failed", osgiCacheDir, backupOsgiCacheDir)); } } } @@ -1029,7 +1044,7 @@ private String getMonitoringAgentJvmOptionString() throws GFLauncherException { if (flashlightJarFile.isFile()) { return "javaagent:" + getCleanPath(flashlightJarFile); } else { - String msg = strings.get("no_flashlight_agent", flashlightJarFile); + String msg = I18N.get("no_flashlight_agent", flashlightJarFile); GFLauncherLogger.warning(GFLauncherLogger.NO_FLASHLIGHT_AGENT, flashlightJarFile); throw new GFLauncherException(msg); } @@ -1055,6 +1070,14 @@ void setClasspath(String s) { classpath = s; } + String getModulepath() { + return modulepath; + } + + void setModulepath(String modulepath) { + this.modulepath = modulepath; + } + private List propsToJvmOptions(Map map) { List ss = new ArrayList<>(); Set> entries = map.entrySet(); @@ -1107,7 +1130,7 @@ private void closeStandardStreamsMaybe() { sname = callerParameters.getInstanceName(); } - System.out.println(strings.get("ssh", sname)); + System.out.println(I18N.get("ssh", sname)); try { System.in.close(); } catch (Exception e) { // ignore diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java index f888ac40e1d..8d613826654 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherInfo.java @@ -44,12 +44,12 @@ public class GFLauncherInfo { private final static String CONFIG_FILENAME = "domain.xml"; // Set by contructor - private RuntimeType type; + private final RuntimeType type; /** * Incoming arguments from caller */ - private List argsRaw = new ArrayList<>(); + private final List argsRaw = new ArrayList<>(); /** * Intermediate map form of arguments from caller @@ -352,8 +352,8 @@ public Map getArgs() throws GFLauncherException { return map; } - public void setRespawnInfo(String classname, String classpath, String[] args) { - respawnInfo = new RespawnInfo(classname, classpath, args); + public void setRespawnInfo(String classname, String modulePath, String classpath, String[] args) { + respawnInfo = new RespawnInfo(classname, modulePath, classpath, args); } /** diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherNativeHelper.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherNativeHelper.java index 559ad70f3f2..744cc881e71 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherNativeHelper.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncherNativeHelper.java @@ -85,9 +85,11 @@ List getCommands() { // * all duplicate directories are removed // * junk is removed, e.g. ":xxx::yy::::::" goes to "xxx:yy" - String finalPathString = GFLauncherUtils.fileListToPathString(GFLauncherUtils.stringToFiles(sb.toString())); - String nativeCommand = "-D" + JAVA_NATIVE_SYSPROP_NAME + "=" + finalPathString; - list.add(nativeCommand); + List files = GFLauncherUtils.stringToFiles(sb.toString()); + if (!files.isEmpty()) { + String nativeCommand = "-D" + JAVA_NATIVE_SYSPROP_NAME + "=" + GFLauncherUtils.fileListToPathString(files); + list.add(nativeCommand); + } return list; } 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 4789bfa4bd4..d5ad1ca10f9 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 @@ -21,10 +21,7 @@ import java.io.File; import java.nio.file.Path; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; @@ -64,24 +61,13 @@ void internalLaunch() throws GFLauncherException { @Override List getMainClasspath() throws GFLauncherException { - Path dir = Path.of(getEnvProps().get(INSTALL_ROOT_PROPERTY), "lib", "bootstrap"); - List classpath = Stream - .of("glassfish.jar", "glassfish-jul-extension.jar", "glassfish-jdk-extensions.jar", - "simple-glassfish-api.jar") - .map(dir::resolve).map(Path::toFile).map(SmartFile::sanitize).collect(Collectors.toList()); - if (isFakeLaunch()) { - return classpath; - } - List missing = new ArrayList<>(classpath.size()); - for (File file : classpath) { - if (!file.exists()) { - missing.add(file); - } - } - if (missing.isEmpty()) { - return classpath; - } - throw new GFLauncherException("nobootjar", missing); + return List.of(); + } + + @Override + List getMainModulepath() throws GFLauncherException { + return List + .of(SmartFile.sanitize(Path.of(getEnvProps().get(INSTALL_ROOT_PROPERTY), "lib", "bootstrap").toFile())); } @Override diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/RespawnInfo.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/RespawnInfo.java index fb9d0d99b11..2d66f475406 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/RespawnInfo.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/RespawnInfo.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -24,28 +25,31 @@ */ class RespawnInfo { - private String classname; - private String classpath; - private String[] args; + private final String classname; + private final String classpath; + private final String modulepath; + private final String[] args; private static final String PREFIX = "-asadmin-"; private static final String SEPARATOR = ",,,"; - RespawnInfo(String cn, String cp, String[] a) { - classname = cn; - classpath = cp; + RespawnInfo(String cn, String modulepath, String cp, String[] args) { + this.classname = cn; + this.classpath = cp; + this.modulepath = modulepath; - if (a == null) { - a = new String[0]; + if (args == null) { + args = new String[0]; } - args = a; + this.args = args; } void put(Map map) throws GFLauncherException { validate(); map.put(PREFIX + "classname", classname); map.put(PREFIX + "classpath", classpath); + map.put(PREFIX + "modulepath", modulepath); putArgs(map); } diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java index 0449e383d67..f3f08a664b6 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/StartDomainCommand.java @@ -220,7 +220,7 @@ public void createLauncher() throws GFLauncherException, MiniXmlParserException launchParameters.setWatchdog(watchdog); launchParameters.setDropInterruptedCommands(drop_interrupted_commands); - launchParameters.setRespawnInfo(programOpts.getClassName(), programOpts.getClassPath(), respawnArgs()); + launchParameters.setRespawnInfo(programOpts.getClassName(), programOpts.getModulePath(), programOpts.getClassPath(), respawnArgs()); glassFishLauncher.setup(); } diff --git a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/NodeUtils.java b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/NodeUtils.java index cbaf592102f..1192347a477 100644 --- a/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/NodeUtils.java +++ b/nucleus/cluster/admin/src/main/java/com/sun/enterprise/v3/admin/cluster/NodeUtils.java @@ -71,7 +71,7 @@ public class NodeUtils { static final String PARAM_TYPE = "type"; static final String PARAM_INSTALL = "install"; public static final String PARAM_WINDOWS_DOMAIN = "windowsdomain"; - static final String LANDMARK_FILE = "glassfish/modules/admin-cli.jar"; + static final String LANDMARK_FILE = "glassfish/admin-cli.jar"; private static final String NL = System.lineSeparator(); private TokenResolver resolver = null; private Logger logger = null; diff --git a/nucleus/cluster/cli/pom.xml b/nucleus/cluster/cli/pom.xml index 9c492ad597f..a155cf0a0de 100755 --- a/nucleus/cluster/cli/pom.xml +++ b/nucleus/cluster/cli/pom.xml @@ -124,23 +124,5 @@ - - - maven-jar-plugin - - - - - ../../modules/cluster-common.jar - ../../modules/cluster-ssh.jar - ../../modules/config-api.jar - ../../modules/internal-api.jar - ../../modules/config-types.jar - ../../modules/shoal-gms-impl.jar - - - - - diff --git a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/StartLocalInstanceCommand.java b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/StartLocalInstanceCommand.java index 1e1cad3d65a..3d609a394ca 100644 --- a/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/StartLocalInstanceCommand.java +++ b/nucleus/cluster/cli/src/main/java/com/sun/enterprise/admin/cli/cluster/StartLocalInstanceCommand.java @@ -195,20 +195,18 @@ protected int executeCommand() throws CommandException { * Sets the launcher and info fields. */ @Override - public void createLauncher() - throws GFLauncherException, MiniXmlParserException { - setLauncher(GFLauncherFactory.getInstance(getType())); - setInfo(getLauncher().getInfo()); - getInfo().setInstanceName(instanceName); - getInfo().setInstanceRootDir(instanceDir); - getInfo().setVerbose(verbose); - getInfo().setWatchdog(watchdog); - getInfo().setDebug(debug); - getInfo().setRespawnInfo(programOpts.getClassName(), - programOpts.getClassPath(), - respawnArgs()); - - getLauncher().setup(); + public void createLauncher() throws GFLauncherException, MiniXmlParserException { + setLauncher(GFLauncherFactory.getInstance(getType())); + setInfo(getLauncher().getInfo()); + getInfo().setInstanceName(instanceName); + getInfo().setInstanceRootDir(instanceDir); + getInfo().setVerbose(verbose); + getInfo().setWatchdog(watchdog); + getInfo().setDebug(debug); + getInfo().setRespawnInfo(programOpts.getClassName(), programOpts.getModulePath(), programOpts.getClassPath(), + respawnArgs()); + + getLauncher().setup(); } /** diff --git a/nucleus/cluster/gms-adapter/pom.xml b/nucleus/cluster/gms-adapter/pom.xml index 4d5682a121a..e01ae687394 100644 --- a/nucleus/cluster/gms-adapter/pom.xml +++ b/nucleus/cluster/gms-adapter/pom.xml @@ -93,16 +93,6 @@ - - maven-jar-plugin - - - - shoal-gms-impl.jar - - - - diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/JavaClassRunner.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/JavaClassRunner.java index 4a48cf172ee..76d47217789 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/JavaClassRunner.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/process/JavaClassRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -48,14 +48,14 @@ public class JavaClassRunner { } final Path javaroot = Path.of(System.getProperty("java.home")); javaExecutable = javaroot.resolve("bin").resolve(javaName); - } - - public JavaClassRunner(String classpath, String[] sysprops, String classname, String[] args) throws IOException { - if (javaExecutable == null) { - throw new IOException("Can not find a jvm"); + if (!javaExecutable.toFile().canExecute()) { + throw new Error(javaExecutable + " is not an existing executable file."); } + } - if (!isEmpty(classname)) { + public JavaClassRunner(String modulepath, String classpath, String[] sysprops, String classname, String[] args) + throws IOException { + if (!isSet(classname)) { throw new IllegalArgumentException("classname was null"); } @@ -64,7 +64,13 @@ public JavaClassRunner(String classpath, String[] sysprops, String classname, St cmdline.add("nohup"); } cmdline.add(javaExecutable.toString()); - if (isEmpty(classpath)) { + if (isSet(modulepath)) { + cmdline.add("--module-path"); + cmdline.add(modulepath); + cmdline.add("--add-modules"); + cmdline.add("ALL-MODULE-PATH"); + } + if (isSet(classpath)) { cmdline.add("-cp"); cmdline.add(classpath); } @@ -97,7 +103,7 @@ public void run() throws IOException { } } - private boolean isEmpty(String s) { + private boolean isSet(String s) { return s != null && !s.isEmpty(); } } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java index 129a6617023..eb44ac350d9 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java @@ -105,6 +105,7 @@ private static Properties initProperties(String[] args) { map.put("default", args[i]); } } + // no sense doing this if we were started by CLI... if (!wasStartedByCLI(map)) { for (int i = 0; i < args.length; i++) { if (i > 0) { @@ -113,9 +114,9 @@ private static Properties initProperties(String[] args) { sb.append(args[i]); } map.setProperty(BootstrapKeys.ORIGINAL_ARGS, sb.toString()); - // no sense doing this if we were started by CLI... map.setProperty(BootstrapKeys.ORIGINAL_CP, System.getProperty("java.class.path")); map.setProperty(BootstrapKeys.ORIGINAL_CN, GlassFishMain.class.getName()); + map.setProperty(BootstrapKeys.ORIGINAL_MP, System.getProperty("jdk.module.path")); } return map; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java index e6f2331ea14..1eb2182de0a 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/BootstrapKeys.java @@ -26,10 +26,12 @@ public final class BootstrapKeys { /** bundle containing module startup */ public static final String GF_KERNEL = "org.glassfish.core.kernel"; + public static final String ASADMIN_MP = "-asadmin-modulepath"; public static final String ASADMIN_CP = "-asadmin-classpath"; public static final String ASADMIN_CN = "-asadmin-classname"; public static final String ASADMIN_ARGS = "-asadmin-args"; + public static final String ORIGINAL_MP = "-startup-modulepath"; public static final String ORIGINAL_CP = "-startup-classpath"; public static final String ORIGINAL_CN = "-startup-classname"; public static final String ORIGINAL_ARGS = "-startup-args"; diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/GlassfishOsgiBootstrapClassLoader.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/GlassfishOsgiBootstrapClassLoader.java index 73548358a33..24b8ad1a784 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/GlassfishOsgiBootstrapClassLoader.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/launch/GlassfishOsgiBootstrapClassLoader.java @@ -72,8 +72,8 @@ public void launchGlassFishServer(final Properties properties) { private static URL[] createUrls(final File glassfishDir) throws IOException { final List urls = new ArrayList<>(); - final File libDir = glassfishDir.toPath().resolve(Path.of("lib", "bootstrap")).toFile(); - urls.add(getURL(libDir, "glassfish-osgi-bootstrap")); + final File moduleDir = glassfishDir.toPath().resolve(Path.of("modules")).toFile(); + urls.add(getURL(moduleDir, "glassfish-osgi-bootstrap")); return urls.toArray(URL[]::new); } diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java index 5eb65d270f2..90c9f317e17 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/RestartServer.java @@ -52,11 +52,13 @@ public class RestartServer { private Properties props; private Logger logger; private boolean verbose; + private String modulepath; private String classpath; private String classname; private String argsString; private String[] args; private String serverName = ""; + private static final LocalStringsImpl strings = new LocalStringsImpl(RestartServer.class); private static final String magicProperty = "-DAS_RESTART=" + ProcessHandle.current().pid(); private static final String[] normalProps = { magicProperty }; @@ -151,7 +153,7 @@ private void doReincarnation() throws RDCException { sysProps = normalProps; } - JavaClassRunner runner = new JavaClassRunner(classpath, sysProps, classname, args); + JavaClassRunner runner = new JavaClassRunner(modulepath, classpath, sysProps, classname, args); runner.run(); } catch (Exception e) { throw new RDCException(e); @@ -159,6 +161,7 @@ private void doReincarnation() throws RDCException { } private boolean setupReincarnationWithAsadmin() throws RDCException { + modulepath = props.getProperty(BootstrapKeys.ASADMIN_MP); classpath = props.getProperty(BootstrapKeys.ASADMIN_CP); classname = props.getProperty(BootstrapKeys.ASADMIN_CN); argsString = props.getProperty(BootstrapKeys.ASADMIN_ARGS); @@ -167,7 +170,7 @@ private boolean setupReincarnationWithAsadmin() throws RDCException { } private boolean setupReincarnationWithOther() throws RDCException { - + modulepath = props.getProperty(BootstrapKeys.ORIGINAL_MP); classpath = props.getProperty(BootstrapKeys.ORIGINAL_CP); classname = props.getProperty(BootstrapKeys.ORIGINAL_CN); argsString = props.getProperty(BootstrapKeys.ORIGINAL_ARGS); @@ -283,7 +286,7 @@ private void stripOperandFromArgs() { } private boolean ok(String s) { - return s != null && s.length() > 0; + return s != null && !s.isEmpty(); } // We use this simply to tell the difference between fatal errors and other diff --git a/nucleus/distributions/atomic/src/main/assembly/atomic.xml b/nucleus/distributions/atomic/src/main/assembly/atomic.xml index bd585499e9a..572461982c9 100644 --- a/nucleus/distributions/atomic/src/main/assembly/atomic.xml +++ b/nucleus/distributions/atomic/src/main/assembly/atomic.xml @@ -75,7 +75,6 @@ ${temp.dir} glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar @@ -83,6 +82,15 @@ ${install.dir.name}/lib/bootstrap + + + ${temp.dir} + + admin-cli.jar + + ${install.dir.name} + + ${temp.dir} @@ -131,6 +139,7 @@ *.jar + admin-cli.jar server-mgmt.jar osgi-cli-interactive.jar flashlight-agent.jar @@ -145,7 +154,6 @@ felix.jar nucleus-domain.jar glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin index 9cfd62ed4c4..afd2a85244a 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin @@ -21,9 +21,12 @@ case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac . "${AS_INSTALL}/config/asenv.conf" + JAVA=java #Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" -Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager -jar "$AS_INSTALL/modules/admin-cli.jar" "$@" + +ASADMIN_CLASSPATH="$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" +exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain "$@" 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 1e628a33f68..84ea758a195 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat @@ -1,31 +1,36 @@ -@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 -call "%~dp0..\config\asenv.bat" -if "%AS_JAVA%x" == "x" goto UsePath -set JAVA="%AS_JAVA%\bin\java" -goto run -:UsePath -set JAVA=java -:run -%JAVA% "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%AS_INSTALL%\modules\admin-cli.jar" %* +@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 +call "%~dp0..\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%/admin-cli.jar:%AS_INSTALL%/modules/*" +%JAVA% "%ASADMIN_JVM_OPTIONS%" --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" com.sun.enterprise.admin.cli.AdminMain %* diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv index b729e5ba6a9..7afb22a1065 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv @@ -20,17 +20,19 @@ AS_INSTALL=`dirname "$0"`/.. case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac -AS_INSTALL_LIB="$AS_INSTALL/modules" . "${AS_INSTALL}/config/asenv.conf" + JAVA=java #Depends upon Java from ../config/asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi +ASADMIN_CLASSPATH="$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" + start_as_main_process () { if [[ "$@" == "--help" ]] || [[ "$@" == "--help=true" ]] || [[ "$@" == "-?" ]]; then - exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --help + exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain start-domain --help fi # Execute start-domain --dry-run and store the output line by line into an array. @@ -50,7 +52,7 @@ start_as_main_process () { else DRY_RUN_OUTPUT+=("$COM"); fi - done < <(java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$ASADMIN_JAR" start-domain --dry-run "$@" || echo "FAILED" ) + done < <("$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain start-domain --dry-run "$@" || echo "FAILED") if [[ x"$DRY_RUN_OUTPUT" == x ]] then echo -n -e "${DRY_RUN_OUTPUT_BEFORE_DUMP}" >&2 @@ -65,7 +67,6 @@ start_as_main_process () { } -ASADMIN_JAR="$AS_INSTALL_LIB/admin-cli.jar" start_as_main_process "$@" # Alternatively, run the following: 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 c83f7ce9b01..b50ca87989d 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat @@ -16,5 +16,21 @@ 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 -java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\modules\admin-cli.jar" start-domain --verbose %* +:ok +call "%~dp0..\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%/admin-cli.jar:%AS_INSTALL%/modules/*" +%JAVA% "%ASADMIN_JVM_OPTIONS%" --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" com.sun.enterprise.admin.cli.AdminMain start-domain --verbose %* diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv index d6b9421a3ee..02014ede1e0 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv @@ -17,6 +17,5 @@ # AS_INSTALL=`dirname "$0"`/.. -AS_INSTALL_LIB="$AS_INSTALL/modules" -exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_INSTALL_LIB/admin-cli.jar" stop-domain "$@" +exec java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "$AS_INSTALL/admin-cli.jar" stop-domain "$@" diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat index 7a506976488..0f10d2bfad9 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/stopserv.bat @@ -1,20 +1,20 @@ -@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..\modules\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 + + +java "-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -jar "%~dp0..\admin-cli.jar" stop-domain %* 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 20642050f73..d43288cb854 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat @@ -45,3 +45,6 @@ set AS_INSTALL=.. set AS_DEF_DOMAINS_PATH=..\domains set AS_DEF_NODES_PATH=..\nodes set AS_DERBY_INSTALL=..\..\javadb + +set ASADMIN_MODULEPATH="%AS_INSTALL%/lib/bootstrap" +set ASADMIN_JVM_OPTIONS="-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf index 53793cb53cb..a7052fe9950 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf @@ -44,3 +44,6 @@ AS_INSTALL="${AS_INSTALL:-..}" AS_DEF_DOMAINS_PATH="${AS_DEF_DOMAINS_PATH:-../domains}" AS_DEF_NODES_PATH="${AS_DEF_NODES_PATH:-../nodes}" AS_DERBY_INSTALL="${AS_DERBY_INSTALL:-../../javadb}" + +ASADMIN_MODULEPATH="${AS_INSTALL}/lib/bootstrap" +ASADMIN_JVM_OPTIONS="-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties b/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties index bd5744cacc4..20a74f553a3 100755 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/osgi.properties @@ -100,7 +100,7 @@ com.sun.enterprise.hk2.cacheDir=${org.osgi.framework.storage} # Then we autostart GlassFish core bundles followed by optional services. # The reason for using installRootURI is to make sure any char like white space is properly encoded. glassfish.osgi.auto.install=\ - ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar \ + ${com.sun.aas.installRootURI}modules/glassfish-osgi-bootstrap.jar \ ${com.sun.aas.installRootURI}modules/osgi-resource-locator.jar \ ${com.sun.aas.installRootURI}modules/ \ ${com.sun.aas.installRootURI}modules/autostart/ @@ -131,7 +131,7 @@ hk2.bundles=\ core.bundles=\ ${hk2.bundles} \ - ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar + ${com.sun.aas.installRootURI}modules/glassfish-osgi-bootstrap.jar autostart.bundles=${com.sun.aas.installRootURI}modules/autostart/ diff --git a/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml b/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml index ae7d1e9f305..b689e216c5d 100644 --- a/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml +++ b/nucleus/distributions/nucleus/src/main/assembly/nucleus-new.xml @@ -65,8 +65,16 @@ ${install.dir.name}/lib/schemas - + + + ${temp.dir} + + admin-cli.jar + + ${install.dir.name} + + ${temp.dir} @@ -100,7 +108,6 @@ ${temp.dir} glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar @@ -136,6 +143,7 @@ *.jar + admin-cli.jar server-mgmt.jar osgi-cli-interactive.jar flashlight-agent.jar @@ -148,7 +156,6 @@ org.osgi.util.function.jar org.osgi.util.promise.jar glassfish.jar - glassfish-osgi-bootstrap.jar glassfish-jdk-extensions.jar glassfish-jul-extension.jar simple-glassfish-api.jar diff --git a/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties b/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties index bd5744cacc4..20a74f553a3 100755 --- a/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties +++ b/nucleus/osgi-platforms/felix/src/main/resources/config/osgi.properties @@ -100,7 +100,7 @@ com.sun.enterprise.hk2.cacheDir=${org.osgi.framework.storage} # Then we autostart GlassFish core bundles followed by optional services. # The reason for using installRootURI is to make sure any char like white space is properly encoded. glassfish.osgi.auto.install=\ - ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar \ + ${com.sun.aas.installRootURI}modules/glassfish-osgi-bootstrap.jar \ ${com.sun.aas.installRootURI}modules/osgi-resource-locator.jar \ ${com.sun.aas.installRootURI}modules/ \ ${com.sun.aas.installRootURI}modules/autostart/ @@ -131,7 +131,7 @@ hk2.bundles=\ core.bundles=\ ${hk2.bundles} \ - ${com.sun.aas.installRootURI}lib/bootstrap/glassfish-osgi-bootstrap.jar + ${com.sun.aas.installRootURI}modules/glassfish-osgi-bootstrap.jar autostart.bundles=${com.sun.aas.installRootURI}modules/autostart/ diff --git a/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java b/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java index 2dc210fe511..24029925027 100644 --- a/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java +++ b/nucleus/osgi-platforms/osgi-cli-interactive/src/main/java/org/glassfish/osgi/cli/interactive/LocalOSGiShellCommand.java @@ -357,6 +357,7 @@ private int executeCommands(LineReader reader) throws CommandException { */ final ProgramOptions programOptions = new ProgramOptions(env); // copy over AsadminMain info + programOptions.setModulePath(programOpts.getModulePath()); programOptions.setClassPath(programOpts.getClassPath()); programOptions.setClassName(programOpts.getClassName()); // remove the old one and replace it From cf9be1a23277379187190eafc99fe5b832eb44e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Mon, 14 Oct 2024 19:59:17 +0200 Subject: [PATCH 25/38] Fixed bootstrap's module-info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - felix framework is supplied by other jpms modules which don't overlap osgi.core - logging annotations are used just by maven compiler plugin and they are not used in runtime. Signed-off-by: David Matějček --- nucleus/core/bootstrap/src/main/java/module-info.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nucleus/core/bootstrap/src/main/java/module-info.java b/nucleus/core/bootstrap/src/main/java/module-info.java index 8b5b5fc74f2..d97f4ba8049 100644 --- a/nucleus/core/bootstrap/src/main/java/module-info.java +++ b/nucleus/core/bootstrap/src/main/java/module-info.java @@ -22,8 +22,8 @@ requires java.base; requires java.logging; - requires org.apache.felix.framework; - requires org.glassfish.annotation.processing.logging; + requires static org.apache.felix.framework; + requires static org.glassfish.annotation.processing.logging; requires org.glassfish.main.jdke; exports com.sun.enterprise.glassfish.bootstrap.cfg; From 14b4e1a2cac75f40baae2b8c372cf55a4b6df026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Wed, 16 Oct 2024 22:24:05 +0200 Subject: [PATCH 26/38] Fixed classpaths and env variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AS_INSTALL must be absolute env option despite it can be also autodetected, but then it would not be possible to use it in scripts (chicken-egg problem). - classpaths in manifests sometimes don't work on JDK11-17, not sure why exactly. Signed-off-by: David Matějček --- .../admin/cli/optional/DatabaseCommand.java | 16 +- .../cli/optional/StartDatabaseCommand.java | 22 +- .../cli/optional/StopDatabaseCommand.java | 24 +- .../org/glassfish/admin/cli/AsadminMain.java | 17 -- .../appclient/client/acc-standalone/pom.xml | 21 -- .../packageappclient/PackageAppClient.java | 75 ++---- .../appclient/client/CLIBootstrap.java | 13 +- .../client/acc/ACCStartupContext.java | 34 ++- .../appclient/client/CLIBootstrapTest.java | 4 +- .../main/resources/glassfish/bin/appclient | 18 +- .../resources/glassfish/bin/appclient.bat | 21 +- .../resources/glassfish/bin/package-appclient | 12 +- .../glassfish/bin/package-appclient.bat | 11 +- .../src/main/resources/bin/asadmin | 7 +- .../src/main/resources/bin/asadmin.bat | 7 +- .../src/main/resources/bin/debug-asadmin | 8 +- .../src/main/resources/bin/debug-asadmin.bat | 8 +- .../src/main/resources/bin/startserv | 9 +- .../src/main/resources/bin/startserv.bat | 7 +- .../src/main/resources/glassfish/bin/asadmin | 7 +- .../main/resources/glassfish/bin/asadmin.bat | 7 +- .../main/itest/tools/asadmin/StartServ.java | 6 + .../main/admin/test/StartServITest.java | 2 + .../tests/appserv-tests/config/jws-appclient | 10 +- .../sun/enterprise/admin/cli/AdminMain.java | 36 ++- .../admin/cli/DirectoryClassLoader.java | 9 +- .../enterprise/admin/launcher/GFLauncher.java | 1 - .../glassfish/ASenvPropertyReader.java | 254 +----------------- .../universal/glassfish/GFLauncherUtils.java | 138 ++++------ .../glassfish/ASenvPropertyReaderTest.java | 4 +- .../src/main/java/module-info.java | 1 + .../main/jdke/props/EnvToPropsConverter.java | 116 ++++++++ .../osgi/EmbeddedOSGiGlassFishRuntime.java | 25 +- .../glassfish/bootstrap/GlassFishMain.java | 21 +- .../glassfish/bootstrap/cfg/AsenvConf.java | 108 -------- .../bootstrap/src/main/java/module-info.java | 4 +- .../bootstrap/cfg/AsenvConfTest.java | 79 ------ .../server/CommonClassLoaderServiceImpl.java | 3 +- .../glassfish/kernel/KernelLoggerInfo.java | 2 +- .../src/main/resources/bin/nadmin | 6 +- .../src/main/resources/bin/nadmin.bat | 6 +- .../src/main/resources/bin/startserv | 9 +- .../src/main/resources/bin/startserv.bat | 6 +- .../src/main/resources/config/asenv.bat | 17 +- .../src/main/resources/config/asenv.conf | 19 +- 45 files changed, 450 insertions(+), 780 deletions(-) create mode 100644 nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/props/EnvToPropsConverter.java delete mode 100644 nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java delete mode 100644 nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConfTest.java diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java index 3114b47658a..7d9614edc29 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/DatabaseCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Contributors to the Eclipse Foundation + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -55,6 +55,7 @@ public abstract class DatabaseCommand extends CLICommand { @Param(name = "dbport", optional = true, defaultValue = DB_PORT_DEFAULT) protected String dbPort; + protected final ClassPathBuilder modulepath = new ClassPathBuilder(); protected final ClassPathBuilder sClasspath = new ClassPathBuilder(); protected final ClassPathBuilder sDatabaseClasspath = new ClassPathBuilder(); @@ -80,7 +81,8 @@ protected void prepareProcessExecutor() throws Exception { dbLocation = new File(getSystemProperty(DERBY_ROOT_PROP_NAME)); checkIfDbInstalled(dbLocation); - sClasspath.add(new File(installRoot, "lib/asadmin/cli-optional.jar")); + modulepath.addAll(new File(installRoot, "lib/bootstrap"), f -> f.isFile()); + sClasspath.add(new File(installRoot, System.getProperty("java.class.path"))); sDatabaseClasspath.add(dbLocation, "lib", "derby.jar") .add(dbLocation, "lib", "derbyshared.jar") .add(dbLocation, "lib", "derbytools.jar") @@ -133,8 +135,11 @@ protected String[] pingDatabaseCmd(boolean bRedirect) throws Exception { getJavaExe().toString(), "-Djava.library.path=" + installRoot + File.separator + "lib", "-Dderby.storage.fileSyncTransactionLog=True", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + File.pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "ping", dbHost, dbPort, Boolean.toString(bRedirect) }; @@ -144,8 +149,11 @@ protected String[] pingDatabaseCmd(boolean bRedirect) throws Exception { return new String[] { getJavaExe().toString(), "-Djava.library.path=" + installRoot + File.separator + "lib", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + File.pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "ping", dbHost, dbPort, Boolean.toString(bRedirect) }; diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java index 841dc9b2667..d9910d30a87 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StartDatabaseCommand.java @@ -92,6 +92,11 @@ public String[] startDatabaseCmd() { cmd.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:9011"); } + cmd.add("--module-path"); + cmd.add(modulepath.toString()); + cmd.add("--add-modules"); + cmd.add("ALL-MODULE-PATH"); + cmd.add("-cp"); cmd.add(sClasspath + pathSeparator + sDatabaseClasspath); if (jvmoptions != null) { @@ -117,8 +122,11 @@ public String[] sysinfoCmd() throws Exception { javaHome + separator + "bin" + separator + "java", "-Djava.library.path=" + installRoot + separator + "lib", "-Dderby.storage.fileSyncTransactionLog=True", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "sysinfo", dbHost, dbPort, "false" }; @@ -127,8 +135,11 @@ public String[] sysinfoCmd() throws Exception { return new String[] { javaHome + separator + "bin" + separator + "java", "-Djava.library.path=" + installRoot + separator + "lib", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "sysinfo", dbHost, dbPort, "false" }; @@ -144,6 +155,11 @@ public String[] executeSQLCmd() throws Exception { cmd.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:9012"); } + cmd.add("--module-path"); + cmd.add(modulepath.toString()); + cmd.add("--add-modules"); + cmd.add("ALL-MODULE-PATH"); + cmd.add("-cp"); cmd.add(sClasspath + pathSeparator + sDatabaseClasspath); @@ -158,7 +174,7 @@ public String[] executeSQLCmd() throws Exception { cmd.add(dbPassword); } - return cmd.toArray(new String[cmd.size()]); + return cmd.toArray(String[]::new); } /** diff --git a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java index f80e40100ae..ae05ed152e7 100644 --- a/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java +++ b/appserver/admin/cli-optional/src/main/java/com/sun/enterprise/admin/cli/optional/StopDatabaseCommand.java @@ -81,8 +81,11 @@ public String[] stopDatabaseCmd() throws Exception { javaHome + separator + "bin" + separator + "java", "-Djava.library.path=" + installRoot + separator + "lib", "-Dderby.storage.fileSyncTransactionLog=True", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "shutdown", dbHost, dbPort, "false" }; @@ -91,8 +94,11 @@ public String[] stopDatabaseCmd() throws Exception { return new String[] { javaHome + separator + "bin" + separator + "java", "-Djava.library.path=" + installRoot + separator + "lib", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "shutdown", dbHost, dbPort, "false" }; @@ -100,10 +106,13 @@ public String[] stopDatabaseCmd() throws Exception { if (OS.isDarwin()) { return new String[] { javaHome + separator + "bin" + separator + "java", - "-Djava.library.path=" + installRoot + separator + - "lib", "-Dderby.storage.fileSyncTransactionLog=True", + "-Djava.library.path=" + installRoot + separator + "lib", + "-Dderby.storage.fileSyncTransactionLog=True", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "shutdown", dbHost, dbPort, "false", dbUser, dbPassword }; @@ -112,8 +121,11 @@ public String[] stopDatabaseCmd() throws Exception { return new String[] { javaHome + separator + "bin" + separator + "java", "-Djava.library.path=" + installRoot + separator + "lib", + "--module-path", + modulepath.toString(), + "--add-modules", + "ALL-MODULE-PATH", "-cp", sClasspath + pathSeparator + sDatabaseClasspath, - "com.sun.enterprise.admin.cli.optional.DerbyControl", "shutdown", dbHost, dbPort, "false", dbUser, dbPassword }; diff --git a/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java b/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java index a750dee6b47..f200e8d50b2 100644 --- a/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java +++ b/appserver/admin/cli/src/main/java/org/glassfish/admin/cli/AsadminMain.java @@ -20,9 +20,6 @@ import com.sun.enterprise.admin.cli.AdminMain; import com.sun.enterprise.admin.cli.Environment; -import java.io.File; -import java.util.Set; - /** * The asadmin main program. */ @@ -47,18 +44,4 @@ public static void main(String[] args) { protected String getCommandName() { return "asadmin"; } - - - @Override - protected Set getExtensions() { - final Set locations = super.getExtensions(); - // FIXME: Identify just modules containing admin commands and their dependencies. - // Then split those jar files to server and cli part. - // Then cli parts should be under lib/admin - // And server parts under modules. - // They should not depend on each other. - final File modules = getInstallRoot().resolve("modules").toFile(); - locations.add(modules); - return locations; - } } diff --git a/appserver/appclient/client/acc-standalone/pom.xml b/appserver/appclient/client/acc-standalone/pom.xml index 0218caad3ce..a190a48bd02 100755 --- a/appserver/appclient/client/acc-standalone/pom.xml +++ b/appserver/appclient/client/acc-standalone/pom.xml @@ -53,22 +53,6 @@ - - ../lib - ${path.lib}/install/applications - ${path.lib}/appclient - ../../javadb/lib - ../../mq/lib - - ${path.derby}/derby.jar ${path.derby}/derbyclient.jar ${path.derby}/derbynet.jar ${path.derby}/derbytools.jar ${path.derby}/derbyrun.jar - ${path.apps}/jaxr-ra/jaxr-ra.jar - ${path.apps}/__ds_jdbc_ra/jdbc-ra-ds.jar ${path.apps}/__cp_jdbc_ra/jdbc-ra-cp.jar ${path.apps}/__xa_jdbc_ra/jdbc-ra-xa.jar ${path.apps}/__dm_jdbc_ra/jdbc-ra-dm.jar - ${path.mq}/imq.jar ${path.mq}/imqadmin.jar ${path.mq}/imqutil.jar ${path.mq}/fscontext.jar ${path.apps}/jmsra/imqjmsra.jar - ${path.appclient}/weld-se-shaded.jar - - ${path.lib}/bootstrap/glassfish-jul-extension.jar ${classpath.mq} ${classpath.derby} ${classpath.jaxrra} ${classpath.jdbcra} ${classpath.weld} - - @@ -133,16 +117,11 @@ org.glassfish.appclient.client.AppClientFacade org.glassfish.appclient.client.acc - true - ../modules/ - custom - ${artifact.artifactId}${dashClassifier?}.${artifact.extension} ${project.build.outputDirectory}/META-INF/MANIFEST.MF org.glassfish.appclient.client.acc.agent.AppClientContainerAgent true - ${classpath.additions} diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java index d431490905a..43f8c538b16 100644 --- a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java @@ -68,7 +68,6 @@ public class PackageAppClient { private final static String GLASSFISH_LIB = "glassfish/lib"; private final static String GLASSFISH_BIN = "glassfish/bin"; private final static String GLASSFISH_CONFIG = "glassfish/config"; - private final static String MODULES_ENDORSED_DIR = "glassfish/modules/endorsed"; private final static String MQ_LIB = "mq/lib"; private final static String DOMAIN_1_CONFIG = "glassfish/domains/domain1/config"; private final static String INDENT = " "; @@ -79,15 +78,9 @@ public class PackageAppClient { private final static String[] DIRS_TO_COPY = new String[] { GLASSFISH_LIB + "/dtds", GLASSFISH_LIB + "/schemas", - GLASSFISH_LIB + "/appclient" }; - - /* - * relative path to the endorsed directory of the app server. Handled separately from other directorys because we do not - * include all files from the endorsed directory. - */ - private final static String LIB_ENDORSED_DIR = GLASSFISH_LIB + "/endorsed"; - - private final static String[] ENDORSED_DIRS_TO_COPY = new String[] { LIB_ENDORSED_DIR, MODULES_ENDORSED_DIR }; + GLASSFISH_LIB + "/appclient", + GLASSFISH_LIB + "/bootstrap", + }; /* default sun-acc.xml is relative to the installation directory */ private final static String DEFAULT_ACC_XML = DOMAIN_1_CONFIG + ACC_CONFIG_FILE_DEFAULT; @@ -146,55 +139,41 @@ private void run(String[] args) throws URISyntaxException, IOException { File installDir = findInstallDir(thisJarFile); File modulesDir = new File(installDir.toURI().resolve("glassfish/modules/")); - /* - * Write the new JAR to a temp file in the install directory. Then we can simply rename the file to the correct name. - * (Rename does not work on Windows systems across volumes.) - */ + // Write the new JAR to a temp file in the install directory. Then we can simply rename + // the file to the correct name. + // (Rename does not work on Windows systems across volumes.) File tempFile = File.createTempFile("appc", ".tmp", installDir); File outputFile = chooseOutputFile(installDir, args); File[] configFiles = chooseConfigFiles(installDir, args); String[] classPathElements = getJarClassPath(thisJarFile).split(" "); - JarOutputStream os = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempFile))); - - /* - * Add this JAR file to the output. - */ - addFile(os, installDir.toURI(), thisJarFile.toURI(), tempFile, ""); - - /* - * JARs listed in the Class-Path are all relative to the modules directory so resolve each Class-Path entry against the - * modules directory. - */ - for (String classPathElement : classPathElements) { - File classPathJAR = new File(modulesDir, classPathElement); - addFile(os, installDir.toURI(), modulesDir.toURI().resolve(classPathJAR.toURI()), tempFile, ""); - } + try (JarOutputStream os = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempFile)))) { + // Add this JAR file to the output. + addFile(os, installDir.toURI(), thisJarFile.toURI(), tempFile, ""); - /* - * The directories to copy are all relative to the installation directory, so resolve them against the installDir file. - */ - for (String dirToCopy : DIRS_TO_COPY) { - addDir(os, installDir.toURI(), installDir.toURI().resolve(dirToCopy), tempFile, ""); - } + // JARs listed in the Class-Path are all relative to the modules directory so resolve + // each Class-Path entry against the modules directory. + for (String classPathElement : classPathElements) { + File classPathJAR = new File(modulesDir, classPathElement); + addFile(os, installDir.toURI(), modulesDir.toURI().resolve(classPathJAR.toURI()), tempFile, ""); + } - for (String endorsedDirToCopy : ENDORSED_DIRS_TO_COPY) { - addEndorsedFiles(os, installDir.toURI(), installDir.toURI().resolve(endorsedDirToCopy), tempFile); - } + // The directories to copy are all relative to the installation directory, so resolve + // them against the installDir file. + for (String dirToCopy : DIRS_TO_COPY) { + addDir(os, installDir.toURI(), installDir.toURI().resolve(dirToCopy), tempFile, ""); + } - for (String singleFileToCopy : SINGLE_FILES_TO_COPY) { - addFile(os, installDir.toURI(), installDir.toURI().resolve(singleFileToCopy), tempFile, ""); - } + for (String singleFileToCopy : SINGLE_FILES_TO_COPY) { + addFile(os, installDir.toURI(), installDir.toURI().resolve(singleFileToCopy), tempFile, ""); + } - /* - * The glassfish-acc.xml file and sun-acc.xml files. - */ - for (File configFile : configFiles) { - addFile(os, installDir.toURI(), configFile.toURI(), tempFile, ""); + // The glassfish-acc.xml file and sun-acc.xml files. + for (File configFile : configFiles) { + addFile(os, installDir.toURI(), configFile.toURI(), tempFile, ""); + } } - - os.close(); placeFile(tempFile, outputFile); } 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 2b4a0e15978..dcbfd00b2da 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 @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.PrintStream; import java.net.URL; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -83,7 +84,7 @@ public class CLIBootstrap { private final static String SECURITY_AUTH_LOGIN_CONFIG_PROPERTY_EXPR = "-Djava.security.auth.login.config="; private final static String SYSTEM_CLASS_LOADER_PROPERTY_EXPR = "-Djava.system.class.loader=org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader"; - private final static String[] ENV_VARS = { "_AS_INSTALL", "APPCPATH", "VMARGS" }; + private final static String[] ENV_VARS = { "AS_INSTALL", "APPCPATH", "VMARGS" }; private JavaInfo java = new JavaInfo(); private GlassFishInfo gfInfo = new GlassFishInfo(); @@ -291,7 +292,9 @@ private void addProperties(final StringBuilder command) { command.append(' ').append("--add-opens=java.base/java.lang=ALL-UNNAMED"); command.append(' ').append(INSTALL_ROOT_PROPERTY_EXPR).append(quote(gfInfo.home().getAbsolutePath())); command.append(' ').append(SECURITY_POLICY_PROPERTY_EXPR).append(quote(gfInfo.securityPolicy().getAbsolutePath())); - command.append(' ').append("-classpath").append(' ').append(gfInfo.agentJarPath()).append(File.pathSeparatorChar).append('.'); + command.append(' ').append("--module-path ").append(quote(gfInfo.home().toPath().normalize().resolve(Path.of("lib", "bootstrap")).toString())); + command.append(' ').append("--add-modules ALL-MODULE-PATH"); + command.append(' ').append("-classpath ").append(gfInfo.agentJarPath()).append(File.pathSeparatorChar).append('.'); command.append(' ').append(SYSTEM_CLASS_LOADER_PROPERTY_EXPR); command.append(' ').append("-Xshare:off"); command.append(' ').append(SECURITY_AUTH_LOGIN_CONFIG_PROPERTY_EXPR).append(quote(gfInfo.loginConfig().getAbsolutePath())); @@ -867,7 +870,7 @@ private File fileContainingAgentArgs() throws IOException { /** * Encapsulates information about the GlassFish installation, mostly useful directories within the installation. *

- * Note that we use the property acc._AS_INSTALL to find the installation. + * Note that we use the property acc.AS_INSTALL to find the installation. */ static class GlassFishInfo { @@ -878,9 +881,9 @@ static class GlassFishInfo { private static final String ACC_CONFIG_PREFIX = "domains/domain1/config"; GlassFishInfo() { - String asInstallPath = System.getProperty(ENV_VAR_PROP_PREFIX + "_AS_INSTALL"); + String asInstallPath = System.getProperty(ENV_VAR_PROP_PREFIX + "AS_INSTALL"); if (asInstallPath == null || asInstallPath.length() == 0) { - throw new IllegalArgumentException("_AS_INSTALL == null"); + throw new IllegalArgumentException("AS_INSTALL == null"); } this.home = new File(asInstallPath); modules = new File(home, "modules"); 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 03e17819e8d..0ae12f0f2ef 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 @@ -17,7 +17,6 @@ package org.glassfish.appclient.client.acc; -import com.sun.enterprise.glassfish.bootstrap.cfg.AsenvConf; import com.sun.enterprise.module.bootstrap.StartupContext; import com.sun.enterprise.util.io.FileUtils; @@ -26,13 +25,20 @@ import java.io.File; import java.net.URI; import java.net.URISyntaxException; +import java.util.Map; import java.util.Properties; +import org.glassfish.main.jdke.props.EnvToPropsConverter; import org.jvnet.hk2.annotations.Service; -import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; -import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_PROP_NAME; - +import static com.sun.enterprise.util.SystemPropertyConstants.AGENT_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.CONFIG_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.DERBY_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.DOMAINS_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.IMQ_BIN_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.IMQ_LIB_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.JAVA_ROOT_PROPERTY_ASENV; /** * Start-up context for the ACC. Note that this context is used also for * Java Web Start launches. @@ -55,13 +61,19 @@ public ACCStartupContext() { */ private static Properties accEnvironment() { final File rootDirectory = getRootDirectory(); - final Properties environment = AsenvConf.parseAsEnv(rootDirectory).toProperties(); - environment.setProperty(INSTALL_ROOT_PROP_NAME, rootDirectory.getAbsolutePath()); - final File javadbDir = new File(rootDirectory.getParentFile(), "javadb"); - if (javadbDir.isDirectory()) { - environment.setProperty(DERBY_ROOT_PROP_NAME, javadbDir.getAbsolutePath()); - } - return environment; + final Map pairs = Map.of( + "AS_DERBY_INSTALL", DERBY_ROOT_PROPERTY, + "AS_IMQ_LIB", IMQ_LIB_PROPERTY, + "AS_IMQ_BIN", IMQ_BIN_PROPERTY, + "AS_CONFIG", CONFIG_ROOT_PROPERTY, + "AS_INSTALL", INSTALL_ROOT_PROPERTY, + "AS_JAVA", JAVA_ROOT_PROPERTY_ASENV, + "AS_DEF_DOMAINS_PATH", DOMAINS_ROOT_PROPERTY, + "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())); + return env; } private static File getRootDirectory() { diff --git a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/CLIBootstrapTest.java b/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/CLIBootstrapTest.java index 09324219171..1023ec494c9 100644 --- a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/CLIBootstrapTest.java +++ b/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/CLIBootstrapTest.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -43,7 +43,7 @@ public void setUp() { System.setProperty(CLIBootstrap.ENV_VAR_PROP_PREFIX + "AS_JAVA", ""); System.setProperty(CLIBootstrap.ENV_VAR_PROP_PREFIX + "JAVA_HOME", ""); System.setProperty(CLIBootstrap.ENV_VAR_PROP_PREFIX + "PATH", System.getenv("PATH")); - System.setProperty(CLIBootstrap.ENV_VAR_PROP_PREFIX + "_AS_INSTALL", + System.setProperty(CLIBootstrap.ENV_VAR_PROP_PREFIX + "AS_INSTALL", "/Users/Tim/asgroup/v3/H/publish/glassfish7/glassfish"); } diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient index aa240dac3a6..e34bdff2ab8 100644 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -15,10 +16,6 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -# - -# set -x - chooseJava() { # # Looks for Java at AS_JAVA, JAVA_HOME or in the path. @@ -65,14 +62,17 @@ seekJavaOnPath() { } -_AS_INSTALL=`dirname "$0"`/.. -export _AS_INSTALL +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in - CYGWIN*) _AS_INSTALL=`cygpath --windows $_AS_INSTALL` + CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` cygwinProp=-Dorg.glassfish.isCygwin=true esac -. "${_AS_INSTALL}/config/asenv.conf" +. "${AS_INSTALL}/config/asenv.conf" chooseJava -eval "`"${ACCJava}" -Dorg.glassfish.appclient.shell $cygwinProp -classpath "${_AS_INSTALL}/lib/gf-client.jar" org.glassfish.appclient.client.CLIBootstrap "$@"`" +ACC_MODULEPATH="${AS_INSTALL}/lib/bootstrap" +ACC_INSTALL_LIB="${AS_INSTALL}/lib/install/applications"; +ACC_CLASSPATH="${AS_INSTALL}/lib/gf-client.jar:${AS_INSTALL}/lib/appclient/weld-se-shaded.jar:$AS_INSTALL/admin-cli.jar:$AS_DERBY_INSTALL/lib/*:$ACC_INSTALL_LIB/__ds_jdbc_ra/jdbc-ra-ds.jar:$ACC_INSTALL_LIB/__cp_jdbc_ra/jdbc-ra-cp.jar:$ACC_INSTALL_LIB/__xa_jdbc_ra/jdbc-ra-xa.jar:$ACC_INSTALL_LIB/__dm_jdbc_ra/jdbc-ra-dm.jar:$ACC_INSTALL_LIB/jmsra/imqjmsra.jar:${AS_IMQ_LIB}/imq.jar:${AS_IMQ_LIB}/imqadmin.jar:${AS_IMQ_LIB}/imqutil.jar:${AS_IMQ_LIB}/fscontext.jar:$AS_INSTALL/modules/*" + +"${ACCJava}" -Dorg.glassfish.appclient.shell $cygwinProp --module-path "${ACC_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "${ACC_CLASSPATH}" org.glassfish.appclient.client.CLIBootstrap "$@" diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat index 60b86637f90..cb12e49a19e 100644 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat @@ -1,5 +1,6 @@ @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 @@ -65,18 +66,12 @@ rem issue the error so we don't have to do i18n of our own message from the scri goto :EOF :main -set _AS_INSTALL=%~dp0.. -call "%_AS_INSTALL%\config\asenv.bat" +set AS_INSTALL="%~dp0.." +call "%AS_INSTALL%\config\asenv.bat" call :chooseJava -set inputArgs=%* -rem -rem Convert the java.exe path and the classpath path to -rem Windows "short" versions - with no spaces - so the -rem for /F statement below will work correctly. Spaces cause -rem it great troubles. -rem -for %%a in ("%JAVA%") do set ACCJava=%%~sa% -for %%a in ("%_AS_INSTALL%/lib/gf-client.jar") do set XCLASSPATH=%%~sa -for /F "usebackq tokens=*" %%a in (`%ACCJava% -classpath %XCLASSPATH% org.glassfish.appclient.client.CLIBootstrap`) do set javaCmd=%%a -%javaCmd% +set ACC_MODULEPATH="%AS_INSTALL%\lib\bootstrap" +set ACC_INSTALL_LIB="%AS_INSTALL%\lib\install\applications"; +set ACC_CLASSPATH="%AS_INSTALL%\lib\gf-client.jar:%AS_INSTALL%\lib\appclient\weld-se-shaded.jar:%AS_INSTALL%\admin-cli.jar:%AS_DERBY_INSTALL%\lib\*:%ACC_INSTALL_LIB%\__ds_jdbc_ra\jdbc-ra-ds.jar:%ACC_INSTALL_LIB%\__cp_jdbc_ra\jdbc-ra-cp.jar:%ACC_INSTALL_LIB%\__xa_jdbc_ra\jdbc-ra-xa.jar:%ACC_INSTALL_LIB%\__dm_jdbc_ra\jdbc-ra-dm.jar:%ACC_INSTALL_LIB%\jmsra\imqjmsra.jar:%AS_IMQ_LIB%\imq.jar:%AS_IMQ_LIB%\imqadmin.jar:%AS_IMQ_LIB%\imqutil.jar:%AS_IMQ_LIB%\fscontext.jar:%AS_INSTALL%\modules\*" + +%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ACC_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ACC_CLASSPATH%" org.glassfish.appclient.client.CLIBootstrap %* diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient index 341491e5831..5af013ede1f 100755 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient @@ -1,5 +1,6 @@ #!/bin/sh # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -17,19 +18,20 @@ # set -x -_AS_INSTALL=`dirname "$0"`/.. +export AS_INSTALL="$(dirname $(realpath -s $0))/.." + # # Run with the user-specified Java, if any. # case "`uname`" in - CYGWIN*) _AS_INSTALL=`cygpath --windows $_AS_INSTALL` + CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac -. "${_AS_INSTALL}/config/asenv.conf" +. "${AS_INSTALL}/config/asenv.conf" JAVA=java # Depends upon Java from ../config/asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -_AS_INSTALL_LIB=$_AS_INSTALL/lib -$JAVA -classpath "$_AS_INSTALL_LIB/gf-client.jar" org.glassfish.appclient.client.packageappclient.PackageAppClient "$@" +AS_INSTALL_LIB="$AS_INSTALL/lib" +$JAVA -classpath "$AS_INSTALL_LIB/gf-client.jar" org.glassfish.appclient.client.packageappclient.PackageAppClient "$@" diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient.bat b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient.bat index 286f2baf2fa..4aed19d3c80 100755 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient.bat +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient.bat @@ -1,5 +1,6 @@ @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 @@ -16,16 +17,18 @@ REM SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 REM setlocal -set _AS_INSTALL=%~dp0.. -call "%_AS_INSTALL%\config\asenv.bat" +set AS_INSTALL=%~dp0.. +call "%AS_INSTALL%\config\asenv.bat" REM REM Run with the user-specified Java, if any. REM if "%AS_JAVA%x" == "x" goto UsePath set JAVA="%AS_JAVA%\bin\java" goto run + :UsePath set JAVA=java + :run -set _AS_INSTALL_LIB=%_AS_INSTALL%\lib -%JAVA% -classpath "%_AS_INSTALL_LIB%\gf-client.jar" org.glassfish.appclient.client.packageappclient.PackageAppClient %* +set AS_INSTALL_LIB=%AS_INSTALL%\lib +%JAVA% -classpath "%AS_INSTALL_LIB%\gf-client.jar" org.glassfish.appclient.client.packageappclient.PackageAppClient %* diff --git a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin index 77c480ad28a..2c3f0427217 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin @@ -16,17 +16,16 @@ # 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" JAVA=java -#Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" -exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain "$@" +export ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:${ASADMIN_CLASSPATH}" +exec "$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/asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat index 50b841054a6..74e07986b99 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/asadmin.bat @@ -23,7 +23,8 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\glassfish\config\asenv.bat" +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 @@ -32,5 +33,5 @@ goto run set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%/appserver-cli.jar:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" -%JAVA% "%ASADMIN_JVM_OPTIONS%" --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain %* +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 b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin index 5c5d7552c33..8511a1ea203 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin @@ -16,15 +16,13 @@ # 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" . "${AS_INSTALL}/config/asenv.conf" JAVA=java -#Depends upon Java from ../config/asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" -exec "$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 "$@" - +export ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$ASADMIN_CLASSPATH" +exec "$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/debug-asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/bin/debug-asadmin.bat index dfa747bd657..5b41772b7b2 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 @@ -16,7 +16,6 @@ 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 @@ -24,7 +23,8 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\glassfish\config\asenv.bat" +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 @@ -33,5 +33,5 @@ goto run set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%/appserver-cli.jar:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" -%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 %* +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 b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv index 3188778d880..d0899b0b287 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv @@ -16,23 +16,22 @@ # 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" JAVA=java -#Depends upon Java from ../config/asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" +export ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:${ASADMIN_CLASSPATH}" start_as_main_process () { if [[ "$@" == "--help" ]] || [[ "$@" == "--help=true" ]] || [[ "$@" == "-?" ]]; then - exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain start-domain --help + exec "$JAVA" ${ASADMIN_JVM_OPTIONS} --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain start-domain --help fi # Execute start-domain --dry-run and store the output line by line into an array. @@ -52,7 +51,7 @@ start_as_main_process () { else DRY_RUN_OUTPUT+=("$COM"); fi - done < <("$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain start-domain --dry-run "$@" || echo "FAILED") + done < <("$JAVA" ${ASADMIN_JVM_OPTIONS} --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain start-domain --dry-run "$@" || echo "FAILED") if [[ x"$DRY_RUN_OUTPUT" == x ]] then echo -n -e "${DRY_RUN_OUTPUT_BEFORE_DUMP}" >&2 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 65c064aba7b..7db123c3d21 100755 --- a/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat +++ b/appserver/distributions/glassfish-common/src/main/resources/bin/startserv.bat @@ -23,7 +23,8 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 @@ -32,5 +33,5 @@ goto run set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%/appserver-cli.jar:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" -%JAVA% "%ASADMIN_JVM_OPTIONS%" --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain start-domain --verbose %* +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/glassfish/bin/asadmin b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin index d363ad4a57b..ac9a0cf2c37 100644 --- a/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin +++ b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin @@ -16,17 +16,16 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/.. +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac . "${AS_INSTALL}/config/asenv.conf" JAVA=java -#Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" -exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" org.glassfish.admin.cli.AsadminMain "$@" +export ASADMIN_CLASSPATH="$AS_INSTALL/appserver-cli.jar:${ASADMIN_CLASSPATH}" +exec "$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/glassfish/bin/asadmin.bat b/appserver/distributions/glassfish-common/src/main/resources/glassfish/bin/asadmin.bat index e5a2e53b0ea..0822ceb03b3 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 @@ -23,7 +23,8 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 @@ -32,5 +33,5 @@ goto run set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%/appserver-cli.jar:%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" -%JAVA% "%ASADMIN_JVM_OPTIONS%" --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" org.glassfish.admin.cli.AsadminMain %* +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/itest-tools/src/main/java/org/glassfish/main/itest/tools/asadmin/StartServ.java b/appserver/itest-tools/src/main/java/org/glassfish/main/itest/tools/asadmin/StartServ.java index 601af11a230..8148a1defea 100644 --- a/appserver/itest-tools/src/main/java/org/glassfish/main/itest/tools/asadmin/StartServ.java +++ b/appserver/itest-tools/src/main/java/org/glassfish/main/itest/tools/asadmin/StartServ.java @@ -160,4 +160,10 @@ public AsadminResult exec(final int timeout, final String... args) { return result; } + + @Override + public String toString() { + return this.startServ.toString(); + } + } diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/StartServITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/StartServITest.java index 0f6ce9b95ea..5d3d56b18c0 100644 --- a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/StartServITest.java +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/StartServITest.java @@ -99,7 +99,9 @@ static class StartServArgumentsProvider implements ArgumentsProvider { @Override public Stream provideArguments(ExtensionContext context) { return Stream.of( + // Will be as [1] Arguments.of(STARTSERV), + // Will be as [2] Arguments.of(STARTSERV_IN_TOPLEVEL_BIN) ); } diff --git a/appserver/tests/appserv-tests/config/jws-appclient b/appserver/tests/appserv-tests/config/jws-appclient index 94ba854f71b..9d45bdfbe37 100644 --- a/appserver/tests/appserv-tests/config/jws-appclient +++ b/appserver/tests/appserv-tests/config/jws-appclient @@ -66,14 +66,14 @@ seekJavaOnPath() { } -_AS_INSTALL=$S1AS_HOME -echo "_AS_INSTALL now defined as $_AS_INSTALL" -export _AS_INSTALL +AS_INSTALL=$S1AS_HOME +echo "AS_INSTALL now defined as $AS_INSTALL" +export AS_INSTALL case "`uname`" in - CYGWIN*) _AS_INSTALL=`cygpath --windows $_AS_INSTALL` + CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` cygwinProp=-Dorg.glassfish.isCygwin=true esac -. "${_AS_INSTALL}/config/asenv.conf" +. "${AS_INSTALL}/config/asenv.conf" chooseJava 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 eb4bb13d38e..f86a90c9a4c 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 @@ -20,11 +20,11 @@ import com.sun.enterprise.admin.remote.reader.ProprietaryReaderFactory; import com.sun.enterprise.admin.remote.writer.ProprietaryWriterFactory; import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; +import com.sun.enterprise.universal.glassfish.GFLauncherUtils; import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.SystemPropertyConstants; import java.io.File; -import java.io.IOException; import java.io.PrintStream; import java.lang.Runtime.Version; import java.net.ConnectException; @@ -81,7 +81,7 @@ public class AdminMain { private static final String[] SYS_PROPERTIES_TO_SET_FROM_ASENV = { INSTALL_ROOT_PROPERTY, SystemPropertyConstants.CONFIG_ROOT_PROPERTY, - SystemPropertyConstants.PRODUCT_ROOT_PROPERTY + SystemPropertyConstants.PRODUCT_ROOT_PROPERTY, }; private static final LocalStringsImpl strings = new LocalStringsImpl(AdminMain.class); @@ -107,18 +107,7 @@ public class AdminMain { public AdminMain() { - this.installRoot = Path.of(System.getProperty(INSTALL_ROOT_PROPERTY)); - if (installRoot == null) { - throw new Error("The install root was not specified by the system property " + INSTALL_ROOT_PROPERTY); - } - try { - final File dir = installRoot.toRealPath().toFile(); - if (!dir.isDirectory() && dir.canRead()) { - throw new Error("The install root is not an existing readable directory: " + installRoot); - } - } catch (IOException e) { - throw new Error("The install root is not valid: " + installRoot, e); - } + this.installRoot = GFLauncherUtils.getInstallDir().toPath(); } protected Path getInstallRoot() { @@ -131,7 +120,7 @@ protected Path getInstallRoot() { * @return a class loader used to load local commands */ private ClassLoader getExtensionClassLoader(final Set extensions) { - final ClassLoader ecl = AdminMain.class.getClassLoader(); + final ClassLoader ecl = getClass().getClassLoader(); if (extensions == null || extensions.isEmpty()) { return ecl; } @@ -157,11 +146,16 @@ private ClassLoader getExtensionClassLoader(final Set extensions) { protected Set getExtensions() { final Set locations = new HashSet<>(); final File ext = installRoot.resolve(Path.of("lib", "asadmin")).toFile(); - if (ext.exists() && ext.isDirectory()) { + if (ext.isDirectory()) { locations.add(ext); - return locations; + } else { + throw new Error(strings.get("ExtDirMissing", ext)); + } + final File modules = getInstallRoot().resolve("modules").toFile(); + if (modules.isDirectory()) { + locations.add(modules); } - throw new Error(strings.get("ExtDirMissing", ext)); + return locations; } @@ -210,9 +204,9 @@ protected final int doMain(String[] args) { modulePath = SmartFile.sanitize(System.getProperty("jdk.module.path")); className = AdminMain.class.getName(); - if (logger.isLoggable(FINER)) { - logger.log(FINER, "ModulePath: {0}\nClasspath: {1}\nArguments: {2}", - new Object[] {modulePath, classPath, Arrays.toString(args)}); + if (logger.isLoggable(FINEST)) { + logger.log(FINEST, getClass() + "\nModulePath: {0}\nClasspath: {1}\nExtensions: {2}\nArguments: {3}", + new Object[] {modulePath, classPath, ecl, Arrays.toString(args)}); } if (args.length == 0) { diff --git a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java index 077481f2cd8..252ffc647a6 100644 --- a/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java +++ b/nucleus/admin/cli/src/main/java/com/sun/enterprise/admin/cli/DirectoryClassLoader.java @@ -87,12 +87,15 @@ private static URL[] getJars(final File... jarsAndDirs) { } - private static Set getJarPaths(final File dir) { - try (Stream stream = Files.walk(dir.toPath(), MAX_DEPTH)) { + private static Set getJarPaths(final File jarOrDir) { + if (jarOrDir.isFile()) { + return Set.of(jarOrDir.toPath()); + } + try (Stream stream = Files.walk(jarOrDir.toPath(), MAX_DEPTH)) { return stream.filter(path -> !Files.isDirectory(path)) .filter(path -> path.getFileName().toString().endsWith(".jar")).collect(Collectors.toSet()); } catch (final IOException e) { - throw new IllegalStateException(STRINGS.get("DirError", dir), e); + throw new IllegalStateException(STRINGS.get("DirError", jarOrDir), e); } } } diff --git a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java index 07d821ce2d2..3bebd265c8c 100644 --- a/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java +++ b/nucleus/admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java @@ -785,7 +785,6 @@ void setCommandLine() throws GFLauncherException { cmdLine.add("--add-modules"); cmdLine.add("ALL-MODULE-PATH"); } - cmdLine.add("-verbose"); if (getClasspath() != null) { addIgnoreNull(cmdLine, "-cp"); addIgnoreNull(cmdLine, getClasspath()); 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 b238b6f312d..e08749952ce 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 @@ -20,14 +20,13 @@ import com.sun.enterprise.universal.io.SmartFile; import com.sun.enterprise.util.net.NetUtils; -import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; -import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.glassfish.main.jdke.props.EnvToPropsConverter; + import static com.sun.enterprise.util.SystemPropertyConstants.AGENT_ROOT_PROPERTY; import static com.sun.enterprise.util.SystemPropertyConstants.CONFIG_ROOT_PROPERTY; import static com.sun.enterprise.util.SystemPropertyConstants.DERBY_ROOT_PROPERTY; @@ -39,9 +38,6 @@ import static com.sun.enterprise.util.SystemPropertyConstants.JAVA_ROOT_PROPERTY; import static com.sun.enterprise.util.SystemPropertyConstants.JAVA_ROOT_PROPERTY_ASENV; import static com.sun.enterprise.util.SystemPropertyConstants.PRODUCT_ROOT_PROPERTY; -import static com.sun.enterprise.util.SystemPropertyConstants.UNIX_ASENV_FILENAME; -import static com.sun.enterprise.util.SystemPropertyConstants.WINDOWS_ASENV_FILENAME; -import static java.nio.charset.StandardCharsets.UTF_8; /** * Class ASenvPropertyReader @@ -59,7 +55,6 @@ public class ASenvPropertyReader { "AS_IMQ_LIB", IMQ_LIB_PROPERTY, "AS_IMQ_BIN", IMQ_BIN_PROPERTY, "AS_CONFIG", CONFIG_ROOT_PROPERTY, - "AS_INSTALL", INSTALL_ROOT_PROPERTY, "AS_JAVA", JAVA_ROOT_PROPERTY_ASENV, "AS_DEF_DOMAINS_PATH", DOMAINS_ROOT_PROPERTY, "AS_DEF_NODES_PATH", AGENT_ROOT_PROPERTY); @@ -130,199 +125,15 @@ public String toString() { } - /** - * ASenvMap is a "lazy-evaluation" map, i.e., for values that are - * expensive to calculate, the value is not calculated until it is actually - * used. - */ static class ASenvMap extends HashMap { - // If we find a token in a set property, this is set to true. - boolean foundToken; - ASenvMap(File installDir) { - put(INSTALL_ROOT_PROPERTY, installDir.getPath()); - File configDir = SmartFile.sanitize(new File(installDir, "config")); - put(CONFIG_ROOT_PROPERTY, configDir.getPath()); - setProperties(configDir); - postProcess(configDir); - // Product root is defined to be the parent of the install root. - // While tempting to just use installDir.getParent() we go through - // these gyrations just in case setProperties() changed the value - // of the INSTALL_ROOT_PROPERTY property. - File installRoot = new File(super.get(INSTALL_ROOT_PROPERTY)); - put(PRODUCT_ROOT_PROPERTY, installRoot.getParent()); - } - - @Override - public String get(Object k) { - String v = super.get(k); - if (v != null) { - return v; - } - if (k.equals(HOST_NAME_PROPERTY)) { - v = getHostname(); - put(HOST_NAME_PROPERTY, v); - } - else if (k.equals(JAVA_ROOT_PROPERTY)) { - v = getJavaRoot(super.get(JAVA_ROOT_PROPERTY_ASENV)); - put(JAVA_ROOT_PROPERTY, v); - } - return v; - } - - @Override - public Set keySet() { - completeMap(); - return super.keySet(); - } - - @Override - public Set> entrySet() { - completeMap(); - return super.entrySet(); - } - - @Override - public boolean containsKey(Object k) { - completeMap(); - return super.containsKey(k); - } - - @Override - public Collection values() { - completeMap(); - return super.values(); - } - - /** - * Add the "lazy" items to the map so that the map is complete. - */ - private void completeMap() { - get(HOST_NAME_PROPERTY); - get(JAVA_ROOT_PROPERTY); - } - - - /** - *

    - *
  1. change relative paths to absolute - *
  2. change env. variables to either the actual values in the environment -` * or to another prop in asenv - *
- */ - private void postProcess(File configDir) { - if (foundToken) { - final Map env = System.getenv(); - //put env props in first - Map all = new HashMap<>(env); - // now override with our props - all.putAll(this); - TokenResolver tr = new TokenResolver(all); - tr.resolve(this); - } - - // props have all tokens replaced now (if they exist) - // now make the paths absolute. - // Call super.keySet here so that the lazy values are not added - // to the map at this point. - Set keys = super.keySet(); - - for (String key : keys) { - String value = super.get(key); - if (GFLauncherUtils.isRelativePath(value)) { - // we have to handle both of these: - // /x/y/../z - // ../x/y/../z - - File f; - if (value.startsWith(".")) { - f = SmartFile.sanitize(new File(configDir, value)); - } - else { - f = SmartFile.sanitize(new File(value)); - } - - put(key, f.getPath()); - } - } - } - - private void setProperties(File configDir) { - //Read in asenv.conf/bat and set system properties accordingly - File asenv = new File(configDir, - GFLauncherUtils.isWindows() ? WINDOWS_ASENV_FILENAME : UNIX_ASENV_FILENAME); - if (!asenv.exists()) { - return; - } - try (BufferedReader reader = new BufferedReader(new FileReader(asenv, UTF_8))) { - String line; - while ((line = reader.readLine()) != null) { - setProperty(line); - } - } catch (Exception e) { - throw new IllegalStateException("Could not parse " + asenv, e); - } - } - - /** - * Method setProperty - * Parses a single line of asenv.conf or asenv.bat and attempt to - * set the corresponding property. Note that if the system - * property is already set (e.g. via -D on the command line), then - * we will not clobber its existing value. - * - * @param line - * - */ - private void setProperty(String line) { - int pos = line.indexOf('='); - if (pos > 0) { - String lhs = (line.substring(0, pos)).trim(); - String rhs = (line.substring(pos + 1)).trim(); - String rhsExpression = "\"${" + lhs + ":-"; - if (!GFLauncherUtils.isWindows() && rhs.contains(rhsExpression) && rhs.contains("}")) { - String env = System.getenv(lhs); - int start = rhs.indexOf(rhsExpression); - int end = rhs.indexOf('}'); - StringBuilder value = new StringBuilder(); - if (start > 0) { - value.append(rhs.subSequence(0, start)); - } - if (env == null) { - value.append('"').append(rhs.substring(start + rhsExpression.length(), end)); - } else { - value.append(env); - } - if (rhs.length() > end + 1) { - value.append(rhs.substring(end + 1)); - } - rhs = value.toString(); - } - - if (GFLauncherUtils.isWindows()) { - // trim off the "set " - lhs = (lhs.substring(3)).trim(); - } else { - // take the quotes out - pos = rhs.indexOf('"'); - if (pos != -1) { - rhs = (rhs.substring(pos + 1)).trim(); - pos = rhs.indexOf('"'); - if (pos != -1) { - rhs = (rhs.substring(0, pos)).trim(); - } - } - } - - String systemPropertyName = ENV_TO_SYS_PROPERTY.get(lhs); - - if (systemPropertyName != null) { - if (TokenResolver.hasToken(rhs)) { - foundToken = true; - } - put(systemPropertyName, rhs); - } - } + 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()); + put(HOST_NAME_PROPERTY, getHostname()); } private static String getHostname() { @@ -336,51 +147,6 @@ private static String getHostname() { return hostname; } - /** - * Get a value for the Java installation directory. The value that is - * passed in should be the value from the ASenv config file. If it is valid - * it is returned. Otherwise, this method checks the following: - * - JAVA_HOME environment variable - * - java.home system property - */ - private static String getJavaRoot(String fileValue) { - // make sure we have a folder with java in it! - // note that we are not in a position to set it from domain.xml yet - - // first choice -- whatever is in asenv - String javaRootName = fileValue; - - if (isValidJavaRoot(javaRootName)) { - return javaRootName; // we are already done! - } - - // try JAVA_HOME - javaRootName = System.getenv("JAVA_HOME"); - - if (isValidJavaRoot(javaRootName)) { - javaRootName = SmartFile.sanitize(new File(javaRootName)).getPath(); - return javaRootName; - } - // try java.home with ../ - // usually java.home is pointing at jre and ".." goes to the jdk - javaRootName = System.getProperty("java.home") + "/.."; - - if (isValidJavaRoot(javaRootName)) { - javaRootName = SmartFile.sanitize(new File(javaRootName)).getPath(); - return javaRootName; - } - - // try java.home as-is - javaRootName = System.getProperty("java.home"); - - if (isValidJavaRoot(javaRootName)) { - javaRootName = SmartFile.sanitize(new File(javaRootName)).getPath(); - return javaRootName; - } - // TODO - should this be an Exception? A log message? - return null; - } - private static boolean isValidJavaRoot(String javaRootName) { if (!GFLauncherUtils.ok(javaRootName)) { return false; @@ -394,9 +160,7 @@ private static boolean isValidJavaRoot(String javaRootName) { } else { f = new File(f, "bin/java"); } - return f.exists(); } - } } diff --git a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/GFLauncherUtils.java b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/GFLauncherUtils.java index 91b7a4b8541..9d0cacc417b 100644 --- a/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/GFLauncherUtils.java +++ b/nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/GFLauncherUtils.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,30 +18,29 @@ package com.sun.enterprise.universal.glassfish; import com.sun.enterprise.universal.io.SmartFile; +import com.sun.enterprise.util.SystemPropertyConstants; import com.sun.enterprise.util.net.NetUtils; import java.io.File; -import java.net.JarURLConnection; -import java.net.URL; +import java.io.IOException; +import java.net.URISyntaxException; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; - /** * Package private static utility methods * @author bnevins */ -public class GFLauncherUtils { +public final class GFLauncherUtils { private GFLauncherUtils() { - // all static methods + // all static methods } public static boolean ok(String s) { - return s != null && s.length() > 0; + return s != null && !s.isEmpty(); } public static boolean safeExists(File f) { @@ -51,54 +51,12 @@ public static boolean safeIsDirectory(File f) { return f != null && f.isDirectory(); } - public static synchronized File getInstallDir() { - // if it is already set as a System Property -- skip the huge block below - setInstallDirFromSystemProp(); - - if(installDir == null) - { - String resourceName = GFLauncherUtils.class.getName().replace('.', '/') + ".class"; - URL resource = GFLauncherUtils.class.getClassLoader().getResource(resourceName); - - if (resource == null) { - return null; - } - - if (!resource.getProtocol().equals("jar")) { - return null; - } - - try { - JarURLConnection c = (JarURLConnection) resource.openConnection(); - URL jarFile = c.getJarFileURL(); - - // important to sanitize it! - // unreported bug: - // JDK does this: - // the parent of "/foo/." is "/foo", not "/" ! - - - File f = SmartFile.sanitize(new File(jarFile.toURI())); - - f = f.getParentFile(); // /modules - - if (f == null) { - return null; - } - - f = f.getParentFile(); // / - - if (f == null) { - return null; - } - - installDir = SmartFile.sanitize(f); - } - catch (Exception e) { - installDir = null; - } + public static File getInstallDir() { + try { + return resolveInstallDir(); + } catch (IOException | URISyntaxException e) { + throw new Error("Cannot resolve install root!", e); } - return installDir; } public static boolean isWindows() { @@ -133,7 +91,7 @@ public static String getCanonicalHostName() throws UnknownHostException { } public static String replace(String s, String token, String replace) { - if (s == null || s.length() <= 0 || token == null || token.length() <= 0) { + if (s == null || s.isEmpty() || token == null || token.isEmpty()) { return s; } @@ -162,17 +120,13 @@ public static String replace(String s, String token, String replace) { public static boolean isRelativePath(String path) { if (!ok(path)) { return false; - } - else if (path.startsWith(".")) { + } else if (path.startsWith(".")) { return true; - } - else if (path.indexOf("/.") >= 0) { + } else if (path.indexOf("/.") >= 0) { return true; - } - else if (path.indexOf("\\.") >= 0) { + } else if (path.indexOf("\\.") >= 0) { return true; - } - else { + } else { return false; } } @@ -182,16 +136,16 @@ else if (path.indexOf("\\.") >= 0) { * @param cp The classpath-like string * @return the list of File */ - public static List stringToFiles(String cp) - { - List list = new ArrayList(); + public static List stringToFiles(String cp) { + List list = new ArrayList<>(); - if(ok(cp)) { + if (ok(cp)) { cp = SmartFile.sanitizePaths(cp); String[] ss = cp.split(File.pathSeparator); - for(String s : ss) + for (String s : ss) { list.add(new File(s)); + } } return list; @@ -214,27 +168,37 @@ public static String fileListToPathString(List files) { return sb.toString(); } - private static void setInstallDirFromSystemProp() { - // https://embedded-glassfish.dev.java.net/issues/show_bug.cgi?id=54 - // - // For instance if we are called from an Embedded Server then InstallRoot - // may already be set as a System Prop -- and the jar we are running from has - // nothing whatever to do with the concept of an "install root". - // In that case we certainly do not want to wipe out the already set install root. - - // if anything is not kosher simply return w/o setting installDir to anything. - String installRootDirName = System.getProperty(INSTALL_ROOT_PROPERTY); - - if(!ok(installRootDirName)) - return; - - File f = SmartFile.sanitize(new File(installRootDirName)); - - if(f.isDirectory()) { - installDir = f; + /** + * @return + * @throws IOException + * @throws URISyntaxException + */ + private static File resolveInstallDir() throws IOException, URISyntaxException { + // Property first, because it could be already set by this JVM and we respect it. + String sys = System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY); + if (sys != null) { + return toValidDirectory(sys); } + String env = System.getenv("AS_INSTALL"); + if (env != null) { + return toValidDirectory(env); + } + // Expectation: we are running the program using usual directory design of GlassFish. + // That means that the common-util jar is in modules directory. + return new File(GFLauncherUtils.class.getProtectionDomain().getCodeSource().getLocation().toURI()) + .getCanonicalFile().getParentFile().getParentFile(); } - private static File installDir; + private static File toValidDirectory(String value) throws IOException { + File file = new File(value).toPath().normalize().toFile(); + if (!file.isAbsolute()) { + throw new IOException("The path to install root is not an absolute path: " + file); + } + File canonical = file.getCanonicalFile(); + if (!canonical.isDirectory()) { + throw new IOException("The path to install root is not a directory: " + canonical); + } + return canonical; + } } diff --git a/nucleus/common/common-util/src/test/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReaderTest.java b/nucleus/common/common-util/src/test/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReaderTest.java index bf9914d2415..5fb1c00c722 100644 --- a/nucleus/common/common-util/src/test/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReaderTest.java +++ b/nucleus/common/common-util/src/test/java/com/sun/enterprise/universal/glassfish/ASenvPropertyReaderTest.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -46,6 +46,6 @@ public static void setUpClass() throws Exception { public void test() { ASenvPropertyReader reader = new ASenvPropertyReader(installDir); Map props = reader.getProps(); - assertThat(props.toString(), props.entrySet(), hasSize(10)); + assertThat(props.toString(), props.entrySet(), hasSize(5)); } } diff --git a/nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java b/nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java index 5b202253adf..e19edb8e156 100644 --- a/nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/module-info.java @@ -23,4 +23,5 @@ exports org.glassfish.main.jdke.cl; exports org.glassfish.main.jdke.i18n; + exports org.glassfish.main.jdke.props; } 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 new file mode 100644 index 00000000000..7129887143a --- /dev/null +++ b/nucleus/common/glassfish-jdk-extensions/src/main/java/org/glassfish/main/jdke/props/EnvToPropsConverter.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 Eclipse Foundation and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.main.jdke.props; + +import java.io.File; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; + +/** + * Given a file, tries to resolve given keys to absolute paths. + * + * @author David Matejcek + */ +public final class EnvToPropsConverter { + + private final Path anchor; + + /** + * @param relativePathAnchor absolute path; will be normalized. + */ + public EnvToPropsConverter(final Path relativePathAnchor) { + if (relativePathAnchor == null || !relativePathAnchor.isAbsolute()) { + throw new IllegalArgumentException("The path is not absolute: " + relativePathAnchor); + } + anchor = relativePathAnchor.normalize(); + } + + + /** + * Tries to resolve given keys. + *
    + *
  • First tries {@link System#getenv(String)} using map key. + *
  • Then tries {@link System#getProperty(String)} using map value. + *
+ * Then if the retrieved value is relative, it is resolved against the anchor path from + * constructor. + * The resolved file is added to the resulting map using the input map's value as a key. + * 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. + */ + public Map convert(final Map envToSys) { + final Map files = new HashMap<>(envToSys.size()); + for (final String envPropertyName : envToSys.keySet()) { + final String systemPropertyName = envToSys.get(envPropertyName); + if (systemPropertyName == null) { + continue; + } + final File file = convert(envPropertyName, systemPropertyName); + if (file != null) { + files.put(systemPropertyName, file); + } + } + return files; + } + + + /** + * Tries to resolve given keys. + *
    + *
  • First tries {@link System#getenv(String)} using the first parameter. + *
  • Then tries {@link System#getProperty(String)} using the second parameter. + *
+ * Then if the retrieved value is relative, it is resolved against the anchor path from + * constructor. + * + * @param envPropertyName + * @param systemPropertyName + * @return file - there is no guarantee the file does exist. + */ + public File convert(final String envPropertyName, final String systemPropertyName) { + final String value = evaluate(envPropertyName, systemPropertyName); + return value == null ? null : toAbsoluteFile(Path.of(value)); + } + + + private String evaluate(final String envPropertyName, final String systemPropertyName) { + final String envValue = System.getenv(envPropertyName); + if (envValue != null) { + return envValue; + } + final String sysValue = System.getProperty(systemPropertyName); + if (sysValue != null) { + return sysValue; + } +// System.err.println("Missing env " + envPropertyName + " or system property " + systemPropertyName); + return null; + } + + + private File toAbsoluteFile(final Path path) { + File absoluteFile; + if (path.isAbsolute()) { + absoluteFile = path.normalize().toFile(); + } else { + absoluteFile = anchor.resolve(path).normalize().toFile(); + } + return absoluteFile; + } +} 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 499e8bd771d..cdc711bee88 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 @@ -17,7 +17,6 @@ package org.glassfish.main.boot.osgi; -import com.sun.enterprise.glassfish.bootstrap.cfg.AsenvConf; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.bootstrap.BootException; import com.sun.enterprise.module.bootstrap.Main; @@ -35,6 +34,7 @@ import java.util.Arrays; import java.util.Enumeration; import java.util.List; +import java.util.Map; import java.util.Properties; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -47,6 +47,7 @@ import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.main.boot.impl.GlassFishImpl; import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; +import org.glassfish.main.jdke.props.EnvToPropsConverter; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; @@ -57,6 +58,13 @@ import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_URI_PROP_NAME; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTANCE_ROOT_PROP_NAME; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTANCE_ROOT_URI_PROP_NAME; +import static com.sun.enterprise.util.SystemPropertyConstants.AGENT_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.CONFIG_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.DERBY_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.DOMAINS_ROOT_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.IMQ_BIN_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.IMQ_LIB_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.JAVA_ROOT_PROPERTY_ASENV; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.logging.Level.FINEST; import static org.glassfish.embeddable.GlassFish.Status.DISPOSED; @@ -225,10 +233,19 @@ private void tryAddPomProperties(Bundle bundle, StringBuilder bundleBuilder) thr private void setEnv(Properties bootstrapProperties) { final String installRootValue = bootstrapProperties.getProperty(INSTALL_ROOT_PROP_NAME); if (installRootValue != null && !installRootValue.isEmpty()) { + final Map pairs = Map.of( + "AS_DERBY_INSTALL", DERBY_ROOT_PROPERTY, + "AS_IMQ_LIB", IMQ_LIB_PROPERTY, + "AS_IMQ_BIN", IMQ_BIN_PROPERTY, + "AS_CONFIG", CONFIG_ROOT_PROPERTY, + "AS_JAVA", JAVA_ROOT_PROPERTY_ASENV, + "AS_DEF_DOMAINS_PATH", DOMAINS_ROOT_PROPERTY, + "AS_DEF_NODES_PATH", AGENT_ROOT_PROPERTY); + File installRoot = new File(installRootValue); - System.setProperty(INSTALL_ROOT_PROP_NAME, installRoot.getAbsolutePath()); - final AsenvConf asenv = AsenvConf.parseAsEnv(installRoot); - asenv.mirrorToSystemProperties(); + new EnvToPropsConverter(installRoot.toPath()).convert(pairs).entrySet() + .forEach(e -> System.setProperty(e.getKey(), e.getValue().getAbsolutePath())); + System.setProperty(INSTALL_ROOT_PROP_NAME, installRootValue); System.setProperty(INSTALL_ROOT_URI_PROP_NAME, installRoot.toURI().toString()); } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java index eb44ac350d9..58dd79f2852 100644 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java +++ b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/GlassFishMain.java @@ -17,7 +17,6 @@ package com.sun.enterprise.glassfish.bootstrap; -import com.sun.enterprise.glassfish.bootstrap.cfg.AsenvConf; import com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys; import com.sun.enterprise.glassfish.bootstrap.cfg.OsgiPlatform; import com.sun.enterprise.glassfish.bootstrap.cfg.ServerFiles; @@ -31,6 +30,8 @@ import java.nio.file.Path; import java.util.Properties; +import org.glassfish.main.jdke.props.EnvToPropsConverter; + import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.PLATFORM_PROPERTY_KEY; import static com.sun.enterprise.glassfish.bootstrap.cp.ClassLoaderBuilder.createOSGiFrameworkLauncherCL; import static com.sun.enterprise.glassfish.bootstrap.log.LogFacade.BOOTSTRAP_LOGGER; @@ -43,8 +44,6 @@ */ public class GlassFishMain { - private static final String DEFAULT_DOMAINS_DIR_PROPNAME = "AS_DEF_DOMAINS_PATH"; - // logging system may override original output streams. private static final PrintStream STDOUT = System.out; @@ -193,16 +192,18 @@ private static File getDomainRoot(Properties argsAsProps, File installRoot) { private static File getDefaultDomainsDir(File installRoot) { - AsenvConf asEnv = AsenvConf.parseAsEnv(installRoot); - String dirname = asEnv.getProperty(DEFAULT_DOMAINS_DIR_PROPNAME); - if (!isSet(dirname)) { - throw new RuntimeException(DEFAULT_DOMAINS_DIR_PROPNAME + " is not set."); + String domainsRootSys = "com.sun.aas.domainsRoot"; + String domainsRootEnv = "AS_DEF_DOMAINS_PATH"; + // Can be a just a link + File domainsDirFile = new EnvToPropsConverter(installRoot.toPath()).convert(domainsRootEnv, domainsRootSys); + if (domainsDirFile == null) { + throw new RuntimeException( + "Neither " + domainsRootEnv + " env property nor " + domainsRootSys + " system property is set."); } - File domainsDir = absolutize(new File(dirname)); + File domainsDir = absolutize(domainsDirFile); if (!domainsDir.isDirectory()) { - throw new RuntimeException(DEFAULT_DOMAINS_DIR_PROPNAME + "[" + dirname + "]" - + " is specifying a file that is NOT a directory."); + throw new RuntimeException(domainsDir + " is specifying a file that is NOT a directory."); } return domainsDir; } diff --git a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java b/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java deleted file mode 100644 index 6a42e2f8120..00000000000 --- a/nucleus/core/bootstrap/src/main/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConf.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2024 Contributors to the Eclipse Foundation. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.enterprise.glassfish.bootstrap.cfg; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.LineNumberReader; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static com.sun.enterprise.glassfish.bootstrap.log.LogFacade.BOOTSTRAP_LOGGER; -import static java.nio.charset.StandardCharsets.UTF_8; -import static java.util.logging.Level.FINE; - -/** - * The asenv.conf file content. - */ -// FIXME: duplicates AsenvPropertyReader, but cannot resolve bash defaults. -@Deprecated -public class AsenvConf { - - private static final Pattern LINE = Pattern.compile("(?i)(set +)?([^=]*)=\"?([^\"]*)\"?"); - - private final Properties properties; - - private AsenvConf(File asenv, File configDir) { - this.properties = new Properties(); - if (!asenv.exists()) { - BOOTSTRAP_LOGGER.log(FINE, "{0} not found, ignoring", asenv.getAbsolutePath()); - return; - } - try (LineNumberReader lnReader = new LineNumberReader(new FileReader(asenv, UTF_8))) { - String line = lnReader.readLine(); - // most of the asenv.conf values have surrounding "", remove them - // and on Windows, they start with SET XXX=YYY - while (line != null) { - Matcher m = LINE.matcher(line); - if (m.matches()) { - File configFile = new File(m.group(3)); - if (!configFile.isAbsolute()) { - configFile = new File(configDir, m.group(3)); - if (configFile.exists()) { - properties.put(m.group(2), configFile.getAbsolutePath()); - } else { - properties.put(m.group(2), m.group(3)); - } - } else { - properties.put(m.group(2), m.group(3)); - } - } - line = lnReader.readLine(); - } - } catch (IOException ioe) { - throw new RuntimeException("Error opening asenv.conf file.", ioe); - } - } - - public String getProperty(String key) { - return properties.getProperty(key); - } - - - public void mirrorToSystemProperties() { - for (String name : properties.stringPropertyNames()) { - System.setProperty(name, properties.getProperty(name)); - } - } - - - public Properties toProperties() { - return (Properties) properties.clone(); - } - - - public static AsenvConf parseAsEnv(File installRoot) { - File configDir = new File(installRoot, "config"); - File asenv = getAsEnvConf(configDir); - return new AsenvConf(asenv, configDir); - } - - - /** - * Figures out the asenv.conf file to load. - */ - private static File getAsEnvConf(File configDir) { - String osName = System.getProperty("os.name"); - if (osName.contains("Windows")) { - return new File(configDir, "asenv.bat"); - } - return new File(configDir, "asenv.conf"); - } -} diff --git a/nucleus/core/bootstrap/src/main/java/module-info.java b/nucleus/core/bootstrap/src/main/java/module-info.java index d97f4ba8049..6afb9821b50 100644 --- a/nucleus/core/bootstrap/src/main/java/module-info.java +++ b/nucleus/core/bootstrap/src/main/java/module-info.java @@ -22,9 +22,11 @@ requires java.base; requires java.logging; + requires org.glassfish.main.api.simple; + requires org.glassfish.main.jdke; + requires static org.apache.felix.framework; requires static org.glassfish.annotation.processing.logging; - requires org.glassfish.main.jdke; exports com.sun.enterprise.glassfish.bootstrap.cfg; exports com.sun.enterprise.glassfish.bootstrap.launch; diff --git a/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConfTest.java b/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConfTest.java deleted file mode 100644 index 5fd6d4bf0e3..00000000000 --- a/nucleus/core/bootstrap/src/test/java/com/sun/enterprise/glassfish/bootstrap/cfg/AsenvConfTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2024 Contributors to the Eclipse Foundation. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package com.sun.enterprise.glassfish.bootstrap.cfg; - -import java.io.File; -import java.io.PrintWriter; - -import org.junit.jupiter.api.Test; - -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class AsenvConfTest { - - /** - * This test is used to test the regex pattern of "parseAsEnv" method of "MainHelper.java". - *
- * It creates two temporary files (asenv.conf and asenv.bat) for testing purpose. - * The "parseAsEnv()" method of "MainHelper.java" reads the "asenv.*" file line by line to - * generate the Properties "asenvProps" whose assertion has been done in this unit test. - */ - @Test - void parseAsEnvTest() throws Exception { - File resources = File.createTempFile("helperTestResources", "config"); - resources.delete(); // delete the temp file - resources.mkdir(); // reuse the name for a directory - resources.deleteOnExit(); - File config = new File(resources, "config"); - config.mkdir(); - config.deleteOnExit(); - File asenv_bat = new File(config, "asenv.bat"); // test resource for windows - File asenv_conf = new File(config, "asenv.conf");// test resource for linux - asenv_bat.deleteOnExit(); - asenv_conf.deleteOnExit(); - - PrintWriter pw1 = new PrintWriter(asenv_bat, UTF_8); - pw1.println("set AbcVar=value1"); - pw1.println("SET Avar=\"value2\""); - pw1.println("Set Bvar=\"value3\""); - pw1.println("set setVar=\"value4\""); - pw1.println("set SetVar=value5"); - pw1.println("set seVar=\"value6\""); - pw1.println("set sVar=\"value7\""); - pw1.close(); - PrintWriter pw2 = new PrintWriter(asenv_conf, UTF_8); - pw2.println("AbcVar=value1"); - pw2.println("Avar=\"value2\""); - pw2.println("Bvar=\"value3\""); - pw2.println("setVar=\"value4\""); - pw2.println("SetVar=value5"); - pw2.println("seVar=\"value6\""); - pw2.println("sVar=\"value7\""); - pw2.close(); - - File installRoot = new File(resources.toString()); - AsenvConf asenvProps = AsenvConf.parseAsEnv(installRoot); - assertEquals("value1", asenvProps.getProperty("AbcVar")); - assertEquals("value2", asenvProps.getProperty("Avar")); - assertEquals("value3", asenvProps.getProperty("Bvar")); - assertEquals("value4", asenvProps.getProperty("setVar")); - assertEquals("value5", asenvProps.getProperty("SetVar")); - assertEquals("value6", asenvProps.getProperty("seVar")); - assertEquals("value7", asenvProps.getProperty("sVar")); - } -} 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 009a64fa7b8..dc340138559 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 @@ -46,6 +46,7 @@ import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.DERBY_ROOT_PROP_NAME; import static com.sun.enterprise.glassfish.bootstrap.cfg.BootstrapKeys.INSTALL_ROOT_PROP_NAME; import static java.util.logging.Level.CONFIG; +import static java.util.logging.Level.INFO; /** * This class is responsible for setting up Common Class Loader. As the @@ -171,7 +172,7 @@ private List findDerbyJars(File installDir) { final File derbyLib = derbyHome.resolve("lib").toFile(); if (!derbyLib.exists()) { - LOG.info(KernelLoggerInfo.cantFindDerby); + LOG.log(INFO, KernelLoggerInfo.cantFindDerby, derbyLib); return Collections.emptyList(); } diff --git a/nucleus/core/kernel/src/main/java/org/glassfish/kernel/KernelLoggerInfo.java b/nucleus/core/kernel/src/main/java/org/glassfish/kernel/KernelLoggerInfo.java index 27a9e073568..e9d759f39e2 100644 --- a/nucleus/core/kernel/src/main/java/org/glassfish/kernel/KernelLoggerInfo.java +++ b/nucleus/core/kernel/src/main/java/org/glassfish/kernel/KernelLoggerInfo.java @@ -319,7 +319,7 @@ public static Logger getLogger() { public static final String invalidClassPathEntry = LOGMSG_PREFIX + "-00045"; @LogMessageInfo( - message = "Cannot find javadb client jar file, derby jdbc driver will not be available by default.", + message = "Cannot find javadb client jar file, derby jdbc driver will not be available by default: {0}.", level = "INFO") public static final String cantFindDerby = LOGMSG_PREFIX + "-00046"; diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin index afd2a85244a..1a184116519 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin @@ -16,17 +16,15 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/.. +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac . "${AS_INSTALL}/config/asenv.conf" JAVA=java -#Depends upon Java from asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -ASADMIN_CLASSPATH="$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" -exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain "$@" +exec "$JAVA" ${ASADMIN_JVM_OPTIONS} --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain "$@" 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 84ea758a195..50cebcbe7f5 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/nadmin.bat @@ -23,7 +23,8 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 @@ -32,5 +33,4 @@ goto run set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" -%JAVA% "%ASADMIN_JVM_OPTIONS%" --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" com.sun.enterprise.admin.cli.AdminMain %* +%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" com.sun.enterprise.admin.cli.AdminMain %* diff --git a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv index 7afb22a1065..782668c7356 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv @@ -16,23 +16,20 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/.. +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac . "${AS_INSTALL}/config/asenv.conf" JAVA=java -#Depends upon Java from ../config/asenv.conf if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -ASADMIN_CLASSPATH="$AS_INSTALL/admin-cli.jar:$AS_INSTALL/modules/*" - start_as_main_process () { if [[ "$@" == "--help" ]] || [[ "$@" == "--help=true" ]] || [[ "$@" == "-?" ]]; then - exec "$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain start-domain --help + exec "$JAVA" ${ASADMIN_JVM_OPTIONS} --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain start-domain --help fi # Execute start-domain --dry-run and store the output line by line into an array. @@ -52,7 +49,7 @@ start_as_main_process () { else DRY_RUN_OUTPUT+=("$COM"); fi - done < <("$JAVA" "${ASADMIN_JVM_OPTIONS}" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain start-domain --dry-run "$@" || echo "FAILED") + done < <("$JAVA" ${ASADMIN_JVM_OPTIONS} --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$ASADMIN_CLASSPATH" com.sun.enterprise.admin.cli.AdminMain start-domain --dry-run "$@" || echo "FAILED") if [[ x"$DRY_RUN_OUTPUT" == x ]] then echo -n -e "${DRY_RUN_OUTPUT_BEFORE_DUMP}" >&2 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 b50ca87989d..add308faae3 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/bin/startserv.bat @@ -23,7 +23,8 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 @@ -32,5 +33,4 @@ goto run set JAVA=java :run -set ASADMIN_CLASSPATH="%AS_INSTALL%/admin-cli.jar:%AS_INSTALL%/modules/*" -%JAVA% "%ASADMIN_JVM_OPTIONS%" --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" com.sun.enterprise.admin.cli.AdminMain start-domain --verbose %* +%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ASADMIN_CLASSPATH%" com.sun.enterprise.admin.cli.AdminMain start-domain --verbose %* 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 d43288cb854..6d0bf3a7551 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat @@ -38,13 +38,14 @@ REM directory. REM REM This file uses UTF-8 character encoding. -set AS_IMQ_LIB=..\..\mq\lib -set AS_IMQ_BIN=..\..\mq\bin -set AS_CONFIG=..\config -set AS_INSTALL=.. -set AS_DEF_DOMAINS_PATH=..\domains -set AS_DEF_NODES_PATH=..\nodes -set AS_DERBY_INSTALL=..\..\javadb +set AS_DERBY_INSTALL="%AS_INSTALL%\..\javadb" +set AS_IMQ_LIB="%AS_INSTALL%\..\mq\lib" +set AS_IMQ_BIN="%AS_INSTALL%\..\mq\bin" -set ASADMIN_MODULEPATH="%AS_INSTALL%/lib/bootstrap" +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.validation-api.jar:%AS_INSTALL%\modules\jakarta.xml.bind-api.jar:%AS_INSTALL%\modules\jettison.jar:%AS_INSTALL%\modules\launcher.jar:%AS_INSTALL%\modules\mimepull.jar" diff --git a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf index a7052fe9950..f672a063650 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf @@ -37,13 +37,14 @@ # # This file uses UTF-8 character encoding. -AS_IMQ_LIB="${AS_IMQ_LIB:-../../mq/lib}" -AS_IMQ_BIN="${AS_IMQ_BIN:-../../mq/bin}" -AS_CONFIG="${AS_CONFIG:-../config}" -AS_INSTALL="${AS_INSTALL:-..}" -AS_DEF_DOMAINS_PATH="${AS_DEF_DOMAINS_PATH:-../domains}" -AS_DEF_NODES_PATH="${AS_DEF_NODES_PATH:-../nodes}" -AS_DERBY_INSTALL="${AS_DERBY_INSTALL:-../../javadb}" +export AS_DERBY_INSTALL="${AS_DERBY_INSTALL:-$AS_INSTALL/../javadb}" +export AS_IMQ_LIB="${AS_IMQ_LIB:-$AS_INSTALL/../mq/lib}" +export AS_IMQ_BIN="${AS_IMQ_BIN:-$AS_INSTALL/../mq/bin}" -ASADMIN_MODULEPATH="${AS_INSTALL}/lib/bootstrap" -ASADMIN_JVM_OPTIONS="-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" +export AS_CONFIG="${AS_CONFIG:-$AS_INSTALL/config}" +export AS_DEF_DOMAINS_PATH="${AS_DEF_DOMAINS_PATH:-$AS_INSTALL/domains}" +export AS_DEF_NODES_PATH="${AS_DEF_NODES_PATH:-$AS_INSTALL/nodes}" + +export ASADMIN_MODULEPATH="${AS_INSTALL}/lib/bootstrap" +export ASADMIN_JVM_OPTIONS="-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" +export 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.validation-api.jar:$AS_INSTALL/modules/jakarta.xml.bind-api.jar:$AS_INSTALL/modules/jettison.jar:$AS_INSTALL/modules/launcher.jar:$AS_INSTALL/modules/mimepull.jar" From b3f19b5603e2745b0fcd07966da96bd8124c4473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 17 Oct 2024 00:57:44 +0200 Subject: [PATCH 27/38] TemplateInfoHolder - do not hide the cause of the problem! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../admin/servermgmt/template/TemplateInfoHolder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java index c1abd30aba0..b7fac12f979 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/template/TemplateInfoHolder.java @@ -47,7 +47,7 @@ public TemplateInfoHolder(InputStream inputSteam, String location) throws Domain try { _templateInfo = parse(inputSteam); } catch (Exception e) { - throw new DomainException(_strings.get("failedToParse", TEMPLATE_INFO_SCHEMA_PATH)); + throw new DomainException(_strings.get("failedToParse", TEMPLATE_INFO_SCHEMA_PATH), e); } _location = location; } From 42d3b01df81e880d6242ddd4ab92f5a3c97c0252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 17 Oct 2024 00:59:36 +0200 Subject: [PATCH 28/38] Using ASADMIN_CLASSPATH to limit list of extensions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - If not present, use all jars in the modules directory. Signed-off-by: David Matějček --- .../com/sun/enterprise/admin/cli/AdminMain.java | 17 ++++++++++++++--- .../src/main/resources/config/asenv.bat | 2 +- .../src/main/resources/config/asenv.conf | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) 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 f86a90c9a4c..092dff67b9c 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 @@ -151,9 +151,20 @@ protected Set getExtensions() { } else { throw new Error(strings.get("ExtDirMissing", ext)); } - final File modules = getInstallRoot().resolve("modules").toFile(); - if (modules.isDirectory()) { - locations.add(modules); + final String envClasspath = System.getenv("ASADMIN_CLASSPATH"); + if (envClasspath == null) { + final File modules = getInstallRoot().resolve("modules").toFile(); + if (modules.isDirectory()) { + locations.add(modules); + } + } else { + for (String path : envClasspath.split(":")) { + File file = new File(path); + // nuclesus doesn't contain some files, ie. backup.jar + if (file.exists()) { + locations.add(file); + } + } } return locations; } 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 6d0bf3a7551..444dd9e6307 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.bat @@ -48,4 +48,4 @@ 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.validation-api.jar:%AS_INSTALL%\modules\jakarta.xml.bind-api.jar:%AS_INSTALL%\modules\jettison.jar:%AS_INSTALL%\modules\launcher.jar:%AS_INSTALL%\modules\mimepull.jar" +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/nucleus-common/src/main/resources/config/asenv.conf b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf index f672a063650..f263030a0d2 100644 --- a/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf +++ b/nucleus/distributions/nucleus-common/src/main/resources/config/asenv.conf @@ -47,4 +47,4 @@ export AS_DEF_NODES_PATH="${AS_DEF_NODES_PATH:-$AS_INSTALL/nodes}" export ASADMIN_MODULEPATH="${AS_INSTALL}/lib/bootstrap" export ASADMIN_JVM_OPTIONS="-Djava.util.logging.manager=org.glassfish.main.jul.GlassFishLogManager" -export 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.validation-api.jar:$AS_INSTALL/modules/jakarta.xml.bind-api.jar:$AS_INSTALL/modules/jettison.jar:$AS_INSTALL/modules/launcher.jar:$AS_INSTALL/modules/mimepull.jar" +export 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" From 26ccdef08dbbab645c5abe041aafae0ffc4e59e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 17 Oct 2024 13:31:18 +0200 Subject: [PATCH 29/38] Apostrophes and eval brought back to appclient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../src/main/resources/glassfish/bin/appclient | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient index e34bdff2ab8..2befdb1a79b 100644 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient @@ -75,4 +75,4 @@ ACC_MODULEPATH="${AS_INSTALL}/lib/bootstrap" ACC_INSTALL_LIB="${AS_INSTALL}/lib/install/applications"; ACC_CLASSPATH="${AS_INSTALL}/lib/gf-client.jar:${AS_INSTALL}/lib/appclient/weld-se-shaded.jar:$AS_INSTALL/admin-cli.jar:$AS_DERBY_INSTALL/lib/*:$ACC_INSTALL_LIB/__ds_jdbc_ra/jdbc-ra-ds.jar:$ACC_INSTALL_LIB/__cp_jdbc_ra/jdbc-ra-cp.jar:$ACC_INSTALL_LIB/__xa_jdbc_ra/jdbc-ra-xa.jar:$ACC_INSTALL_LIB/__dm_jdbc_ra/jdbc-ra-dm.jar:$ACC_INSTALL_LIB/jmsra/imqjmsra.jar:${AS_IMQ_LIB}/imq.jar:${AS_IMQ_LIB}/imqadmin.jar:${AS_IMQ_LIB}/imqutil.jar:${AS_IMQ_LIB}/fscontext.jar:$AS_INSTALL/modules/*" -"${ACCJava}" -Dorg.glassfish.appclient.shell $cygwinProp --module-path "${ACC_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "${ACC_CLASSPATH}" org.glassfish.appclient.client.CLIBootstrap "$@" +eval "`"${ACCJava}" -Dorg.glassfish.appclient.shell $cygwinProp --module-path "${ACC_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "${ACC_CLASSPATH}" org.glassfish.appclient.client.CLIBootstrap "$@"`" From 7f58b33694546be535a11bf043452fb4954c2398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 17 Oct 2024 18:43:01 +0200 Subject: [PATCH 30/38] Fixed glassfish-embedded-static classpath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../appclient/client/CLIBootstrap.java | 2 +- .../glassfish-embedded-static-shell/pom.xml | 43 ++++++++++++------- .../ejb/ejb31/embedded/basic/build.xml | 14 +++--- .../ejb/ejb32/embedded/autoclose/build.xml | 24 ++++++----- .../common/glassfish-jdk-extensions/pom.xml | 2 +- nucleus/core/bootstrap-osgi/pom.xml | 2 +- 6 files changed, 53 insertions(+), 34 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 dcbfd00b2da..5f1da73e4ec 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 @@ -1,6 +1,6 @@ /* + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2022 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at diff --git a/appserver/extras/embedded/shell/glassfish-embedded-static-shell/pom.xml b/appserver/extras/embedded/shell/glassfish-embedded-static-shell/pom.xml index 68a3c733b8e..7788ab3a23e 100755 --- a/appserver/extras/embedded/shell/glassfish-embedded-static-shell/pom.xml +++ b/appserver/extras/embedded/shell/glassfish-embedded-static-shell/pom.xml @@ -25,7 +25,7 @@ org.glassfish.main.extras extras 7.0.21-SNAPSHOT - ../../../pom.xml + ../../.. glassfish-embedded-static-shell @@ -35,8 +35,6 @@ ../../../javadb/lib ${path.derby}/derby.jar ${path.derby}/derbyclient.jar ${path.derby}/derbynet.jar ${path.derby}/derbytools.jar ${path.derby}/derbyrun.jar - ../bootstrap - ${path.bootstrap}/glassfish-jul-extension.jar @@ -835,12 +833,6 @@ ${project.version} true
- - org.glassfish.main.common - simple-glassfish-api - ${project.version} - true - org.glassfish.external management-api @@ -876,12 +868,6 @@ ${project.version} true - - org.glassfish.main.core - glassfish - ${project.version} - true - org.glassfish.main.core api-exporter @@ -1363,6 +1349,31 @@ woodstox-core true + + + + org.glassfish.main.common + glassfish-jdk-extensions + ${project.version} + provided + + + org.glassfish.main + glassfish-jul-extension + provided + + + org.glassfish.main.common + simple-glassfish-api + ${project.version} + provided + + + org.glassfish.main.core + glassfish + ${project.version} + provided +
@@ -1379,7 +1390,7 @@ org.glassfish.embedded.static-shell - ${classpath.derby} ${classpath.bootstrap} + ${classpath.derby} ../asadmin/server-mgmt.jar ../../admin-cli.jar org.glassfish.runnablejar.UberMain diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/basic/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/basic/build.xml index aa5a6c4b50c..2d8071804aa 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/basic/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/basic/build.xml @@ -66,13 +66,17 @@ - + + + - + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml index 266ef591620..5c1de87e73c 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml @@ -63,16 +63,20 @@ - - - - - - - + + + + + + + + + diff --git a/nucleus/common/glassfish-jdk-extensions/pom.xml b/nucleus/common/glassfish-jdk-extensions/pom.xml index c93e0d96ee0..f33a9cca458 100755 --- a/nucleus/common/glassfish-jdk-extensions/pom.xml +++ b/nucleus/common/glassfish-jdk-extensions/pom.xml @@ -22,7 +22,7 @@ org.glassfish.main.common nucleus-common - 7.0.19-SNAPSHOT + 7.0.21-SNAPSHOT glassfish-jdk-extensions diff --git a/nucleus/core/bootstrap-osgi/pom.xml b/nucleus/core/bootstrap-osgi/pom.xml index 3dd32a7cc52..0654a9cf289 100755 --- a/nucleus/core/bootstrap-osgi/pom.xml +++ b/nucleus/core/bootstrap-osgi/pom.xml @@ -23,7 +23,7 @@ org.glassfish.main.core nucleus-core - 7.0.19-SNAPSHOT + 7.0.21-SNAPSHOT glassfish-osgi-bootstrap From 1356964b4e57608e8660c592611c7fb3e89ff57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Fri, 18 Oct 2024 01:01:14 +0200 Subject: [PATCH 31/38] Fixed ejb embedded tests + in master passes 32 tests, here 33 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../connectors/jms/JMSLoggerInfo.java | 18 +- .../connectors/jms/util/JmsRaUtil.java | 275 +++++++++--------- .../devtests/ejb/ejb31/embedded/build.xml | 55 ++-- .../ejb31/embedded/datasourcedef/build.xml | 3 + .../ejb/ejb31/embedded/ejbandwar/build.xml | 6 + .../ejb/ejb31/embedded/ejbinwar/build.xml | 12 + .../ejb/ejb31/embedded/embedasync/build.xml | 3 + .../ejb/ejb31/embedded/jaxrs/build.xml | 9 +- .../ejb/ejb31/embedded/manifestonly/build.xml | 3 + .../devtests/ejb/ejb31/embedded/mdb/build.xml | 5 + .../embedded/modulewithappname/build.xml | 3 + .../embedded/modulewithinheritance/build.xml | 3 + .../ejb31/embedded/modulewithlibs/build.xml | 3 + .../embedded/modulewithmanifest/build.xml | 3 + .../ejb/ejb31/embedded/profile/build.xml | 3 + .../ejb/ejb31/embedded/remote/build.xml | 3 + .../ejb/ejb31/embedded/skipjar/build.xml | 6 + .../ejb/ejb31/embedded/testclose/build.xml | 3 + .../ejb/ejb31/embedded/timertest/build.xml | 3 + .../ejb31/embedded/twocontainers/build.xml | 9 +- .../ejb/ejb31/embedded/twomodules/build.xml | 11 +- .../embedded/twomoduleswithlibs/build.xml | 10 +- 22 files changed, 248 insertions(+), 201 deletions(-) diff --git a/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/JMSLoggerInfo.java b/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/JMSLoggerInfo.java index 92fa2efbdf3..5e91a44d14f 100644 --- a/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/JMSLoggerInfo.java +++ b/appserver/jms/jms-core/src/main/java/com/sun/enterprise/connectors/jms/JMSLoggerInfo.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -183,25 +184,10 @@ public static Logger getLogger() { ) public static final String MDB_CONFIG_EXCEPTION = LOGMSG_PREFIX + "-00023"; - @LogMessageInfo(message = "MQ Resource adapter upgrade started.") + @LogMessageInfo(message = "MQ Resource adapter upgrade from {0} to {1} started.") public static final String JMSRA_UPGRADE_STARTED = LOGMSG_PREFIX + "-00024"; @LogMessageInfo(message = "MQ Resource adapter upgrade completed.") public static final String JMSRA_UPGRADE_COMPLETED = LOGMSG_PREFIX + "-00025"; - @LogMessageInfo( - message = "Upgrading a MQ resource adapter failed : {0}", - level = "WARNING", - cause = "unknown", - action = "unknown" - ) - public static final String JMSRA_UPGRADE_FAILED = LOGMSG_PREFIX + "-00026"; - - @LogMessageInfo( - message = "Check for a new version of MQ installation failed : {0}", - level = "WARNING", - cause = "unknown", - action = "unknown" - ) - public static final String JMSRA_UPGRADE_CHECK_FAILED = LOGMSG_PREFIX + "-00027"; } 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 7fe55f88a23..7647e291620 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,7 +17,6 @@ package com.sun.enterprise.connectors.jms.util; -import com.sun.appserv.connectors.internal.api.ConnectorConstants; import com.sun.appserv.connectors.internal.api.ConnectorRuntimeException; import com.sun.enterprise.config.serverbeans.Cluster; import com.sun.enterprise.config.serverbeans.Config; @@ -29,13 +28,15 @@ import com.sun.enterprise.connectors.jms.system.MQAddressList; import com.sun.enterprise.deployment.ConnectorConfigProperty; import com.sun.enterprise.deployment.ConnectorDescriptor; -import com.sun.enterprise.util.SystemPropertyConstants; +import com.sun.enterprise.util.io.FileUtils; import com.sun.enterprise.util.zip.ZipFile; import com.sun.enterprise.util.zip.ZipFileException; import java.io.File; import java.io.FileInputStream; +import java.nio.file.Path; import java.util.List; +import java.util.Objects; import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.logging.Level; @@ -46,16 +47,23 @@ import org.glassfish.internal.api.RelativePathResolver; import org.jvnet.hk2.config.types.Property; +import static com.sun.appserv.connectors.internal.api.ConnectorConstants.DEFAULT_JMS_ADAPTER; +import static com.sun.enterprise.util.SystemPropertyConstants.IMQ_LIB_PROPERTY; +import static com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY; +import static java.util.logging.Level.FINE; +import static java.util.logging.Level.FINEST; +import static java.util.logging.Level.INFO; +import static java.util.logging.Level.WARNING; + public class JmsRaUtil { private final static String MQ_RAR = "imqjmsra.rar"; - private final String SYSTEM_APP_DIR = - "lib" + File.separator + "install" + File.separator + "applications"; + /** lib/install/applications */ + private static final Path SYSTEM_APP_DIR = Path.of("lib", "install", "applications"); - private final String MQ_RAR_MANIFEST = - ConnectorConstants.DEFAULT_JMS_ADAPTER + File.separator + "META-INF" - + File.separator + "MANIFEST.MF"; + /** jmsra/META-INF/MANIFEST.MF */ + private static final Path MQ_RAR_MANIFEST = Path.of("META-INF", "MANIFEST.MF"); // Manifest version tag. private final static String MANIFEST_TAG = "Implementation-Version"; @@ -79,10 +87,10 @@ public class JmsRaUtil { private int reconnectDelayInSeconds = DEFAULT_RECONNECT_DELAY; private int reconnectMaxRetries = DEFAULT_RECONNECT_RETRIES; - private boolean reconnectEnabled = false; + private boolean reconnectEnabled; - JmsService js = null; - MQAddressList list = null; + JmsService js; + MQAddressList list; private static final Logger _logger = JMSLoggerInfo.getLogger(); @@ -90,12 +98,13 @@ public JmsRaUtil() throws ConnectorRuntimeException { this(null); } + public JmsRaUtil(JmsService js) throws ConnectorRuntimeException { try { if (js != null) { - this.js = js; + this.js = js; } else { - this.js = Globals.get(JmsService.class); + this.js = Globals.get(JmsService.class); } list = new MQAddressList(this.js); // if (isClustered() && ! this.js.getType().equals( @@ -109,34 +118,39 @@ public JmsRaUtil(JmsService js) throws ConnectorRuntimeException { } } - public void setupAddressList() throws ConnectorRuntimeException{ - try { - list.setup(); - } catch (Exception e) { - throw handleException(e); - } + + public void setupAddressList() throws ConnectorRuntimeException { + try { + list.setup(); + } catch (Exception e) { + throw handleException(e); + } } + public String getUrl() { - try { + try { return list.toString(); - } catch (Exception e) { - return null; - } + } catch (Exception e) { + return null; + } } + public static boolean isClustered(List clusters, String instanceName) { - return (enableClustering() && isServerClustered(clusters, - instanceName)); - } - /** + return (enableClustering() && isServerClustered(clusters, instanceName)); + } + + + /** * Return true if the given server instance is part of a cluster. */ - public static boolean isServerClustered(List clusters, String instanceName) - { + public static boolean isServerClustered(List clusters, String instanceName) { return (getClusterForServer(clusters, instanceName) != null); } - public static Cluster getClusterForServer(List clusters, String instanceName){ + + + public static Cluster getClusterForServer(List clusters, String instanceName) { //Return the server only if it is part of a cluster (i.e. only if a cluster //has a reference to it). for (Object cluster : clusters) { @@ -159,15 +173,15 @@ private static boolean enableClustering() { * this flag is set to false. Default is true. */ String enablecluster = System.getProperty(ENABLE_AUTO_CLUSTERING); - _logger.log(Level.FINE, "Sun MQ Auto cluster system property " + enablecluster); + _logger.log(FINE, "Sun MQ Auto cluster system property " + enablecluster); if ((enablecluster != null) && (enablecluster.trim().equals("false"))){ - _logger.log(Level.FINE, "Disabling Sun MQ Auto Clustering"); + _logger.log(FINE, "Disabling Sun MQ Auto Clustering"); return false; } } catch (Exception e) { } - _logger.log(Level.FINE, "Enabling Sun MQ Auto Clustering"); + _logger.log(FINE, "Enabling Sun MQ Auto Clustering"); return true; } @@ -202,14 +216,11 @@ public String getAddressListBehaviour() { public void setMdbContainerProperties(){ MdbContainer mdbc = null; try { - mdbc = Globals.get(MdbContainer.class); - - } - catch (Exception e) { - _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[]{e.getMessage()}); - if (_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, e.getClass().getName(), e); + } catch (Exception e) { + _logger.log(WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[] {e.getMessage()}); + if (_logger.isLoggable(FINE)) { + _logger.log(FINE, e.getClass().getName(), e); } } @@ -239,7 +250,7 @@ else if (name.equals reconnectDelayInSeconds = Integer.parseInt(p.getValue()); } catch (Exception e) { - _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, + _logger.log(WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[]{e.getMessage()}); } } @@ -248,7 +259,7 @@ else if (name.equals(propName_reconnect_max_retries)) { reconnectMaxRetries = Integer.parseInt(p.getValue()); } catch (Exception e) { - _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, + _logger.log(WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[]{e.getMessage()}); } } @@ -258,15 +269,15 @@ else if (name.equals cmtMaxRuntimeExceptions = Integer.parseInt(p.getValue()); } catch (Exception e) { - _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, + _logger.log(WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[]{e.getMessage()}); } } } catch (Exception e) { - _logger.log(Level.WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, + _logger.log(WARNING, JMSLoggerInfo.MDB_CONFIG_EXCEPTION, new Object[]{e.getMessage()}); - if (_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, e.getClass().getName(), e); + if (_logger.isLoggable(FINE)) { + _logger.log(FINE, e.getClass().getName(), e); } } } @@ -278,8 +289,8 @@ else if (name.equals if (reconnectMaxRetries < 0) { reconnectMaxRetries = DEFAULT_RECONNECT_RETRIES; } - if (_logger.isLoggable(Level.FINE)) { - _logger.log(Level.FINE, + if (_logger.isLoggable(FINE)) { + _logger.log(FINE, propName_reconnect_delay_in_seconds+"="+ reconnectDelayInSeconds +", "+ propName_reconnect_max_retries+ "="+reconnectMaxRetries + ", "+ @@ -295,20 +306,18 @@ else if (name.equals } public void configureDescriptor(ConnectorDescriptor cd) { - Object[] envProps = cd.getConfigProperties().toArray(); for (Object envProp2 : envProps) { - ConnectorConfigProperty envProp = (ConnectorConfigProperty ) envProp2; + ConnectorConfigProperty envProp = (ConnectorConfigProperty) envProp2; String name = envProp.getName(); - if (!name.equals("ConnectionURL")) { - continue; - } + if (!name.equals("ConnectionURL")) { + continue; + } String userValue = getUrl(); if (userValue != null) { cd.removeConfigProperty(envProp); - cd.addConfigProperty(new ConnectorConfigProperty ( - name, userValue, userValue, envProp.getType())); + cd.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue, envProp.getType())); } } @@ -321,107 +330,90 @@ public void configureDescriptor(ConnectorDescriptor cd) { * directory. */ public void upgradeIfNecessary() { + String imqLibPath = System.getProperty(IMQ_LIB_PROPERTY); + if (imqLibPath == null) { + _logger.log(Level.SEVERE, "IMQ lib root system property not set: " + IMQ_LIB_PROPERTY); + return; + } - String installedMqVersion = null; - String deployedMqVersion = null; + String installRoot = System.getProperty(INSTALL_ROOT_PROPERTY); + if (installRoot == null) { + _logger.log(Level.SEVERE, "Install root system property not set: " + INSTALL_ROOT_PROPERTY); + return; + } + final Path imqLib = Path.of(imqLibPath); + 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 { - installedMqVersion = getInstalledMqVersion(); - _logger.log(Level.FINE,"installedMQVersion :: " + installedMqVersion); - deployedMqVersion = getDeployedMqVersion(); - _logger.log(Level.FINE,"deployedMQVersion :: " + deployedMqVersion); - }catch (Exception e) { - return; + installedMqVersion = getInstalledMqVersion(imqLibRar); + _logger.log(FINE, "installedMQVersion: {0}", installedMqVersion); + deployedMqVersion = getDeployedMqVersion(deployedDir); + _logger.log(FINE, "deployedMQVersion: {0}", deployedMqVersion); + } catch (Exception e) { + throw new IllegalStateException("Upgrade failed - could not resolve deployed and installed version.", e); } - String deployed_dir = - java.lang. System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY) - + File.separator + SYSTEM_APP_DIR + File.separator - + ConnectorConstants.DEFAULT_JMS_ADAPTER; + if (installedMqVersion == null) { + _logger.log(INFO, "No JMS RA installation RAR found on path {0}. Nothing for upgrade.", imqLibRar); + return; + } // If the Manifest entry has different versions, then attempt to // explode the MQ resource adapter. - if (!installedMqVersion.equals(deployedMqVersion)) { - try { - _logger.log(Level.INFO, JMSLoggerInfo.JMSRA_UPGRADE_STARTED); - ZipFile rarFile = new ZipFile(System.getProperty - (SystemPropertyConstants.IMQ_LIB_PROPERTY) + - File.separator + MQ_RAR, deployed_dir); - rarFile.explode(); - _logger.log(Level.INFO, JMSLoggerInfo.JMSRA_UPGRADE_COMPLETED); - } catch(ZipFileException ze) { - _logger.log(Level.SEVERE, JMSLoggerInfo.JMSRA_UPGRADE_FAILED, - new Object[]{ze.getMessage()}); - } + if (!Objects.equals(installedMqVersion, deployedMqVersion)) { + try { + _logger.log(INFO, JMSLoggerInfo.JMSRA_UPGRADE_STARTED, + new Object[] {deployedMqVersion, installedMqVersion}); + FileUtils.whack(deployedDir.toFile()); + ZipFile rarFile = new ZipFile(imqLibRar, deployedDir.toFile()); + rarFile.explode(); + _logger.log(INFO, JMSLoggerInfo.JMSRA_UPGRADE_COMPLETED); + } catch (ZipFileException e) { + _logger.log(Level.SEVERE, "Upgrading a MQ resource adapter failed", e); + } } + } + + /** Full path of installed Mq Client library */ + private String getInstalledMqVersion(final File imqLibRar) throws Exception { + // This is for a file based install RAR has to be present in this location + // AS_INSTALL/../imq/lib, but ca be set also to another place. + if (!imqLibRar.exists()) { + return null; + } + _logger.log(FINEST, "Found installation JMS RAR: {0}", imqLibRar); + try (JarFile jFile = new JarFile(imqLibRar)) { + Manifest mf = jFile.getManifest(); + return mf.getMainAttributes().getValue(MANIFEST_TAG); + } } - private String getInstalledMqVersion() throws Exception { - String ver = null; - // Full path of installed Mq Client library - String installed_dir = - System.getProperty(SystemPropertyConstants.IMQ_LIB_PROPERTY); - String jarFile = installed_dir + File.separator + MQ_RAR; - _logger.log(Level.FINE,"Installed MQ JAR " + jarFile); - JarFile jFile = null; - try { - if ((new File(jarFile)).exists()) { - /* This is for a file based install - * RAR has to be present in this location - * ASHOME/imq/lib - */ - jFile = new JarFile(jarFile); - } else { - /* This is for a package based install - * RAR has to be present in this location - * /usr/lib - */ - jFile = new JarFile(installed_dir + File.separator + ".." + File.separator + MQ_RAR); - } - Manifest mf = jFile.getManifest(); - ver = mf.getMainAttributes().getValue(MANIFEST_TAG); - return ver; - } catch (Exception e) { - _logger.log(Level.WARNING, JMSLoggerInfo.JMSRA_UPGRADE_CHECK_FAILED, - new Object[]{e.getMessage() + ":" + jarFile}); - throw e; - } finally { - if (jFile != null) { - jFile.close(); - } - } + /** Full path of Mq client library that is deployed in appserver. */ + private String getDeployedMqVersion(Path deployedDir) throws Exception { + File manifestFile = deployedDir.resolve(MQ_RAR_MANIFEST).toFile(); + if (!manifestFile.exists()) { + return null; + } + _logger.log(FINEST, "Found deployed JMS RA Manifest file {0}", manifestFile); + try (FileInputStream fis = new FileInputStream(manifestFile)) { + Manifest mf = new Manifest(fis); + return mf.getMainAttributes().getValue(MANIFEST_TAG); + } } - private String getDeployedMqVersion() throws Exception { - String ver = null; - // Full path of Mq client library that is deployed in appserver. - String deployed_dir = - System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY) - + File.separator + SYSTEM_APP_DIR; - String manifestFile = deployed_dir + File.separator + - MQ_RAR_MANIFEST; - _logger.log(Level.FINE,"Deployed MQ version Manifest file" + manifestFile); - try (FileInputStream fis = new FileInputStream(manifestFile)) { - Manifest mf = new Manifest(fis); - ver = mf.getMainAttributes().getValue(MANIFEST_TAG); - return ver; - } catch (Exception e) { - _logger.log(Level.WARNING, JMSLoggerInfo.JMSRA_UPGRADE_CHECK_FAILED, - new Object[]{e.getMessage() + ":" + manifestFile}); - throw e; - } - } - - private static ConnectorRuntimeException handleException(Exception e) { - ConnectorRuntimeException cre = - new ConnectorRuntimeException(e.getMessage()); + + private static ConnectorRuntimeException handleException(Exception e) { + ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); return cre; } - public static String getJMSPropertyValue(Server as){ + public static String getJMSPropertyValue(Server as) { SystemProperty sp = as.getSystemProperty("JMS_PROVIDER_PORT"); if (sp != null) { return sp.getValue(); @@ -447,16 +439,17 @@ public static String getJMSPropertyValue(Server as){ return null; } - public static String getUnAliasedPwd(String alias){ - try{ + + public static String getUnAliasedPwd(String alias) { + try { String unalisedPwd = RelativePathResolver.getRealPasswordFromAlias(alias); if (unalisedPwd != null && "".equals(unalisedPwd)) { return unalisedPwd; } - }catch(Exception e){ + } catch (Exception e) { } - return alias; + return alias; } } diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/build.xml index a065ef7c6f3..4c978f78731 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/build.xml @@ -195,32 +195,31 @@ ant all (Executes all the ejb-ejb31-embedded tests) - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/datasourcedef/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/datasourcedef/build.xml index 9ac34f4d87d..5b8b21406f4 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/datasourcedef/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/datasourcedef/build.xml @@ -68,8 +68,11 @@ + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbandwar/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbandwar/build.xml index f83a71cff30..0f9ed89bdef 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbandwar/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbandwar/build.xml @@ -94,8 +94,11 @@ + + @@ -107,8 +110,11 @@ + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbinwar/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbinwar/build.xml index 0a621f85993..3348442eb91 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbinwar/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/ejbinwar/build.xml @@ -85,8 +85,11 @@ + + @@ -97,8 +100,11 @@ + + @@ -110,8 +116,11 @@ + + @@ -122,8 +131,11 @@ + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/embedasync/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/embedasync/build.xml index 511682c8615..48cd652d3b5 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/embedasync/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/embedasync/build.xml @@ -68,8 +68,11 @@ + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/jaxrs/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/jaxrs/build.xml index 41a99673762..84be1017f65 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/jaxrs/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/jaxrs/build.xml @@ -79,9 +79,7 @@ - @@ -91,7 +89,9 @@ + @@ -129,12 +129,15 @@ + + - + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/manifestonly/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/manifestonly/build.xml index c344c7ecad7..34327f93c10 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/manifestonly/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/manifestonly/build.xml @@ -85,8 +85,11 @@ + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml index 582eb3cd711..6e7a5996c49 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml @@ -133,11 +133,16 @@ + + + + - + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomodules/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomodules/build.xml index 7e92846f116..0e42cd5da81 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomodules/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomodules/build.xml @@ -72,10 +72,13 @@ - + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomoduleswithlibs/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomoduleswithlibs/build.xml index 68599e6ea38..99cdd313d23 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomoduleswithlibs/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/twomoduleswithlibs/build.xml @@ -108,14 +108,13 @@ + + - @@ -124,8 +123,11 @@ + + From cdd51af45c0445a3239649475d7146bbfe26647b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Fri, 18 Oct 2024 12:15:16 +0200 Subject: [PATCH 32/38] Jar index removed again - support was removed in JDK18 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://bugs.openjdk.org/browse/JDK-8273473 Signed-off-by: David Matějček --- nucleus/parent/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/nucleus/parent/pom.xml b/nucleus/parent/pom.xml index a5c183b6883..1864b8e8514 100644 --- a/nucleus/parent/pom.xml +++ b/nucleus/parent/pom.xml @@ -2019,7 +2019,6 @@ maven-jar-plugin - true false From 78cfac75d4f4706cd913d6bbb92429219884a2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Thu, 7 Nov 2024 20:35:49 +0100 Subject: [PATCH 33/38] GLASSFISH_HOME replaced by S1AS_HOME as the first is not always set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml index 6e7a5996c49..4f0e20d8904 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/embedded/mdb/build.xml @@ -141,8 +141,8 @@ - - + + + true From 4093d24d7745519f2a0b6b3623f95de75f8907fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Sun, 10 Nov 2024 17:28:35 +0100 Subject: [PATCH 35/38] Fixed asadmin verify-domain-xml command + added test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Globals is not used in local commands and might not be available on classpath Signed-off-by: David Matějček --- .../test/AsadminVerifyDomainXmlITest.java | 39 +++++++++++++++++++ .../cli/VerifyDomainXmlCommand.java | 4 +- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminVerifyDomainXmlITest.java diff --git a/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminVerifyDomainXmlITest.java b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminVerifyDomainXmlITest.java new file mode 100644 index 00000000000..dc589033f82 --- /dev/null +++ b/appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/AsadminVerifyDomainXmlITest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.main.admin.test; + +import org.glassfish.main.itest.tools.GlassFishTestEnvironment; +import org.glassfish.main.itest.tools.asadmin.Asadmin; +import org.junit.jupiter.api.Test; + +import static org.glassfish.main.itest.tools.asadmin.AsadminResultMatcher.asadminOK; +import static org.hamcrest.MatcherAssert.assertThat; + + +/** + * @author David Matejcek + */ +public class AsadminVerifyDomainXmlITest { + + private static final Asadmin ASADMIN = GlassFishTestEnvironment.getAsadmin(); + + + @Test + public void verifyDomainXml() { + assertThat(ASADMIN.exec("verify-domain-xml"), asadminOK()); + } +} diff --git a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java index c659f29210e..f66d6db53cb 100644 --- a/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java +++ b/nucleus/admin/server-mgmt/src/main/java/com/sun/enterprise/admin/servermgmt/cli/VerifyDomainXmlCommand.java @@ -17,6 +17,7 @@ package com.sun.enterprise.admin.servermgmt.cli; +import com.sun.enterprise.admin.cli.CLICommand; import com.sun.enterprise.config.serverbeans.Domain; import com.sun.enterprise.module.ModulesRegistry; import com.sun.enterprise.module.single.StaticModulesRegistry; @@ -33,7 +34,6 @@ import org.glassfish.api.admin.CommandException; import org.glassfish.api.admin.CommandValidationException; import org.glassfish.hk2.api.ServiceLocator; -import org.glassfish.internal.api.Globals; import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import org.jvnet.hk2.annotations.Service; import org.jvnet.hk2.config.ConfigParser; @@ -85,7 +85,7 @@ protected int executeCommand() throws CommandException, CommandValidationExcepti final URL[] urlsA = urls.toArray(new URL[urls.size()]); PrivilegedAction action = () -> new GlassfishUrlClassLoader("DomainXmlVerifier", urlsA, - Globals.class.getClassLoader()); + CLICommand.class.getClassLoader()); ClassLoader cl = AccessController.doPrivileged(action); ModulesRegistry registry = new StaticModulesRegistry(cl); ServiceLocator serviceLocator = registry.createServiceLocator("default"); From 70ae204d7791496bb47e937f3d858976e9b2a014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Sun, 10 Nov 2024 21:40:40 +0100 Subject: [PATCH 36/38] Adapted webservices-scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../src/main/resources/glassfish/bin/schemagen | 15 +++++++-------- .../main/resources/glassfish/bin/schemagen.bat | 12 +++++++----- .../src/main/resources/glassfish/bin/wsgen | 15 +++++++-------- .../src/main/resources/glassfish/bin/wsgen.bat | 12 +++++++----- .../src/main/resources/glassfish/bin/wsimport | 15 +++++++-------- .../src/main/resources/glassfish/bin/wsimport.bat | 12 +++++++----- .../src/main/resources/glassfish/bin/xjc | 15 +++++++-------- .../src/main/resources/glassfish/bin/xjc.bat | 12 +++++++----- 8 files changed, 56 insertions(+), 52 deletions(-) diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen index 96a6500a040..509e86f330b 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen @@ -1,5 +1,6 @@ -#!/bin/sh +#!/bin/bash # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -15,19 +16,17 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/.. - +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac - -AS_INSTALL_LIB="$AS_INSTALL/modules" . "${AS_INSTALL}/config/asenv.conf" -JAVA=java -#Depends upon Java from ../config/asenv.conf +JAVA=java if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" -cp "$AS_INSTALL_LIB/webservices-api-osgi.jar:$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/jakarta.xml.bind-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar:$AS_INSTALL_LIB/jakarta.activation-api.jar:$AS_INSTALL_LIB/angus-activation.jar" com.sun.tools.jxc.SchemaGeneratorFacade "$@" +AS_MODULES="$AS_INSTALL/modules" +WS_CLASSPATH="$AS_MODULES/webservices-api-osgi.jar:$AS_MODULES/webservices-osgi.jar:$AS_MODULES/jakarta.xml.bind-api.jar:$AS_MODULES/jaxb-osgi.jar:$AS_MODULES/jakarta.activation-api.jar:$AS_MODULES/angus-activation.jar" +exec "$JAVA" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$WS_CLASSPATH" com.sun.tools.jxc.SchemaGeneratorFacade "$@" diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen.bat b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen.bat index a6ee72edc3b..836204835ff 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen.bat +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/schemagen.bat @@ -1,6 +1,6 @@ @echo off - REM +REM Copyright (c) 2024 Contributors to the Eclipse Foundation REM Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved. REM REM This program and the accompanying materials are made available under the @@ -16,7 +16,6 @@ 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 @@ -24,13 +23,16 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 -%JAVA% -cp "%~dp0..\modules\webservices-api-osgi.jar;%~dp0..\modules\webservices-osgi.jar;%~dp0..\modules\jakarta.xml.bind-api.jar;%~dp0..\modules\jaxb-osgi.jar;%~dp0..\modules\jakarta.activation-api.jar;%~dp0..\modules\angus-activation.jar" com.sun.tools.jxc.SchemaGeneratorFacade %* +set AS_MODULES=%AS_INSTALL%\modules +set WS_CLASSPATH=%AS_MODULES%\webservices-api-osgi.jar;%AS_MODULES%\webservices-osgi.jar:%AS_MODULES%\jakarta.xml.bind-api.jar:%AS_MODULES%\jaxb-osgi.jar:%AS_MODULES%\jakarta.activation-api.jar:%AS_MODULES%\angus-activation.jar +%JAVA% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%WS_CLASSPATH%" com.sun.tools.jxc.SchemaGeneratorFacade %* diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen index bf154804ef6..b13d5c62b52 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen @@ -1,5 +1,6 @@ -#!/bin/sh +#!/bin/bash # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -15,19 +16,17 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/.. - +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac - -AS_INSTALL_LIB="$AS_INSTALL/modules" . "${AS_INSTALL}/config/asenv.conf" -JAVA=java -#Depends upon Java from ../config/asenv.conf +JAVA=java if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" $WSGEN_OPTS -cp "$AS_INSTALL_LIB/webservices-api-osgi.jar:$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/jakarta.xml.bind-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar:$AS_INSTALL_LIB/jakarta.activation-api.jar:$AS_INSTALL_LIB/angus-activation.jar" com.sun.tools.ws.WsGen "$@" +AS_MODULES="$AS_INSTALL/modules" +WS_CLASSPATH="$AS_MODULES/webservices-api-osgi.jar:$AS_MODULES/webservices-osgi.jar:$AS_MODULES/jakarta.xml.bind-api.jar:$AS_MODULES/jaxb-osgi.jar:$AS_MODULES/jakarta.activation-api.jar:$AS_MODULES/angus-activation.jar" +exec "$JAVA" $WSGEN_OPTS --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$WS_CLASSPATH" com.sun.tools.ws.WsGen "$@" diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen.bat b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen.bat index 38694bab5af..f6b9e53c058 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen.bat +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsgen.bat @@ -1,6 +1,6 @@ @echo off - REM +REM Copyright (c) 2024 Contributors to the Eclipse Foundation REM Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved. REM REM This program and the accompanying materials are made available under the @@ -16,7 +16,6 @@ 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 @@ -24,13 +23,16 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 -%JAVA% %WSGEN_OPTS% -cp "%~dp0..\modules\webservices-api-osgi.jar;%~dp0..\modules\webservices-osgi.jar;%~dp0..\modules\jakarta.xml.bind-api.jar;%~dp0..\modules\jaxb-osgi.jar;%~dp0..\modules\jakarta.activation-api.jar;%~dp0..\modules\angus-activation.jar" com.sun.tools.ws.WsGen %* +set AS_MODULES=%AS_INSTALL%\modules +set WS_CLASSPATH=%AS_MODULES%\webservices-api-osgi.jar;%AS_MODULES%\webservices-osgi.jar:%AS_MODULES%\jakarta.xml.bind-api.jar:%AS_MODULES%\jaxb-osgi.jar:%AS_MODULES%\jakarta.activation-api.jar:%AS_MODULES%\angus-activation.jar +%JAVA% %WSGEN_OPTS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%WS_CLASSPATH%" com.sun.tools.ws.WsGen %* diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport index 5792b171f4c..2c4d96c0507 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport @@ -1,5 +1,6 @@ -#!/bin/sh +#!/bin/bash # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -15,19 +16,17 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/.. - +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac - -AS_INSTALL_LIB="$AS_INSTALL/modules" . "${AS_INSTALL}/config/asenv.conf" -JAVA=java -#Depends upon Java from ../config/asenv.conf +JAVA=java if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" $WSIMPORT_OPTS -cp "$AS_INSTALL_LIB/webservices-api-osgi.jar:$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/jakarta.xml.bind-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar:$AS_INSTALL_LIB/jakarta.activation-api.jar:$AS_INSTALL_LIB/angus-activation.jar" com.sun.tools.ws.WsImport "$@" +AS_MODULES="$AS_INSTALL/modules" +WS_CLASSPATH="$AS_MODULES/webservices-api-osgi.jar:$AS_MODULES/webservices-osgi.jar:$AS_MODULES/jakarta.xml.bind-api.jar:$AS_MODULES/jaxb-osgi.jar:$AS_MODULES/jakarta.activation-api.jar:$AS_MODULES/angus-activation.jar" +exec "$JAVA" $WSIMPORT_OPTS --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$WS_CLASSPATH" com.sun.tools.ws.WsImport "$@" diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport.bat b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport.bat index 7384523c42f..4ba3e4ab309 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport.bat +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/wsimport.bat @@ -1,6 +1,6 @@ @echo off - REM +REM Copyright (c) 2024 Contributors to the Eclipse Foundation REM Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved. REM REM This program and the accompanying materials are made available under the @@ -16,7 +16,6 @@ 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 @@ -24,13 +23,16 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 -%JAVA% %WSIMPORT_OPTS% -cp "%~dp0..\modules\webservices-api-osgi.jar;%~dp0..\modules\webservices-osgi.jar;%~dp0..\modules\jakarta.xml.bind-api.jar;%~dp0..\modules\jaxb-osgi.jar;%~dp0..\modules\jakarta.activation-api.jar;%~dp0..\modules\angus-activation.jar" com.sun.tools.ws.WsImport %* +set AS_MODULES=%AS_INSTALL%\modules +set WS_CLASSPATH=%AS_MODULES%\webservices-api-osgi.jar;%AS_MODULES%\webservices-osgi.jar:%AS_MODULES%\jakarta.xml.bind-api.jar:%AS_MODULES%\jaxb-osgi.jar:%AS_MODULES%\jakarta.activation-api.jar:%AS_MODULES%\angus-activation.jar +%JAVA% %WSIMPORT_OPTS% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%WS_CLASSPATH%" com.sun.tools.ws.WsImport %* diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc index 980dbf252e6..4da45d353c2 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc @@ -1,5 +1,6 @@ -#!/bin/sh +#!/bin/bash # +# Copyright (c) 2024 Contributors to the Eclipse Foundation # Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. # # This program and the accompanying materials are made available under the @@ -15,19 +16,17 @@ # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 # -AS_INSTALL=`dirname "$0"`/.. - +export AS_INSTALL="$(dirname $(realpath -s $0))/.." case "`uname`" in CYGWIN*) AS_INSTALL=`cygpath --windows $AS_INSTALL` esac - -AS_INSTALL_LIB="$AS_INSTALL/modules" . "${AS_INSTALL}/config/asenv.conf" -JAVA=java -#Depends upon Java from ../config/asenv.conf +JAVA=java if [ ${AS_JAVA} ]; then JAVA=${AS_JAVA}/bin/java fi -exec "$JAVA" -cp "$AS_INSTALL_LIB/webservices-api-osgi.jar:$AS_INSTALL_LIB/webservices-osgi.jar:$AS_INSTALL_LIB/jakarta.xml.bind-api.jar:$AS_INSTALL_LIB/jaxb-osgi.jar:$AS_INSTALL_LIB/jakarta.activation-api.jar:$AS_INSTALL_LIB/angus-activation.jar" com.sun.tools.xjc.Driver "$@" +AS_MODULES="$AS_INSTALL/modules" +WS_CLASSPATH="$AS_MODULES/webservices-api-osgi.jar:$AS_MODULES/webservices-osgi.jar:$AS_MODULES/jakarta.xml.bind-api.jar:$AS_MODULES/jaxb-osgi.jar:$AS_MODULES/jakarta.activation-api.jar:$AS_MODULES/angus-activation.jar" +exec "$JAVA" --module-path "${ASADMIN_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "$WS_CLASSPATH" com.sun.tools.xjc.Driver "$@" diff --git a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc.bat b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc.bat index e470057462e..895b86ecceb 100644 --- a/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc.bat +++ b/appserver/webservices/webservices-scripts/src/main/resources/glassfish/bin/xjc.bat @@ -1,6 +1,6 @@ @echo off - REM +REM Copyright (c) 2024 Contributors to the Eclipse Foundation REM Copyright (c) 2018, 2021 Oracle and/or its affiliates. All rights reserved. REM REM This program and the accompanying materials are made available under the @@ -16,7 +16,6 @@ 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 @@ -24,13 +23,16 @@ echo "Unable to enable extensions" exit /B 1 :ok -call "%~dp0..\config\asenv.bat" +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 -%JAVA% -cp "%~dp0..\modules\webservices-api-osgi.jar;%~dp0..\modules\webservices-osgi.jar;%~dp0..\modules\jakarta.xml.bind-api.jar;%~dp0..\modules\jaxb-osgi.jar;%~dp0..\modules\jakarta.activation-api.jar;%~dp0..\modules\angus-activation.jar" com.sun.tools.xjc.Driver %* +set AS_MODULES=%AS_INSTALL%\modules +set WS_CLASSPATH=%AS_MODULES%\webservices-api-osgi.jar;%AS_MODULES%\webservices-osgi.jar:%AS_MODULES%\jakarta.xml.bind-api.jar:%AS_MODULES%\jaxb-osgi.jar:%AS_MODULES%\jakarta.activation-api.jar:%AS_MODULES%\angus-activation.jar +%JAVA% --module-path "%ASADMIN_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%WS_CLASSPATH%" com.sun.tools.xjc.Driver %* From 280c10daadd974a5c6e9be3802e0bf56664719e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Sun, 10 Nov 2024 22:40:02 +0100 Subject: [PATCH 37/38] System property should have higher priority than env option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../main/jdke/props/EnvToPropsConverter.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 9691c0c9a62..267ea2556eb 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 @@ -44,8 +44,8 @@ public EnvToPropsConverter(final Path relativePathAnchor) { /** * Tries to resolve given keys. *
    - *
  • First tries {@link System#getenv(String)} using map key. - *
  • Then tries {@link System#getProperty(String)} using map value. + *
  • First tries {@link System#getProperty(String)} using map value. + *
  • Then tries {@link System#getenv(String)} using map key. *
* Then if the retrieved value is relative, it is resolved against the anchor path from * constructor. @@ -74,8 +74,8 @@ public Map convert(final Map envToSys) { /** * Tries to resolve given keys. *
    - *
  • First tries {@link System#getenv(String)} using the first parameter. - *
  • Then tries {@link System#getProperty(String)} using the second parameter. + *
  • First tries {@link System#getProperty(String)} using the second parameter. + *
  • Then tries {@link System#getenv(String)} using the first parameter. *
* Then if the retrieved value is relative, it is resolved against the anchor path from * constructor. @@ -91,14 +91,14 @@ public File convert(final String envPropertyName, final String systemPropertyNam private String evaluate(final String envPropertyName, final String systemPropertyName) { - final String envValue = System.getenv(envPropertyName); - if (envValue != null) { - return envValue; - } final String sysValue = System.getProperty(systemPropertyName); if (sysValue != null) { return sysValue; } + final String envValue = System.getenv(envPropertyName); + if (envValue != null) { + return envValue; + } // System.err.println("Missing env " + envPropertyName + " or system property " + systemPropertyName); return null; } From 7a9173b65e0ccb8107999a6cf15d756f932cdc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mat=C4=9Bj=C4=8Dek?= Date: Sun, 10 Nov 2024 23:11:23 +0100 Subject: [PATCH 38/38] Fixing appclient and Ant tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Matějček --- .../appclient/client/acc-standalone/pom.xml | 52 +- .../client/acc/agent/ACCAgentClassLoader.java | 95 +-- .../acc/agent/AppClientContainerAgent.java | 54 +- .../client/acc/agent}/CLIBootstrap.java | 166 ++--- .../client/acc/agent/ClassLoaderWrapper.java | 107 --- .../client/acc/agent}/ClassPathUtils.java | 94 +-- .../acc/agent/GFDependenciesClassLoader.java | 140 ++++ .../client/acc/agent/UserClassLoader.java | 101 +++ .../packageappclient/PackageAppClient.java | 32 +- .../client/acc/agent/LocalStrings.properties | 20 - .../packageappclient/LocalStrings.properties | 26 - .../client/acc/agent}/CLIBootstrapTest.java | 2 +- appserver/appclient/client/acc/pom.xml | 5 + .../client/AppClientContainerHolder.java | 500 +++++++++++++ .../appclient/client/AppClientFacade.java | 496 +------------ .../client/AppClientGroupFacade.java | 30 +- .../client/JWSACCMaskingClassLoader.java | 3 +- .../client/JWSAppClientContainerMain.java | 19 +- .../client/acc/ACCStartupContext.java | 2 +- .../appclient/client/acc/AgentArguments.java | 11 +- .../client/acc/AppClientContainer.java | 233 +++--- .../client/acc/AppClientContainerBuilder.java | 29 +- .../acc/AppClientContainerSecurityHelper.java | 4 +- .../client/acc/AppclientCommandArguments.java | 2 + .../client/acc/CommandLaunchInfo.java | 33 +- .../client/acc/FacadeLaunchable.java | 14 +- .../appclient/client/acc/Launchable.java | 16 +- .../client/acc/LocalStrings.properties | 4 - .../client/acc/MainClassLaunchable.java | 19 +- .../ProviderContainerContractInfoImpl.java | 4 +- .../client/acc/TargetServerHelper.java | 1 + .../appclient/client/acc/TestMain.java | 15 +- ...ader.java => TransformingClassLoader.java} | 138 ++-- .../client/acc/UndeployedLaunchable.java | 16 +- .../client/jws/boot/ErrorDisplayDialog.java | 2 +- .../appclient/client/jws/boot/JWSACCMain.java | 20 +- .../client/acc/LocalStrings.properties | 4 - .../acc/AppclientCommandArgumentsTest.java | 1 + .../client/acc/CommandLaunchInfoTest.java | 1 + .../main/resources/glassfish/bin/appclient | 9 +- .../resources/glassfish/bin/appclient.bat | 10 +- .../main/resources/glassfish/bin/appclient.js | 9 +- .../resources/glassfish/bin/package-appclient | 2 +- .../tests/appserv-tests/config/common.xml | 49 +- .../tests/appserv-tests/config/properties.xml | 25 +- .../normal-bean-injection-ear/build.xml | 4 +- .../programmatic-lookup-ear/build.xml | 4 +- .../devtests/connector/nonacc/build.xml | 16 +- .../administered-object-definition/build.xml | 15 +- .../ut/ArchiveTest.java | 6 +- .../connection-factory-definition/build.xml | 102 +-- .../ut/ArchiveTest.java | 6 +- .../devtests/connector/v3/ejb32-mdb/build.xml | 12 +- .../ut/ArchiveTest.java | 8 +- .../devtests/deployment/config/common.xml | 1 + .../deployment/directorydeploy/ear/build.xml | 1 - .../deployment/directorydeploy/ejb/build.xml | 5 + .../directorydeploy/ejbwithsuffix/build.xml | 6 +- .../deployment/dol/override/build.xml | 8 +- .../deployment/dol/validation/build.xml | 86 +-- .../wlsEar/META-INF/application.xml | 37 - .../wlsEar/META-INF/weblogic-application.xml | 26 - .../validation/wlsEar/wlsRar/META-INF/ra.xml | 35 - .../wlsEar/wlsRar/META-INF/weblogic-ra.xml | 21 - .../wlsEar2/META-INF/application.xml | 37 - .../wlsEar2/META-INF/weblogic-application.xml | 26 - .../wlsEar3/META-INF/application.xml | 37 - .../wlsEar3/META-INF/weblogic-application.xml | 30 - .../dol/validation/wlsRar/META-INF/ra.xml | 36 - .../wlsRar/META-INF/weblogic-ra.xml | 21 - .../versioning/versioning-common.xml | 685 ++++++++++-------- .../webservices/annotations-common.xml | 2 +- .../deployment/webservices/noinf/build.xml | 2 +- .../ejb/ejb30/clientview/adapted/build.xml | 13 +- .../ejb/ejb30/clientview/core/build.xml | 13 +- .../ejb/ejb30/clientview/exceptions/build.xml | 11 +- .../ejb/ejb30/hello/session/build.xml | 120 ++- .../ejb/ejb30/hello/session5/build.xml | 1 + .../persistence/tx_propagation/build.xml | 11 +- .../asynchronous/localandremote/build.xml | 13 +- .../ejb/ejb31/asynchronous/remote/build.xml | 13 +- .../asynchronous/threadpoolconfig/build.xml | 12 +- .../ejb/ejb31/ejblite/generics/build.xml | 13 +- .../ejb/ejb31/ejblite/javamodule/build.xml | 13 +- .../ejb/ejb31/ejblite/jaxrs/build.xml | 88 ++- .../ejb/ejb31/ejblite/managedbean/build.xml | 13 +- .../ejb/ejb31/ejblite/sinitcallejb/build.xml | 13 +- .../full/disable_nonportable_jndi/build.xml | 12 +- .../devtests/ejb/ejb31/full/ear/build.xml | 13 +- .../ejb/ejb31/full/jcdifull/build.xml | 31 +- .../devtests/ejb/ejb31/full/passact/build.xml | 12 +- .../devtests/ejb/ejb31/full/remote1/build.xml | 12 +- .../devtests/ejb/ejb31/full/remote2/build.xml | 13 +- .../devtests/ejb/ejb31/full/schema/build.xml | 12 +- .../ejb/ejb31/full/sfsbscnc/build.xml | 13 +- .../ejb/ejb31/full/webandejb/build.xml | 13 +- .../ejb/ejb31/security/simple/build.xml | 3 +- .../ejb/ejb31/singleton/cache/build.xml | 12 +- .../ejb/ejb31/singleton/hello/build.xml | 12 +- .../ejb31/singleton/multi-module/build.xml | 16 +- .../ejb31/singleton/threemodules/build.xml | 16 +- .../devtests/ejb/ejb31/timer31/mdb/build.xml | 13 +- .../ejb/ejb31/timer31/methodintf/build.xml | 13 +- .../ejb/ejb32/embedded/autoclose/build.xml | 19 +- .../aroundconstruct/annotation/build.xml | 12 +- .../aroundconstruct/descriptor/build.xml | 12 +- .../constructor-level/annotation/build.xml | 12 +- .../constructor-level/descriptor/build.xml | 12 +- .../get_method_lc/annotation/build.xml | 12 +- .../get_method_lc/descriptor/build.xml | 12 +- .../interceptors-inheritance/build.xml | 12 +- .../annotation/build.xml | 12 +- .../descriptor/build.xml | 12 +- .../devtests/ejb/ejb32/intfces/build.xml | 39 +- .../devtests/ejb/ejb32/mdb/build.xml | 12 +- .../devtests/ejb/ejb32/methodintf/build.xml | 12 +- .../devtests/ejb/ejb32/sfsb/basic/build.xml | 12 +- .../ejb/ejb32/sfsb/descriptor/build.xml | 12 +- .../ejb32/sfsb/lifecycle_cb_txattr/build.xml | 12 +- .../ejb/ejb32/timer/opallowed/build.xml | 181 +++-- .../ejb/stubs/standaloneclient/build.xml | 48 +- .../jdbc/flushconnectionpool/build.xml | 19 +- .../ejb/SimpleBMPBean.java | 7 +- .../devtests/jdbc/nonacc/build.xml | 55 +- .../devtests/naming/injection/build.xml | 12 +- .../security/ejb-mutual-ssl/build.xml | 51 +- .../security/ejb-oneway-ssl/build.xml | 44 +- .../devtests/security/simple-perf/build.xml | 56 +- .../standalone/loginctxdriver/build.xml | 35 +- .../devtests/transaction/ee/cli/build.xml | 4 +- .../tests/community/gfproject/build-impl.xml | 4 +- appserver/tests/quicklook/amx/pom.xml | 32 +- appserver/tests/quicklook/build.xml | 22 +- .../tests/quicklook/ejb/remoteview/pom.xml | 2 +- .../remoteview/src/test/RemoteViewTestNG.java | 17 +- .../tests/quicklook/gfproject/build-impl.xml | 49 +- appserver/tests/quicklook/pom.xml | 78 +- .../tests/quicklook/testng/testng_cluster.xml | 2 +- .../tests/quicklook/testng/testng_debug.xml | 2 +- .../tests/quicklook/testng/testng_em.xml | 2 +- .../quicklook/testng/testng_full_profile.xml | 4 +- .../quicklook/testng/testng_gd_security.xml | 2 +- .../quicklook/testng/testng_web_profile.xml | 4 +- .../src/main/java/module-info.java | 1 + .../client/ApplicationClientCLIEncoding.java | 54 ++ .../client/ApplicationClientClassLoader.java | 47 ++ .../client/ApplicationClientContainer.java | 32 + .../embeddable/client}/UserError.java | 53 +- .../EmbeddedOSGiGlassFishRuntimeBuilder.java | 7 +- .../GlassfishOsgiBootstrapClassLoader.java | 3 +- .../src/main/resources/config/osgi.properties | 9 +- .../src/main/resources/config/osgi.properties | 9 +- 152 files changed, 2587 insertions(+), 3039 deletions(-) rename appserver/appclient/client/{acc/src/main/java/org/glassfish/appclient/client => acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent}/CLIBootstrap.java (87%) delete mode 100644 appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ClassLoaderWrapper.java rename appserver/appclient/client/{acc/src/main/java/org/glassfish/appclient/common => acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent}/ClassPathUtils.java (51%) create mode 100644 appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/GFDependenciesClassLoader.java create mode 100644 appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/UserClassLoader.java delete mode 100644 appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/acc/agent/LocalStrings.properties delete mode 100644 appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/packageappclient/LocalStrings.properties rename appserver/appclient/client/{acc/src/test/java/org/glassfish/appclient/client => acc-standalone/src/test/java/org/glassfish/appclient/client/acc/agent}/CLIBootstrapTest.java (99%) create mode 100644 appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientContainerHolder.java rename appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/{ACCClassLoader.java => TransformingClassLoader.java} (59%) delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/application.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/weblogic-application.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/ra.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/weblogic-ra.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/application.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/weblogic-application.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/application.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/weblogic-application.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/ra.xml delete mode 100644 appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/weblogic-ra.xml create mode 100644 nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/client/ApplicationClientCLIEncoding.java create mode 100644 nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/client/ApplicationClientClassLoader.java create mode 100644 nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/client/ApplicationClientContainer.java rename {appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc => nucleus/common/simple-glassfish-api/src/main/java/org/glassfish/embeddable/client}/UserError.java (63%) diff --git a/appserver/appclient/client/acc-standalone/pom.xml b/appserver/appclient/client/acc-standalone/pom.xml index a190a48bd02..04cc28900c8 100755 --- a/appserver/appclient/client/acc-standalone/pom.xml +++ b/appserver/appclient/client/acc-standalone/pom.xml @@ -17,14 +17,15 @@ --> - + 4.0.0 org.glassfish.main.appclient client 7.0.21-SNAPSHOT - ../pom.xml gf-client @@ -35,9 +36,9 @@ This module builds the free-standing JAR file for the app client container which can be run without using an OSGi implementation. - This module contains little source of its own but mostly packages a JAR - with a manifest Class-Path that specifies all the OSGi JARs on which - it directly or indirectly depends. + However it still depends on many of jars in the modules directory. + The class loader hierarchy tries to reduce efforts required to run + the Application Client especially related to the classpath. @@ -54,46 +55,15 @@ - - org.glassfish.main.appclient - gf-client-module - ${project.version} - - - org.jboss.weld.se - weld-se-shaded - - + org.junit.jupiter + junit-jupiter-engine - org.glassfish.main.jdbc - jdbc-runtime + org.glassfish.main.common + simple-glassfish-api ${project.version} - true - - - org.glassfish.main.resources - resources-runtime - ${project.version} - true - - - org.glassfish.main.persistence - entitybean-container - ${project.version} - true - - - org.jboss.weld - weld-osgi-bundle - - - * - * - - - true + provided diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ACCAgentClassLoader.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ACCAgentClassLoader.java index 921f73eb144..124441e70c7 100644 --- a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ACCAgentClassLoader.java +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ACCAgentClassLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -18,17 +18,10 @@ package org.glassfish.appclient.client.acc.agent; import java.io.File; -import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.net.URLStreamHandlerFactory; -import java.security.PrivilegedAction; -import java.util.Enumeration; - -import org.glassfish.appclient.common.ClassPathUtils; - -import static java.security.AccessController.doPrivileged; +import java.util.Arrays; /** * Used as the system class loader during app client launch. @@ -40,75 +33,51 @@ *

* This class and it's dependencies must not use logging, which could cause recursion in class * loading. So don't extend GlassfishUrlClassLoader. Reproducer: TCK tests use this classloader. + *

+ * The name of this class must not be changed - it is explicitly used in the TCK Platform Test + * package. * * @author tjquinn + * @author David Matejcek */ public class ACCAgentClassLoader extends URLClassLoader { - private boolean isActive = true; + static { + registerAsParallelCapable(); + } /** - * This constructor is used by the VM to create a system class loader (as specified by -Djava.system.class.loader on the - * java command created from the appclient script). + * This constructor is used by the VM to create a system class loader (as specified by + * -Djava.system.class.loader on the java command created from the appclient script). + *

+ * This class loader ignores the parent and uses {@link GFDependenciesClassLoader} + * with the {@link ClassLoader#getPlatformClassLoader()} as its parent instead. */ public ACCAgentClassLoader(ClassLoader parent) { - super(new URL[] {}, prepareLoader(parent)); - } - - - private static URLClassLoader prepareLoader(ClassLoader parent) { - PrivilegedAction action = () -> new URLClassLoader( - new URL[] {ClassPathUtils.getGFClientJarURL()}, new ClassLoaderWrapper(parent)); - return doPrivileged(action); - } - - - public ACCAgentClassLoader(URL[] urls) { - super(urls); - } - - public ACCAgentClassLoader(URL[] urls, ClassLoader parent) { - super(urls, new ClassLoaderWrapper(parent)); - } - - public ACCAgentClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { - super(urls, parent, factory); + super("Agent", new URL[0], new UserClassLoader()); } - // a custom system class loader need to define this method in order to load the java agent. + /** + * A custom system class loader need to define this method in order to load the java agent. + * + * @param path + * @throws MalformedURLException + */ public void appendToClassPathForInstrumentation(String path) throws MalformedURLException { addURL(new File(path).toURI().toURL()); } + /** + * Returns class name, hash code and list of managed urls and info about parent. + */ @Override - public synchronized Class loadClass(String name) throws ClassNotFoundException { - if (isActive && isStillActive()) { - return super.loadClass(name); - } - return getParent().loadClass(name); - } - - @Override - public URL getResource(String name) { - if (isActive && isStillActive()) { - return super.getResource(name); - } - return getParent().getResource(name); - } - - @Override - public Enumeration getResources(String name) throws IOException { - if (isActive && isStillActive()) { - return super.getResources(name); - } - return getParent().getResources(name); - } - - private boolean isStillActive() { - if (isActive) { - String propValue = System.getProperty("org.glassfish.appclient.acc.agentLoaderDone"); - isActive = (propValue != null); - } - return isActive; + public String toString() { + final StringBuilder text = new StringBuilder(1024); + text.append(getClass().getName()).append('@').append(Integer.toHexString(hashCode())); + text.append("[name=").append(getName()).append("], urls=[\n"); + Arrays.stream(getURLs()).forEach(u -> text.append(u).append('\n')); + text.append(']'); + text.append(", parent=").append(getParent()); + return text.toString(); } } diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/AppClientContainerAgent.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/AppClientContainerAgent.java index 4259952c059..330040430c6 100644 --- a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/AppClientContainerAgent.java +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/AppClientContainerAgent.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -18,17 +19,16 @@ import java.io.File; import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; -import java.io.LineNumberReader; import java.lang.instrument.Instrumentation; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.logging.Logger; -import org.glassfish.appclient.client.AppClientFacade; -import org.glassfish.appclient.client.acc.UserError; - import static java.util.logging.Level.FINE; -import static org.glassfish.appclient.client.CLIBootstrap.FILE_OPTIONS_INTRODUCER; +import static org.glassfish.appclient.client.acc.agent.CLIBootstrap.FILE_OPTIONS_INTRODUCER; /** * Agent which prepares the ACC before the VM launches the selected main program. @@ -48,26 +48,29 @@ */ public class AppClientContainerAgent { - private static Logger logger = Logger.getLogger(AppClientContainerAgent.class.getName()); + private static final Logger LOG = Logger.getLogger(AppClientContainerAgent.class.getName()); public static void premain(String agentArgsText, Instrumentation instrumentation) { + ClassLoader loader = ClassLoader.getSystemClassLoader().getParent(); try { long now = System.currentTimeMillis(); - /* - * The agent prepares the ACC but does not launch the client. - */ - AppClientFacade.prepareACC(optionsValue(agentArgsText), instrumentation); - - logger.fine("AppClientContainerAgent finished after " + (System.currentTimeMillis() - now) + " ms"); - - } catch (UserError ue) { - ue.displayAndExit(); - } catch (Exception e) { + // The agent prepares the ACC but does not launch the client. + // The thread class loader is used in init method. + Thread.currentThread().setContextClassLoader(loader); + Class containerInitClass = loader.loadClass("org.glassfish.appclient.client.AppClientContainerHolder"); + Method initContainer = containerInitClass.getMethod("init", String.class, Instrumentation.class); + try { + initContainer.invoke(null, optionsValue(agentArgsText), instrumentation); + } catch (InvocationTargetException e) { + throw e.getCause(); + } + + LOG.fine("AppClientContainerAgent finished after " + (System.currentTimeMillis() - now) + " ms"); + } catch (Throwable e) { e.printStackTrace(); System.exit(1); } - } private static String optionsValue(final String agentArgsText) throws FileNotFoundException, IOException { @@ -79,19 +82,14 @@ private static String optionsValue(final String agentArgsText) throws FileNotFou return agentArgsText; } - File argsFile = new File(agentArgsText.substring(FILE_OPTIONS_INTRODUCER.length())); - String result; - - try (LineNumberReader reader = new LineNumberReader(new FileReader(argsFile))) { - result = reader.readLine(); - } + final Path argsFile = new File(agentArgsText.substring(FILE_OPTIONS_INTRODUCER.length())).toPath(); + final String result = Files.readString(argsFile).trim(); if (Boolean.getBoolean("keep.argsfile")) { - System.err.println("Agent arguments file retained: " + argsFile.getAbsolutePath()); - } else if (!argsFile.delete()) { - logger.log(FINE, "Unable to delete temporary args file {0}; continuing", argsFile.getAbsolutePath()); + System.err.println("Agent arguments file retained: " + argsFile); + } else if (!Files.deleteIfExists(argsFile)) { + LOG.log(FINE, "Unable to delete temporary args file {0}; continuing", argsFile); } - return result; } } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/CLIBootstrap.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/CLIBootstrap.java similarity index 87% rename from appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/CLIBootstrap.java rename to appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/CLIBootstrap.java index 437a41b61bb..932c68cbc6f 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/CLIBootstrap.java +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/CLIBootstrap.java @@ -15,24 +15,19 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package org.glassfish.appclient.client; - -import com.sun.enterprise.util.OS; +package org.glassfish.appclient.client.acc.agent; import java.io.File; import java.io.IOException; import java.io.PrintStream; -import java.net.URL; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.glassfish.appclient.client.acc.UserError; -import org.glassfish.appclient.common.ClassPathUtils; +import org.glassfish.embeddable.client.ApplicationClientCLIEncoding; +import org.glassfish.embeddable.client.UserError; import static java.lang.System.arraycopy; @@ -70,9 +65,9 @@ */ public class CLIBootstrap { + private static final boolean IS_WINDOWS = System.getProperty("os.name", "generic").startsWith("Win"); public final static String FILE_OPTIONS_INTRODUCER = "argsfile="; - private final static String COMMA_IN_ARG_PLACEHOLDER = "+-+-+-+"; private final static boolean isDebug = System.getenv("AS_DEBUG") != null; private final static String INPUT_ARGS = System.getenv("inputArgs"); @@ -82,7 +77,7 @@ public class CLIBootstrap { private final static String INSTALL_ROOT_PROPERTY_EXPR = "-Dcom.sun.aas.installRoot="; private final static String SECURITY_POLICY_PROPERTY_EXPR = "-Djava.security.policy="; private final static String SECURITY_AUTH_LOGIN_CONFIG_PROPERTY_EXPR = "-Djava.security.auth.login.config="; - private final static String SYSTEM_CLASS_LOADER_PROPERTY_EXPR = "-Djava.system.class.loader=org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader"; + private final static String SYSPROP_SYSTEM_CLASS_LOADER = "-Djava.system.class.loader="; private final static String[] ENV_VARS = { "AS_INSTALL", "APPCPATH", "VMARGS" }; @@ -171,8 +166,6 @@ public static void main(String[] args) { } catch (Exception ex) { ex.printStackTrace(); System.exit(1); - } catch (UserError ue) { - ue.displayAndExit(); } } @@ -217,7 +210,7 @@ private static String[] convertInputArgsVariable(String inputArgs) { // #### Instance methods - CLIBootstrap() throws UserError { + CLIBootstrap() throws Error { } @@ -232,7 +225,7 @@ JavaInfo initJava() { * @param args * @throws UserError */ - private String run(String[] args) throws UserError { + private String run(String[] args) throws Error { java = new JavaInfo(); gfInfo = new GlassFishInfo(); @@ -253,7 +246,7 @@ private String run(String[] args) throws UserError { } } if (!isMatched) { - throw new UserError("arg " + i + " = " + augmentedArgs[i] + " not recognized"); + throw new Error("arg " + i + " = " + augmentedArgs[i] + " not recognized"); } } @@ -288,23 +281,22 @@ private String run(String[] args) throws UserError { * @param command */ private void addProperties(final StringBuilder command) { - command.append(' ').append("-Dorg.glassfish.gmbal.no.multipleUpperBoundsException=true"); + final Path gfBootstrapLibs = gfInfo.lib.toPath().resolve("bootstrap").normalize(); + command.append(' ').append("--module-path ").append(quote(gfBootstrapLibs.toString())); + command.append(' ').append("--add-modules ALL-MODULE-PATH"); command.append(' ').append("--add-opens=java.base/java.lang=ALL-UNNAMED"); + command.append(' ').append("-Xshare:off"); + command.append(' ').append(SYSPROP_SYSTEM_CLASS_LOADER).append("org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader"); command.append(' ').append(INSTALL_ROOT_PROPERTY_EXPR).append(quote(gfInfo.home().getAbsolutePath())); + command.append(' ').append("-Dorg.glassfish.gmbal.no.multipleUpperBoundsException=true"); command.append(' ').append(SECURITY_POLICY_PROPERTY_EXPR).append(quote(gfInfo.securityPolicy().getAbsolutePath())); - command.append(' ').append("--module-path ").append(quote(gfInfo.home().toPath().normalize().resolve(Path.of("lib", "bootstrap")).toString())); - command.append(' ').append("--add-modules ALL-MODULE-PATH"); - command.append(' ').append("-classpath ").append(gfInfo.agentJarPath()).append(File.pathSeparatorChar).append('.'); - command.append(' ').append(SYSTEM_CLASS_LOADER_PROPERTY_EXPR); - command.append(' ').append("-Xshare:off"); command.append(' ').append(SECURITY_AUTH_LOGIN_CONFIG_PROPERTY_EXPR).append(quote(gfInfo.loginConfig().getAbsolutePath())); } /** * Adds the -javaagent option to the command line. - * */ - private void addAgentOption() throws UserError { + private void addAgentOption() throws Error { otherJVMOptions.processValue(new String[] { "-javaagent:" + quote(gfInfo.agentJarPath()) + agentOptionsFromFile() }, 0); } @@ -343,7 +335,7 @@ private static String quote(String string) { * @return */ private static String quoteSuppressTokenSubst(String string) { - return (OS.isWindows() ? quote(string) : quote(string.replace("$", "\\$"))); + return IS_WINDOWS ? quote(string) : quote(string.replace("$", "\\$")); } /** @@ -353,33 +345,12 @@ private static String quoteSuppressTokenSubst(String string) { * @return */ static String quoteEscapedArgument(String string) { - if (!OS.isWindows()) { + if (!IS_WINDOWS) { string = string.replace("\\", "\\\\").replace("\"", "\\\"").replace("$", "\\$").replace("`", "\\`"); } return "\"" + string + "\""; } - /** - * Replaces commas in an argument value (which can confuse the ACC agent argument parsing because shells strip out - * double-quotes) with a special sequence. - * - * @param string string to encode - * @return encoded string - */ - public static String encodeArg(String string) { - return string.replace(",", COMMA_IN_ARG_PLACEHOLDER); - } - - /** - * Replaces occurrences of comma encoding with commas. - * - * @param string possibly encoded string - * @return decoded string - */ - public static String decodeArg(String string) { - return string.replace(COMMA_IN_ARG_PLACEHOLDER, ","); - } - /** * Manages the arguments which will be passed to the ACC Java agent. @@ -410,7 +381,7 @@ final void add(String item) { * @param accArg */ final void addACCArg(String accArg) { - add("arg=" + encodeArg(accArg)); + add("arg=" + ApplicationClientCLIEncoding.encodeArg(accArg)); } @Override @@ -430,7 +401,6 @@ public String toString() { private class CommandLineElement { private final Pattern pattern; - Matcher matcher; private final Pattern whiteSpacePattern = Pattern.compile("[\\r\\n]"); @@ -446,7 +416,7 @@ private class CommandLineElement { } final boolean matchesPattern(String element) { - matcher = pattern.matcher(element); + Matcher matcher = pattern.matcher(element); return matcher.matches(); } @@ -465,7 +435,7 @@ boolean matches(String element) { * @throws UserError if the user specified an option that requires a value but provided no value (either the next * command line element is another option or there is no next element) */ - int processValue(String[] args, int slot) throws UserError { + int processValue(String[] args, int slot) throws Error { // Ignore an argument that is just unquoted white space. Matcher matcher = whiteSpacePattern.matcher(args[slot]); if (!matcher.matches()) { @@ -496,9 +466,9 @@ boolean isNextArg(String[] args, int currentSlot) { * @param currentSlot * @throws UserError */ - void ensureNonOptionNextArg(final String[] args, final int currentSlot) throws UserError { + void ensureNonOptionNextArg(final String[] args, final int currentSlot) throws Error { if ((currentSlot >= args.length - 1) || (args[currentSlot + 1].charAt(0) == '-')) { - throw new UserError("Command line element " + args[currentSlot] + " requires non-option value"); + throw new Error("Command line element " + args[currentSlot] + " requires non-option value"); } } @@ -605,7 +575,7 @@ class OptionValue { } @Override - int processValue(String[] args, int slot) throws UserError { + int processValue(String[] args, int slot) throws Error { ensureNonOptionNextArg(args, slot); optValues.add(new OptionValue(args[slot++], args[slot++])); @@ -642,7 +612,7 @@ boolean matches(final String element) { } @Override - int processValue(String[] args, int slot) throws UserError { + int processValue(String[] args, int slot) throws Error { final int result = super.processValue(args, slot); final OptionValue newOptionValue = optValues.get(optValues.size() - 1); agentArgs.addACCArg(newOptionValue.option); @@ -679,7 +649,7 @@ boolean matches(final String element) { } @Override - int processValue(String[] args, int slot) throws UserError { + int processValue(String[] args, int slot) throws Error { final int result = super.processValue(args, slot); agentArgs.addACCArg(values.get(values.size() - 1)); return result; @@ -744,7 +714,7 @@ boolean matches(String element) { private class JVMMainOption extends CommandLineElement { private static final String JVM_MAIN_PATTERN = "-jar|-client|[^-][^\\s]*"; - private String introducer = null; + private String introducer; JVMMainOption() { super(JVM_MAIN_PATTERN); @@ -772,69 +742,66 @@ boolean matches(String element) { } @Override - int processValue(String[] args, int slot) throws UserError { + int processValue(String[] args, int slot) throws Error { // We only care about the most recent setting. values.clear(); - // If arg[slot] is -jar or -client we expect the next value to be the file. Make sure there is a next item and that it + // If arg[slot] is -jar or -client we expect the next value to be the file. + // Make sure there is a next item and that it if (args[slot].charAt(0) != '-') { - // This must be a main class specified on the command line. + values.add("-classpath"); + values.add(gfInfo.agentJarPath() + File.pathSeparatorChar + + ClassPathUtils.getClassPathForGfClient(".")); final int result = super.processValue(args, slot); - agentArgs.add("client=class=" + values.get(values.size() - 1)); + String className = values.get(values.size() - 1); + agentArgs.add("client=class=" + className); return result; } if (!nextLooksOK(args, slot)) { - throw new UserError("-jar or -client requires value but missing"); + throw new Error("-jar or -client requires value but missing"); } introducer = args[slot++]; final int result = super.processValue(args, slot); - final String clientJarPath = values.get(values.size() - 1); + final String clientJarPath = values.remove(values.size() - 1); final File clientJarFile = new File(clientJarPath); if (clientJarFile.isDirectory()) { - // Record in the agent args that the user is launching a directory. Set the main class launch info to launch the ACC JAR. + // Record in the agent args that the user is launching a directory. + // Set the main class launch info to launch the ACC JAR. agentArgs.add("client=dir=" + quote(clientJarFile.getAbsolutePath())); introducer = "-jar"; - values.set(values.size() - 1, gfInfo.agentJarPath()); + values.add(gfInfo.agentJarPath()); } else { agentArgs.add("client=jar=" + quote(clientJarPath)); - // The client path is not a directory. It should be a .jar or a .ear file. If an EAR, then we want Java to launch - // our ACC jar. If a JAR, then we will launch that JAR. + // The client path is not a directory. It should be a .jar or a .ear file. + // If an EAR, then we want Java to launch our ACC jar. + // If a JAR, then we will launch that JAR. if (clientJarPath.endsWith(".ear")) { introducer = "-jar"; - values.set(values.size() - 1, gfInfo.agentJarPath()); + values.add(gfInfo.agentJarPath()); } else if (clientJarPath.endsWith(".jar")) { introducer = null; - values.set(values.size() - 1, "-classpath"); - values.add(gfInfo.agentJarPath() + File.pathSeparatorChar + getClassPathForGfClient(clientJarPath)); + values.add("-classpath"); + values.add(gfInfo.agentJarPath() + File.pathSeparatorChar + + ClassPathUtils.getClassPathForGfClient(clientJarPath)); String mainClass = ClassPathUtils.getMainClass(clientJarFile); values.add(mainClass == null ? "" : mainClass); + } else { + throw new Error("Unexpected client: " + clientJarPath); } } return result; } - private String getClassPathForGfClient(String clientJarPath) { - URL[] classpath = ClassPathUtils.getJavaClassPathForAppClient(); - if (classpath.length == 0) { - return clientJarPath; - } - return clientJarPath + File.pathSeparator + Stream.of(classpath).map(ClassPathUtils::convertToString) - .collect(Collectors.joining(File.pathSeparator)); - } - - @Override boolean format(final StringBuilder commandLine) { - if (introducer != null) { - /* - * In the generated command we always use "-jar" to indicate the JAR to be launched, even if the user specified - * "-client" on the appclient command line. - */ - super.format(commandLine, false /* useQuotes */, "-jar"); - return super.format(commandLine, true /* useQuotes */); + if (introducer == null) { + return super.format(commandLine, false /* useQuotes */); } - return super.format(commandLine, false /* useQuotes */); + // In the generated command we always use "-jar" to indicate the JAR to be launched, + // even if the user specified "-client" on the appclient command line. + super.format(commandLine, false /* useQuotes */, introducer); + return super.format(commandLine, true /* useQuotes */); } private boolean nextLooksOK(final String[] args, final int slot) { @@ -860,10 +827,9 @@ private String agentOptionsFromFile() { private File fileContainingAgentArgs() throws IOException { File argsFile = File.createTempFile("acc", ".dat"); - PrintStream ps = new PrintStream(argsFile); - ps.println(agentArgs.toString()); - ps.close(); - + try (PrintStream ps = new PrintStream(argsFile)) { + ps.println(agentArgs.toString()); + } return argsFile; } @@ -885,10 +851,10 @@ static class GlassFishInfo { if (asInstallPath == null || asInstallPath.isEmpty()) { throw new IllegalArgumentException("AS_INSTALL == null"); } - this.home = new File(asInstallPath); - modules = new File(home, "modules"); - lib = new File(home, "lib"); - libAppclient = new File(lib, "appclient"); + this.home = new File(asInstallPath).toPath().normalize().toFile(); + this.modules = new File(home, "modules"); + this.lib = new File(home, "lib"); + this.libAppclient = new File(lib, "appclient"); } File home() { @@ -903,6 +869,10 @@ File lib() { return lib; } + File libAppclient() { + return libAppclient; + } + File configxml() { /* * Try using glassfish-acc.xml. If that does not exist then the user might have done an in-place upgrade from an earlier @@ -1020,7 +990,7 @@ class UserVMArgs { private final List evElements = new ArrayList<>(); - UserVMArgs(String vmargs) throws UserError { + UserVMArgs(String vmargs) throws Error { if (isDebug) { System.err.println("VMARGS = " + (vmargs == null ? "null" : vmargs)); @@ -1045,7 +1015,7 @@ private void initEVCommandLineElements() { evElements.add(evOtherJVMOptions); } - private void processEVCommandLineElements(final String[] envVarJVMArgs) throws UserError { + private void processEVCommandLineElements(final String[] envVarJVMArgs) throws Error { /* * Process each command-line argument by the first CommandLineElement which matches the argument. */ @@ -1059,7 +1029,7 @@ private void processEVCommandLineElements(final String[] envVarJVMArgs) throws U } } if (!isMatched) { - throw new UserError("arg " + i + " = " + envVarJVMArgs[i] + " not recognized"); + throw new Error("arg " + i + " = " + envVarJVMArgs[i] + " not recognized"); } } } diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ClassLoaderWrapper.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ClassLoaderWrapper.java deleted file mode 100644 index cb3622453ab..00000000000 --- a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ClassLoaderWrapper.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2021 Contributors to the Eclipse Foundation. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0, which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception, which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - */ - -package org.glassfish.appclient.client.acc.agent; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Enumeration; -import java.util.function.Consumer; -import java.util.function.Supplier; -import java.util.stream.Stream; - -public class ClassLoaderWrapper extends ClassLoader implements Supplier, Consumer { - - private ClassLoader wrapped; - - public ClassLoaderWrapper(ClassLoader wrapped) { - super(wrapped.getName(), wrapped); - this.wrapped = wrapped; - } - - public ClassLoader getWrapped() { - return this.wrapped; - } - - public void setWrapped(ClassLoader wrapped) { - this.wrapped = wrapped; - } - - public void accept(ClassLoader t) { - setWrapped(t); - } - - public ClassLoader get() { - return getWrapped(); - } - - public int hashCode() { - return this.wrapped.hashCode(); - } - - public boolean equals(Object obj) { - return this.wrapped.equals(obj); - } - - public String toString() { - return this.wrapped.toString(); - } - - public String getName() { - if (this.wrapped == null) { - return super.getName(); - } - - return this.wrapped.getName(); - } - - public Class loadClass(String name) throws ClassNotFoundException { - return this.wrapped.loadClass(name); - } - - public URL getResource(String name) { - return this.wrapped.getResource(name); - } - - public Enumeration getResources(String name) throws IOException { - return this.wrapped.getResources(name); - } - - public Stream resources(String name) { - return this.wrapped.resources(name); - } - - public InputStream getResourceAsStream(String name) { - return this.wrapped.getResourceAsStream(name); - } - - public void setDefaultAssertionStatus(boolean enabled) { - this.wrapped.setDefaultAssertionStatus(enabled); - } - - public void setPackageAssertionStatus(String packageName, boolean enabled) { - this.wrapped.setPackageAssertionStatus(packageName, enabled); - } - - public void setClassAssertionStatus(String className, boolean enabled) { - this.wrapped.setClassAssertionStatus(className, enabled); - } - - public void clearAssertionStatus() { - this.wrapped.clearAssertionStatus(); - } -} diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/common/ClassPathUtils.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ClassPathUtils.java similarity index 51% rename from appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/common/ClassPathUtils.java rename to appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ClassPathUtils.java index f2249d20fc7..ea57abf412e 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/common/ClassPathUtils.java +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/ClassPathUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package org.glassfish.appclient.common; +package org.glassfish.appclient.client.acc.agent; import java.io.File; import java.io.IOException; @@ -22,7 +22,6 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; -import java.security.CodeSource; import java.util.ArrayList; import java.util.List; import java.util.function.Function; @@ -30,6 +29,7 @@ import java.util.jar.JarFile; import java.util.jar.Manifest; import java.util.stream.Collectors; +import java.util.stream.Stream; import static java.util.Collections.emptyList; @@ -38,7 +38,7 @@ * * @author David Matejcek */ -public class ClassPathUtils { +final class ClassPathUtils { private static final Function TO_URL = p -> { try { @@ -48,20 +48,12 @@ public class ClassPathUtils { } }; - private static final Function TO_REAL_PATH = p -> { - try { - return p.toRealPath(); - } catch (IOException e) { - throw new IllegalStateException("Could not resolve real path of: " + p, e); - } - }; - /** * @param clientJarFile * @return Main-Class attributer of the manifest file. */ - public static String getMainClass(File clientJarFile) { + static String getMainClass(File clientJarFile) { try (JarFile jarFile = new JarFile(clientJarFile)) { Manifest manifest = jarFile.getManifest(); if (manifest == null) { @@ -75,71 +67,41 @@ public static String getMainClass(File clientJarFile) { } - /** - * @return java.class.path without gf-client.jar extended by env.APPCPATH. Never null. - */ - public static URL[] getJavaClassPathForAppClient() { - final Path gfClientJar = TO_REAL_PATH.apply(getGFClientJarPath()); - final List paths = convertClassPathToPaths(System.getProperty("java.class.path")); - final List result = new ArrayList<>(); - for (Path path : paths) { - if (!TO_REAL_PATH.apply(path).equals(gfClientJar)) { - result.add(TO_URL.apply(path)); - } + static String getClassPathForGfClient(String clientJarPath) { + URL[] classpath = getJavaClassPathForAppClient(); + if (classpath.length == 0) { + return clientJarPath; } - result.addAll(convertClassPathToURLs(System.getenv("APPCPATH"))); - return result.toArray(new URL[result.size()]); - } - - /** - * @return {@link URL} to the gf-client.jar - */ - public static URL getGFClientJarURL() { - return TO_URL.apply(getGFClientJarPath()); + return clientJarPath + File.pathSeparator + Stream.of(classpath).map(ClassPathUtils::convertToString) + .distinct().collect(Collectors.joining(File.pathSeparator)); } - /** - * @return {@link Path} to the gf-client.jar - */ - public static Path getGFClientJarPath() { - try { - Class clazz = Class.forName("org.glassfish.appclient.client.acc.agent.AppClientContainerAgent"); - CodeSource codeSource = clazz.getProtectionDomain().getCodeSource(); - if (codeSource == null || codeSource.getLocation() == null) { - throw new IllegalStateException("Unable to detect the gf-client.jar location," - + " because the getCodeSource() or getLocation() method returned null." - + " That can happen ie. when you use the boot classloader" - + " or a classloader which doesn't use locations."); - } - return Path.of(codeSource.getLocation().toURI()); - } catch (ClassNotFoundException | URISyntaxException e) { - throw new IllegalStateException("Could not detect the GlassFish lib directory.", e); + private static URL[] getJavaClassPathForAppClient() { + final List paths = convertClassPathToPaths(System.getProperty("java.class.path")); + final List result = new ArrayList<>(); + for (Path path : paths) { + result.add(TO_URL.apply(path)); } + result.addAll(convertClassPathToURLs(System.getenv("APPCPATH"))); + return result.toArray(URL[]::new); } - /** - * @param classPath files separated by {@link File#pathSeparator} - * @return classPath as a list of {@link URL} - */ - public static List convertClassPathToURLs(final String classPath) { + private static List convertClassPathToURLs(final String classPath) { return convertClassPathToPaths(classPath).stream().map(TO_URL).collect(Collectors.toList()); } - /** - * @param classPath files separated by {@link File#pathSeparator} - * @return classPath as a list of {@link Path} - */ - public static List convertClassPathToPaths(final String classPath) { + private static List convertClassPathToPaths(final String classPath) { if (classPath == null || classPath.isBlank()) { return emptyList(); } - final List result = new ArrayList<>(); try { - for (String classPathElement : classPath.split(File.pathSeparator)) { - result.add(new File(classPathElement.trim()).toPath()); + String[] paths = classPath.split(File.pathSeparator); + final List result = new ArrayList<>(paths.length); + for (String classPathElement : paths) { + result.add(new File(classPathElement.trim()).toPath().normalize()); } return result; } catch (Exception e) { @@ -148,13 +110,9 @@ public static List convertClassPathToPaths(final String classPath) { } - /** - * @param url url describing a {@link Path} - * @return string path - */ - public static String convertToString(URL url) { + private static String convertToString(URL url) { try { - return Path.of(url.toURI()).toString(); + return new File(url.toURI()).toPath().toAbsolutePath().normalize().toFile().getAbsolutePath(); } catch (URISyntaxException e) { throw new IllegalArgumentException("Cannot convert to URI string: " + url, e); } diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/GFDependenciesClassLoader.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/GFDependenciesClassLoader.java new file mode 100644 index 00000000000..4970db370be --- /dev/null +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/GFDependenciesClassLoader.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.appclient.client.acc.agent; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.security.CodeSource; +import java.util.Arrays; +import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Stream; + +/** + * This class loader was created to minimize GlassFish dependencies on the command line. + * It can be used as a system class loader too. + * It should not depend on other classes except JDK. + */ +public final class GFDependenciesClassLoader extends URLClassLoader { + + static { + registerAsParallelCapable(); + } + + private static final Function TO_URL = file -> { + try { + return file.toURI().toURL(); + } catch (IOException e) { + throw new Error("Could not resolve url: " + file, e); + } + }; + + private static final boolean AS_TRACE = Boolean.parseBoolean(System.getenv("AS_TRACE")); + + /** + * This constructor is used when you instantiate this class loader in your code. + */ + GFDependenciesClassLoader() { + super("GlassFish", findGlassFishJars(), ClassLoader.getPlatformClassLoader()); + } + + + /** + * Returns class name, hash code and list of managed urls and info about parent. + */ + @Override + public String toString() { + final StringBuilder text = new StringBuilder(1024); + text.append(getClass().getName()).append('@').append(Integer.toHexString(hashCode())); + text.append("[name=").append(getName()).append(']'); + if (AS_TRACE) { + text.append(", urls=[\n"); + Arrays.stream(getURLs()).forEach(u -> text.append(u).append('\n')); + text.append(']'); + text.append(", parent=").append(getParent()); + } + return text.toString(); + } + + private static URL[] findGlassFishJars() { + Path gfHome = getGlassFishHome(); + Path gfModules = gfHome.resolve("modules"); + Set ignoredFiles = Set.of( + // TODO: Which should be here? + ); + Predicate moduleFilter = path -> { + String fileName = path.getFileName().toString(); + if (!fileName.endsWith(".jar") || ignoredFiles.contains(fileName)) { + return false; + } + String relativePath = gfModules.relativize(path).toString(); + return !relativePath.contains("autostart/"); + }; + Path appInstall = gfHome.resolve(Path.of("lib", "install", "applications")); + Predicate libFilter = filePath -> { + String path = appInstall.relativize(filePath).toString(); + return path.endsWith(".jar") && (path.contains("jmsra/") || path.contains("_jdbc_ra/")); + }; + Path derbyLibDir = gfHome.resolve(Path.of("..", "javadb", "lib")).normalize(); + Predicate derbyFilter = filePath -> { + Set files = Set.of("derby.jar", "derbyclient.jar", "derbynet.jar"); + return files.contains(filePath.getFileName().toString()); + }; + Stream modules = findFiles(gfModules, moduleFilter); + Stream libs = findFiles(appInstall, libFilter); + Stream derbyLibs = findFiles(derbyLibDir, derbyFilter); + return Stream.of(modules, libs, derbyLibs).reduce(Stream::concat).orElseGet(Stream::empty).map(TO_URL) + .toArray(URL[]::new); + } + + + private static Stream findFiles(Path root, Predicate filter) { + try { + return Files.walk(root, 5).filter(filter).map(Path::toFile); + } catch (IOException e) { + throw new Error(e); + } + } + + + private static Path getGlassFishHome() { + return new File(getMyJar()).getParentFile().getParentFile().toPath(); + } + + + private static URI getMyJar() { + try { + CodeSource codeSource = GFDependenciesClassLoader.class.getProtectionDomain().getCodeSource(); + if (codeSource == null || codeSource.getLocation() == null) { + throw new Error("Unable to detect the current jar file location," + + " because the getCodeSource() or getLocation() method returned null." + + " That can happen ie. when you use the boot classloader" + + " or a classloader which doesn't use locations."); + } + return codeSource.getLocation().toURI(); + } catch (URISyntaxException e) { + throw new Error("Could not detect the GlassFish lib directory.", e); + } + } +} diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/UserClassLoader.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/UserClassLoader.java new file mode 100644 index 00000000000..7cd7e55a6da --- /dev/null +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/acc/agent/UserClassLoader.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.appclient.client.acc.agent; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import org.glassfish.embeddable.client.ApplicationClientClassLoader; +import org.glassfish.embeddable.client.ApplicationClientContainer; + +/** + * Dependencies from -classpath argument, APPCPATH environment option, current directory + */ +public class UserClassLoader extends URLClassLoader implements ApplicationClientClassLoader { + + private static final Function PATH_TO_URL = p -> { + try { + return p.toUri().toURL(); + } catch (MalformedURLException e) { + throw new IllegalStateException("Could not convert path to url: " + p, e); + } + }; + + + UserClassLoader() { + super("User", createClassPath(), new GFDependenciesClassLoader()); + } + + private volatile ApplicationClientContainer container; + + @Override + public ApplicationClientContainer getApplicationClientContainer() { + return container; + } + + + @Override + public void setApplicationClientContainer(ApplicationClientContainer container) { + this.container = container; + } + + + /** + * Returns class name, hash code and list of managed urls and info about parent. + */ + @Override + public String toString() { + final StringBuilder text = new StringBuilder(1024); + text.append(getClass().getName()).append('@').append(Integer.toHexString(hashCode())); + text.append("[name=").append(getName()).append(']'); + text.append("[container=").append(container).append(']'); + text.append(", urls=[\n"); + Arrays.stream(getURLs()).forEach(u -> text.append(u).append('\n')); + text.append(']'); + text.append(", parent=").append(getParent()); + return text.toString(); + } + + + private static URL[] createClassPath() { + final Stream hardCodedPaths = convertClassPathToPaths("."); + final Stream cpPaths = convertClassPathToPaths(System.getProperty("java.class.path")); + final Stream envPaths = convertClassPathToPaths(System.getenv("APPCPATH")); + final Predicate filterOutGfClient = f -> !f.endsWith(Path.of("gf-client.jar")); + return Stream.of(hardCodedPaths, cpPaths, envPaths).reduce(Stream::concat).orElseGet(Stream::empty) + .map(Path::toAbsolutePath).map(Path::normalize).distinct().filter(filterOutGfClient).map(PATH_TO_URL) + .toArray(URL[]::new); + } + + private static Stream convertClassPathToPaths(final String classPath) { + if (classPath == null || classPath.isBlank()) { + return Stream.empty(); + } + try { + return Stream.of(classPath.split(File.pathSeparator)).map(File::new).map(File::toPath); + } catch (Exception e) { + throw new IllegalArgumentException("Could not parse the classpath: " + classPath, e); + } + } +} diff --git a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java index 43f8c538b16..50eb8008ffe 100644 --- a/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java +++ b/appserver/appclient/client/acc-standalone/src/main/java/org/glassfish/appclient/client/packageappclient/PackageAppClient.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -33,8 +34,6 @@ import java.util.jar.JarOutputStream; import java.util.zip.ZipException; -import org.glassfish.main.jdke.i18n.LocalStringsImpl; - import static java.util.jar.Attributes.Name.CLASS_PATH; /** @@ -117,8 +116,6 @@ public class PackageAppClient { /* default output file */ private final static String DEFAULT_OUTPUT_PATH = GLASSFISH_LIB + "/appclient.jar"; - private final static LocalStringsImpl strings = new LocalStringsImpl(PackageAppClient.class); - private boolean isVerbose; /** @@ -180,19 +177,21 @@ private void run(String[] args) throws URISyntaxException, IOException { private void placeFile(final File tempFile, final File outputFile) { if (outputFile.exists()) { if (!outputFile.delete()) { - throw new RuntimeException(strings.get("errDel", outputFile.getAbsolutePath())); + throw new RuntimeException("Stopping; could not delete the existing output file " + outputFile.getAbsolutePath()); } - System.out.println(strings.get("replacingFile", outputFile.getAbsolutePath())); + System.out.println("Replacing " + outputFile.getAbsolutePath()); } else { - System.out.println(strings.get("creatingFile", outputFile.getAbsolutePath())); + System.out.println("Creating" + outputFile.getAbsolutePath()); } if (isVerbose) { - System.out.println(strings.get("moving", tempFile.getAbsolutePath(), outputFile.getAbsolutePath())); + System.out + .println("Moving temp file " + tempFile.getAbsolutePath() + " to " + outputFile.getAbsolutePath()); } if (!tempFile.renameTo(outputFile)) { - throw new RuntimeException(strings.get("errRenaming", tempFile.getAbsolutePath(), outputFile.getAbsolutePath())); + throw new RuntimeException( + "Error renaming temp file " + tempFile.getAbsolutePath() + " to " + outputFile.getAbsolutePath()); } } @@ -222,7 +221,7 @@ private void addEndorsedFiles(JarOutputStream os, URI installDirURI, URI endorse private void addFile(JarOutputStream os, URI installDirURI, URI absoluteURIToAdd, File outputFile, String indent) throws IOException { try { if (isVerbose) { - System.err.println(indent + strings.get("addingFile", absoluteURIToAdd)); + System.err.println(indent + "Adding directory " + absoluteURIToAdd); } File fileToCopy = new File(absoluteURIToAdd); @@ -240,7 +239,8 @@ private void addFile(JarOutputStream os, URI installDirURI, URI absoluteURIToAdd */ if (!new File(absoluteURIToAdd).exists()) { if (isVerbose) { - System.err.println(indent + strings.get("noFile", new File(absoluteURIToAdd).getAbsolutePath())); + System.err.println(indent + "Error locating file " + + new File(absoluteURIToAdd).getAbsolutePath() + "; continuing"); } return; } @@ -255,7 +255,8 @@ private void addFile(JarOutputStream os, URI installDirURI, URI absoluteURIToAdd * Probably duplicate entry. Keep going after logging the error. */ if (isVerbose) { - System.err.println(indent + strings.get("zipExc", e.getLocalizedMessage())); + System.err.println( + indent + "Continuing after ZipException when adding a file: " + e.getLocalizedMessage()); } } catch (FileNotFoundException ignore) { } @@ -302,7 +303,7 @@ private void addDir(JarOutputStream os, URI installDirURI, URI absoluteDirURIToA } if (isVerbose) { - System.err.println(indent + strings.get("addingDir", dirFile.getAbsolutePath())); + System.err.println(indent + "Adding dir " + dirFile.getAbsolutePath()); } for (File fileToAdd : matchingFiles) { @@ -385,7 +386,8 @@ private File[] chooseConfigFiles(final File installDir, final String[] args) { File userSpecifiedFile = new File(xmlArg); files = new File[] { userSpecifiedFile }; if (!userSpecifiedFile.exists()) { - System.err.println(strings.get("xmlNotFound", userSpecifiedFile.getAbsolutePath())); + System.err.println("The XML configuration file " + userSpecifiedFile.getAbsolutePath() + + " does not exist; continuing but output is incomplete"); } } @@ -393,7 +395,7 @@ private File[] chooseConfigFiles(final File installDir, final String[] args) { } - private File findInstallDir(File currentJarFile) throws URISyntaxException { + private File findInstallDir(File currentJarFile) { return currentJarFile.getParentFile().getParentFile().getParentFile(); } diff --git a/appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/acc/agent/LocalStrings.properties b/appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/acc/agent/LocalStrings.properties deleted file mode 100644 index 9694989c26b..00000000000 --- a/appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/acc/agent/LocalStrings.properties +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. -# -# This program and the accompanying materials are made available under the -# terms of the Eclipse Public License v. 2.0, which is available at -# http://www.eclipse.org/legal/epl-2.0. -# -# This Source Code may also be made available under the following Secondary -# Licenses when the conditions for such availability set forth in the -# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, -# version 2 with the GNU Classpath Exception, which is available at -# https://www.gnu.org/software/classpath/license.html. -# -# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -# - - -main.usage=Usage :\n\tappclient [ | -client ] \n\t\t[-mainclass |-name ] \n\t\t[-xml ] \n\t\t[-textauth] [-user ] [-password |-passwordfile ] \n\t\t[-targetserver host[:port][,host[:port]...] \n\t\t[app-args] -main.usage.1=or :\n\tappclient [ ]\n\t\t[ | -jar ] \n\t\t[app args] -main.badVersion=Current Java version {0} is too low; {1} or later required diff --git a/appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/packageappclient/LocalStrings.properties b/appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/packageappclient/LocalStrings.properties deleted file mode 100644 index a4655a0bf0c..00000000000 --- a/appserver/appclient/client/acc-standalone/src/main/resources/org/glassfish/appclient/client/packageappclient/LocalStrings.properties +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. -# -# This program and the accompanying materials are made available under the -# terms of the Eclipse Public License v. 2.0, which is available at -# http://www.eclipse.org/legal/epl-2.0. -# -# This Source Code may also be made available under the following Secondary -# Licenses when the conditions for such availability set forth in the -# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, -# version 2 with the GNU Classpath Exception, which is available at -# https://www.gnu.org/software/classpath/license.html. -# -# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 -# - -errDel=Stopping; could not delete the existing output file {0} -replacingFile=Replacing {0} -creatingFile=Creating {0} -zipExc=Continuing after ZipException when adding a file: {0} -xmlNotFound=The XML configuration file {0} does not exist; continuing but output is incomplete -addingFile=Adding file {0} -addingDir=Adding directory {0} -noFile=Error locating file {0}; continuing -errRenaming=Error renaming temp file {0} to {1} -moving=Moving temp file {0} to {1} diff --git a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/CLIBootstrapTest.java b/appserver/appclient/client/acc-standalone/src/test/java/org/glassfish/appclient/client/acc/agent/CLIBootstrapTest.java similarity index 99% rename from appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/CLIBootstrapTest.java rename to appserver/appclient/client/acc-standalone/src/test/java/org/glassfish/appclient/client/acc/agent/CLIBootstrapTest.java index 1023ec494c9..3ce0894c0e5 100644 --- a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/CLIBootstrapTest.java +++ b/appserver/appclient/client/acc-standalone/src/test/java/org/glassfish/appclient/client/acc/agent/CLIBootstrapTest.java @@ -15,7 +15,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package org.glassfish.appclient.client; +package org.glassfish.appclient.client.acc.agent; import java.lang.reflect.Method; import java.util.regex.Pattern; diff --git a/appserver/appclient/client/acc/pom.xml b/appserver/appclient/client/acc/pom.xml index 3a611bd7fe3..607f07ce87b 100755 --- a/appserver/appclient/client/acc/pom.xml +++ b/appserver/appclient/client/acc/pom.xml @@ -82,6 +82,11 @@ glassfish-jdk-extensions ${project.version} + + org.glassfish.main.common + simple-glassfish-api + ${project.version} + org.glassfish.hk2 hk2-core diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientContainerHolder.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientContainerHolder.java new file mode 100644 index 00000000000..6595c735dc2 --- /dev/null +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientContainerHolder.java @@ -0,0 +1,500 @@ +/* + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation + * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package org.glassfish.appclient.client; + +import com.sun.enterprise.deployment.node.SaxParserHandlerBundled; +import com.sun.enterprise.universal.glassfish.TokenResolver; + +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.Unmarshaller; +import jakarta.xml.bind.ValidationEvent; +import jakarta.xml.bind.util.ValidationEventCollector; + +import java.io.BufferedReader; +import java.io.CharArrayWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.lang.instrument.Instrumentation; +import java.net.MalformedURLException; +import java.net.URI; +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.sax.SAXSource; + +import org.glassfish.appclient.client.acc.ACCLogger; +import org.glassfish.appclient.client.acc.AgentArguments; +import org.glassfish.appclient.client.acc.AppClientContainer; +import org.glassfish.appclient.client.acc.AppClientContainer.Builder; +import org.glassfish.appclient.client.acc.AppclientCommandArguments; +import org.glassfish.appclient.client.acc.CommandLaunchInfo; +import org.glassfish.appclient.client.acc.CommandLaunchInfo.ClientLaunchType; +import org.glassfish.appclient.client.acc.TargetServerHelper; +import org.glassfish.appclient.client.acc.TransformingClassLoader; +import org.glassfish.appclient.client.acc.Util; +import org.glassfish.appclient.client.acc.config.AuthRealm; +import org.glassfish.appclient.client.acc.config.ClientContainer; +import org.glassfish.appclient.client.acc.config.ClientCredential; +import org.glassfish.appclient.client.acc.config.MessageSecurityConfig; +import org.glassfish.appclient.client.acc.config.Property; +import org.glassfish.appclient.client.acc.config.TargetServer; +import org.glassfish.embeddable.client.ApplicationClientClassLoader; +import org.glassfish.embeddable.client.ApplicationClientContainer; +import org.glassfish.embeddable.client.UserError; +import org.xml.sax.InputSource; +import org.xml.sax.XMLReader; + +import static org.glassfish.appclient.client.acc.CommandLaunchInfo.ClientLaunchType.UNKNOWN; + +/** + * @author tjquinn + * @author David Matejcek + */ +public class AppClientContainerHolder implements ApplicationClientContainer { + + private static final String ACC_CONFIG_CONTENT_PROPERTY_NAME = "glassfish-acc.xml.content"; + private static final String MAN_PAGE_PATH = "/org/glassfish/appclient/client/acc/appclient.1m"; + + private static volatile AppClientContainerHolder instance; + + private CommandLaunchInfo launchInfo; + private AppclientCommandArguments appClientCommandArgs; + + private ApplicationClientContainer appClientContainer; + + + @Override + public void launch(String[] args) throws UserError { + appClientContainer.launch(args); + } + + public ApplicationClientContainer getAppClientContainer() { + return appClientContainer; + } + + public static synchronized AppClientContainerHolder getInstance() { + if (instance == null) { + // The container was not initialized by the instrumentation executed + // by the AppClientContainerAgent. We will try to make it. + try { + init(null, null); + } catch (UserError ue) { + ue.displayAndExit(); + } catch (Exception ex) { + ex.printStackTrace(); + System.exit(1); + } + } + return instance; + } + + /** + * Initializes the {@link ApplicationClientContainer} singleton. + * + * @param agentArgsText + * @param inst + * @throws UserError + * @throws Exception + */ + public static synchronized void init(String agentArgsText, Instrumentation inst) throws UserError, Exception { + int version = Runtime.version().feature(); + if (version < 11) { + throw new UserError(MessageFormat.format("Current Java version {0} is too low; {1} or later required", + System.getProperty("java.version"), "11")); + } + + // Analyze the agent argument string. + AgentArguments agentArgs = AgentArguments.newInstance(agentArgsText); + + + // The agent arguments that correspond to the ones that we want to pass to the ACC are + // the ones with the "arg=" keyword prefix. + // These will include arguments with meaning to the ACC (-textauth for example) as well + // as arguments to be passed on to the client's main method. + AppClientContainerHolder holder = new AppClientContainerHolder(); + holder.appClientCommandArgs = AppclientCommandArguments.newInstance(agentArgs.namedValues("arg")); + + if (holder.appClientCommandArgs.isUsage()) { + usage(0); + } else if (holder.appClientCommandArgs.isHelp()) { + help(); + } + + // Examine the agent arguments for settings about how to launch the client. + holder.launchInfo = CommandLaunchInfo.newInstance(agentArgs); + if (holder.launchInfo.getClientLaunchType() == UNKNOWN) { + usage(1); + } + + // Load the ACC configuration XML file. + ClientContainer clientContainer = readConfig(holder.appClientCommandArgs); + + // Decide what target servers to use. This combines any specified on the command line with + // any in the config file's target-server elements as well as any set in the properties of + // the config file. + final TargetServer[] targetServers = TargetServerHelper.targetServers(clientContainer, + holder.appClientCommandArgs.getTargetServer()); + + ClassLoader dependenciesCL = Thread.currentThread().getContextClassLoader(); + try { + // This class loader does transformations and is saved inside the container. + TransformingClassLoader loader = initClassLoader(dependenciesCL, inst == null); + Thread.currentThread().setContextClassLoader(loader); + + // Get the builder. Doing so correctly involves merging the configuration file data with + // some of the command line and agent arguments. + final AppClientContainer.Builder builder = createBuilder(targetServers, clientContainer, holder.appClientCommandArgs); + + // Create the ACC. Again, precisely how we create it depends on some of the command line + // arguments and agent arguments. + final AppClientContainer newACC = createContainer(builder, holder.launchInfo, holder.appClientCommandArgs); + + // Because the JMV might invoke the client's main class, the agent needs to prepare the container. + // (This is done as part of the AppClientContainer.start() processing in the public API. + newACC.prepare(inst); + holder.appClientContainer = newACC; + ((ApplicationClientClassLoader) dependenciesCL).setApplicationClientContainer(holder.appClientContainer); + AppClientContainerHolder.instance = holder; + } finally { + // Reset for possible usage in the AppClientGroupFacade + Thread.currentThread().setContextClassLoader(dependenciesCL); + } + } + + private static void usage(final int exitStatus) { + System.err.println(getUsage()); + System.exit(exitStatus); + } + + private static void help() throws IOException { + final InputStream is = AppClientContainerHolder.class.getResourceAsStream(MAN_PAGE_PATH); + if (is == null) { + usage(0); + } + + try (BufferedReader helpReader = new BufferedReader(new InputStreamReader(is))) { + String line; + while ((line = helpReader.readLine()) != null) { + System.err.println(line); + } + } finally { + System.exit(0); + } + } + + private static String getUsage() { + return "appclient [ | -client ] [-mainclass |-name ]" + + " [-xml ] [-textauth] [-user ] [-password |-passwordfile ]" + + " [-targetserver host[:port][,host[:port]...] [app-args]" + System.lineSeparator() + + " or :\n\tappclient [ ] [ | -jar ]" + + " [app args]"; + } + + + private static TransformingClassLoader initClassLoader(final ClassLoader parent, final boolean loaderShouldTransform) { + final TransformingClassLoader loader = TransformingClassLoader.instance(); + if (loader == null) { + return TransformingClassLoader.newInstance(parent, loaderShouldTransform); + } + return loader; + } + + private static Builder createBuilder(TargetServer[] targetServers, ClientContainer clientContainer, + AppclientCommandArguments appClientCommandArgs) throws IOException { + Builder builder = AppClientContainer.newBuilder(targetServers); + + /* + * Augment the builder with settings from the app client options that can affect the builder itself. (This is distinct + * from options that affect what client to launch which are handled in creating the ACC itself. + */ + updateClientCredentials(builder, appClientCommandArgs); + List msc = clientContainer.getMessageSecurityConfig(); + if (msc != null) { + builder.getMessageSecurityConfig().addAll(clientContainer.getMessageSecurityConfig()); + } + + builder.logger(new ACCLogger(clientContainer.getLogService())); + + AuthRealm authRealm = clientContainer.getAuthRealm(); + if (authRealm != null) { + builder.authRealm(authRealm.getClassname()); + } + + List property = clientContainer.getProperty(); + if (property != null) { + builder.containerProperties(property); + } + + return builder; + } + + private static void updateClientCredentials(final Builder builder, final AppclientCommandArguments appClientCommandArgs) { + ClientCredential clientCredential = builder.getClientCredential(); + String user = clientCredential == null ? null : clientCredential.getUserName(); + char[] pw = clientCredential != null && clientCredential.getPassword() != null ? clientCredential.getPassword().get() : null; + + /* + * user on command line? + */ + String commandLineUser = appClientCommandArgs.getUser(); + if (commandLineUser != null) { + user = commandLineUser; + } + + /* + * password or passwordfile on command line? (theAppClientCommandArgs class takes care of reading the password from the + * file and/or handling the -password option. + */ + char[] commandLinePW = appClientCommandArgs.getPassword(); + if (commandLinePW != null) { + pw = commandLinePW; + } + + builder.clientCredentials(user, pw); + } + + private static AppClientContainer createContainer(Builder builder, CommandLaunchInfo launchInfo, + AppclientCommandArguments appClientArgs) throws Exception, UserError { + + /* + * The launchInfo already knows something about how to conduct the launch. + */ + ClientLaunchType launchType = launchInfo.getClientLaunchType(); + AppClientContainer container; + + switch (launchType) { + case JAR: + case DIR: + // The client name in the launch info is a file path for the directory or JAR to launch. + container = createContainerForAppClientArchiveOrDir(builder, launchInfo.getClientName(), appClientArgs); + break; + + case URL: + container = createContainerForJWSLaunch(builder, launchInfo.getClientName(), appClientArgs); + break; + + case CLASS: + container = createContainerForClassName(builder, launchInfo.getClientName()); + break; + + case CLASSFILE: + container = createContainerForClassFile(builder, launchInfo.getClientName()); + break; + + default: + container = null; + } + + if (container == null) { + throw new IllegalArgumentException("cannot choose app client launch type"); + } + + return container; + } + + + private static AppClientContainer createContainerForAppClientArchiveOrDir(Builder builder, String appClientPath, + AppclientCommandArguments appClientArgs) throws Exception, UserError { + return builder.newContainer(Util.getURI(new File(appClientPath)), null, + appClientArgs.getMainclass(), appClientArgs.getName(), appClientArgs.isTextauth()); + } + + + private static AppClientContainer createContainerForJWSLaunch(Builder builder, String appClientPath, + AppclientCommandArguments appClientArgs) throws Exception, UserError { + return builder.newContainer(URI.create(appClientPath), null /* callbackHandler */, appClientArgs.getMainclass(), + appClientArgs.getName()); + } + + + /** + * Place "." on the class path so that when we convert the class file path + * to a fully-qualified class name and try to load it, we'll find it. + */ + private static AppClientContainer createContainerForClassName(Builder builder, String className) throws Exception, UserError { + return builder.newContainer(Class.forName(className, true, Thread.currentThread().getContextClassLoader())); + } + + private static AppClientContainer createContainerForClassFile(Builder builder, String classFilePath) + throws MalformedURLException, ClassNotFoundException, FileNotFoundException, IOException, Exception, UserError { + + Util.verifyFilePath(classFilePath); + + /* + * Strip off the trailing .class from the path and convert separator characters to dots to build a fully-qualified class + * name. + */ + String className = classFilePath.substring(0, classFilePath.lastIndexOf(".class")).replace(File.separatorChar, '.'); + + return createContainerForClassName(builder, className); + } + + private static ClientContainer readConfig(AppclientCommandArguments appClientCommandArgs) throws UserError, Exception { + final String configPath = appClientCommandArgs.getConfigFilePath(); + ClientContainer result = null; + Reader configReader = null; + try { + /* + * During a Java Web Start launch, the config is passed as a property value. + */ + final String configInProperty = System.getProperty(ACC_CONFIG_CONTENT_PROPERTY_NAME); + final String configFileLocationForErrorMessage; + if (configInProperty == null) { + /* + * This is not a Java Web Start launch, so read the configuration from a disk file. + */ + File configFile = checkXMLFile(configPath); + checkXMLFile(appClientCommandArgs.getConfigFilePath()); + configReader = new FileReader(configFile); + configFileLocationForErrorMessage = configFile.getAbsolutePath(); + } else { + /* + * Awkwardly, the glassfish-acc.xml content refers to a config file. We work around this for Java Web Start launch by + * capturing the content of that config file into a property setting in the generated JNLP document. We need to write + * that content into a temporary file here on the client and then replace a placeholder in the glassfish-acc.xml content + * with the path to that temp file. + */ + final File securityConfigTempFile = Util.writeTextToTempFile(configInProperty, "wss-client-config", ".xml", false); + final Properties p = new Properties(); + p.setProperty("security.config.path", securityConfigTempFile.getAbsolutePath()); + configReader = new StringReader(Util.replaceTokens(configInProperty, p)); + configFileLocationForErrorMessage = null; + } + + /* + * Although JAXB makes it very simple to parse the XML into Java objects, we have to do several things explicitly to use + * our local copies of DTDs and XSDs. + */ + SAXParserFactory spf = SAXParserFactory.newInstance(); + spf.setValidating(true); + spf.setNamespaceAware(true); + SAXParser parser = spf.newSAXParser(); + XMLReader reader = parser.getXMLReader(); + + /* + * Get the local entity resolver that knows about the bundled .dtd and .xsd files. + */ + reader.setEntityResolver(new SaxParserHandlerBundled()); + + /* + * To support installation-directory independence the default glassfish-acc.xml refers to the wss-config file using + * ${com.sun.aas.installRoot}... So preprocess the glassfish-acc.xml file to replace any tokens with the corresponding + * values, then submit that result to JAXB. + */ + InputSource inputSource = replaceTokensForParsing(configReader); + SAXSource saxSource = new SAXSource(reader, inputSource); + + JAXBContext jc = JAXBContext.newInstance(ClientContainer.class); + Unmarshaller u = jc.createUnmarshaller(); + final ValidationEventCollector vec = new ValidationEventCollector(); + u.setEventHandler(vec); + result = (ClientContainer) u.unmarshal(saxSource); + if (vec.hasEvents()) { + printValidationEvents(configFileLocationForErrorMessage, vec.getEvents()); + } + return result; + } finally { + if (configReader != null) { + configReader.close(); + } + } + } + + private static void printValidationEvents(String file, ValidationEvent[] events) { + /* + * The parser reported at least one warning or error. If all events were warnings, display them as a message and + * continue. Otherwise there was at least one error or fatal, so say so and try to continue but say that such errors + * might be fatal in future releases. + */ + boolean isError = false; + final StringBuilder sb = new StringBuilder(); + for (ValidationEvent ve : events) { + sb.append(ve.getMessage()).append(System.lineSeparator()); + isError |= (ve.getSeverity() != ValidationEvent.WARNING); + } + + String messageIntroduction = MessageFormat.format(isError + ? "Error parsing app client container configuration{0}." + + " Attempting to continue." + + " In future releases such parsing errors might become fatal." + + " Please correct your configuration file." + : "Warning(s) parsing app client container configuration{0}." + + " Continuing.", + file == null ? "" : " file " + file); + System.err.println(messageIntroduction + System.lineSeparator() + sb); + } + + private static InputSource replaceTokensForParsing(final Reader reader) throws FileNotFoundException, IOException { + CharArrayWriter writer = new CharArrayWriter(); + try { + char[] buffer = new char[4096]; + int charsRead; + while ((charsRead = reader.read(buffer)) != -1) { + writer.write(buffer, 0, charsRead); + } + } finally { + writer.close(); + } + reader.close(); + + Map mapping = new HashMap<>(); + Properties props = System.getProperties(); + for (String propName : props.stringPropertyNames()) { + mapping.put(propName, props.getProperty(propName)); + } + + TokenResolver resolver = new TokenResolver(mapping); + String configWithTokensReplaced = resolver.resolve(writer.toString()); + return new InputSource(new StringReader(configWithTokensReplaced)); + } + + private static File checkXMLFile(String xmlFullName) throws UserError { + try { + File f = new File(xmlFullName); + if (f.exists() && f.isFile() && f.canRead()) { + return f; + } + // If given file does not exists + xmlMessage(xmlFullName); + return null; + } catch (Exception ex) { + xmlMessage(xmlFullName); + return null; + } + } + + private static void xmlMessage(String xmlFullName) throws UserError { + UserError ue = new UserError(MessageFormat.format( + "Client Container xml: {0} not found or unable to read.\nYou may want to use the -xml option to locate your configuration xml.", + xmlFullName)); + ue.setUsage(getUsage()); + throw ue; + + } +} diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java index 5ae868dc7ad..214765beb7a 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientFacade.java @@ -17,85 +17,14 @@ package org.glassfish.appclient.client; -import com.sun.enterprise.container.common.spi.util.InjectionException; -import com.sun.enterprise.deployment.node.SaxParserHandlerBundled; -import com.sun.enterprise.universal.glassfish.TokenResolver; -import com.sun.enterprise.util.LocalStringManager; -import com.sun.enterprise.util.LocalStringManagerImpl; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBException; -import jakarta.xml.bind.Unmarshaller; -import jakarta.xml.bind.ValidationEvent; -import jakarta.xml.bind.util.ValidationEventCollector; - -import java.io.BufferedReader; -import java.io.CharArrayWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.StringReader; -import java.lang.instrument.Instrumentation; -import java.lang.reflect.InvocationTargetException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.sax.SAXSource; - -import org.glassfish.appclient.client.acc.ACCClassLoader; -import org.glassfish.appclient.client.acc.ACCLogger; -import org.glassfish.appclient.client.acc.AgentArguments; -import org.glassfish.appclient.client.acc.AppClientContainer; -import org.glassfish.appclient.client.acc.AppClientContainer.Builder; -import org.glassfish.appclient.client.acc.AppclientCommandArguments; -import org.glassfish.appclient.client.acc.CommandLaunchInfo; -import org.glassfish.appclient.client.acc.CommandLaunchInfo.ClientLaunchType; -import org.glassfish.appclient.client.acc.TargetServerHelper; -import org.glassfish.appclient.client.acc.UserError; -import org.glassfish.appclient.client.acc.Util; -import org.glassfish.appclient.client.acc.config.AuthRealm; -import org.glassfish.appclient.client.acc.config.ClientContainer; -import org.glassfish.appclient.client.acc.config.ClientCredential; -import org.glassfish.appclient.client.acc.config.MessageSecurityConfig; -import org.glassfish.appclient.client.acc.config.Property; -import org.glassfish.appclient.client.acc.config.TargetServer; -import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import static org.glassfish.appclient.client.acc.CommandLaunchInfo.ClientLaunchType.UNKNOWN; +import org.glassfish.embeddable.client.ApplicationClientClassLoader; +import org.glassfish.embeddable.client.UserError; /** * @author tjquinn */ public class AppClientFacade { - private static final String ACC_CONFIG_CONTENT_PROPERTY_NAME = "glassfish-acc.xml.content"; - private static final String MAN_PAGE_PATH = "/org/glassfish/appclient/client/acc/appclient.1m"; - private static final String LINE_SEP = System.lineSeparator(); - - private static final Class stringsAnchor = ACCClassLoader.class; - private static LocalStringManager localStrings = new LocalStringManagerImpl(stringsAnchor); - - private static CommandLaunchInfo launchInfo; - private static AppclientCommandArguments appClientCommandArgs; - private static AppClientContainer appClientContainer; - /** * Prepares the ACC (if not already done by the agent) and then transfers control to the ACC. *

@@ -114,425 +43,14 @@ public class AppClientFacade { */ public static void main(String[] args) { try { - if (appClientContainer == null) { - /* - * The facade JAR has been run directly, not via the appclient script and not via Java Web Start. So we have no agent - * arguments and no instrumentation for registering transformations. - * - * Because the agent has not run, we prepare the ACC here. (The agent would have done so itself had it run.) - */ - prepareACC(null, null); - } - - /* - * In any case, the ACC is now prepared. Launch the app client in the prepared ACC. - */ - appClientContainer.launch(args); - } catch (Exception ex) { - ex.printStackTrace(); - System.exit(1); + ApplicationClientClassLoader loader = (ApplicationClientClassLoader) Thread.currentThread() + .getContextClassLoader(); + loader.getApplicationClientContainer().launch(args); } catch (UserError ue) { ue.displayAndExit(); - } - } - - public static AppClientContainer acc() { - return appClientContainer; - } - - public static void launch(String[] args) throws NoSuchMethodException, ClassNotFoundException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException, IOException, SAXException, InjectionException, UserError { - appClientContainer.launch(args); - } - - public static void prepareACC(String agentArgsText, Instrumentation inst) throws UserError, MalformedURLException, URISyntaxException, - JAXBException, FileNotFoundException, ParserConfigurationException, SAXException, IOException, Exception { - int version = Runtime.version().feature(); - if (version < 11) { - throw new UserError(localStrings.getLocalString(stringsAnchor, "main.badVersion", - "Current Java version {0} is too low; {1} or later required", - new Object[] {System.getProperty("java.version"), "11"})); - } - - /* - * Analyze the agent argument string. - */ - AgentArguments agentArgs = AgentArguments.newInstance(agentArgsText); - - /* - * The agent arguments that correspond to the ones that we want to pass to the ACC are the ones with the "arg=" keyword - * prefix. These will include arguments with meaning to the ACC (-textauth for example) as well as arguments to be - * passed on to the client's main method. - */ - appClientCommandArgs = AppclientCommandArguments.newInstance(agentArgs.namedValues("arg")); - - if (appClientCommandArgs.isUsage()) { - usage(0); - } else if (appClientCommandArgs.isHelp()) { - help(); - } - - /* - * Examine the agent arguments for settings about how to launch the client. - */ - launchInfo = CommandLaunchInfo.newInstance(agentArgs); - if (launchInfo.getClientLaunchType() == UNKNOWN) { - usage(1); - } - - /* - * Handle the legacy env. variable APPCPATH. - */ - ACCClassLoader loader = initClassLoader((inst == null)); - Thread.currentThread().setContextClassLoader(loader); - - /* - * The installRoot property will be set by the ServerEnvironment initialization using the ACC start-up context. That - * happens during the ACCModulesManager warm-up. - */ - - /* - * Load the ACC configuration XML file. - */ - ClientContainer clientContainer = readConfig(appClientCommandArgs.getConfigFilePath(), loader); - - /* - * Decide what target servers to use. This combines any specified on the command line with any in the config file's - * target-server elements as well as any set in the properties of the config file. - */ - final TargetServer[] targetServers = TargetServerHelper.targetServers(clientContainer, appClientCommandArgs.getTargetServer()); - - /* - * Get the builder. Doing so correctly involves merging the configuration file data with some of the command line and - * agent arguments. - */ - final AppClientContainer.Builder builder = createBuilder(targetServers, clientContainer, appClientCommandArgs); - - /* - * Create the ACC. Again, precisely how we create it depends on some of the command line arguments and agent arguments. - */ - final AppClientContainer newACC = createContainer(builder, launchInfo, appClientCommandArgs); - - /* - * Because the JMV might invoke the client's main class, the agent needs to prepare the container. (This is done as part - * of the AppClientContainer.start() processing in the public API. - */ - newACC.prepare(inst); - - appClientContainer = newACC; - } - - private static void usage(final int exitStatus) { - System.err.println(getUsage()); - System.exit(exitStatus); - } - - private static void help() throws IOException { - final InputStream is = AppClientFacade.class.getResourceAsStream(MAN_PAGE_PATH); - if (is == null) { - usage(0); - } - - try (BufferedReader helpReader = new BufferedReader(new InputStreamReader(is))) { - String line; - while ((line = helpReader.readLine()) != null) { - System.err.println(line); - } - } finally { - System.exit(0); - } - } - - private static String getUsage() { - return localStrings.getLocalString(stringsAnchor, "main.usage", - "appclient [ | -client ] [-mainclass |-name ] [-xml ] [-textauth] [-user ] [-password |-passwordfile ] [-targetserver host[:port][,host[:port]...] [app-args]") - + System.lineSeparator() + localStrings.getLocalString(stringsAnchor, "main.usage.1", - " or :\n\tappclient [ ] [ | -jar ] [app args]"); - } - - private static ACCClassLoader initClassLoader(final boolean loaderShouldTransform) throws MalformedURLException { - ACCClassLoader loader = ACCClassLoader.instance(); - if (loader == null) { - loader = ACCClassLoader.newInstance(Thread.currentThread().getContextClassLoader(), loaderShouldTransform); - } - - return loader; - } - - private static Builder createBuilder(TargetServer[] targetServers, ClientContainer clientContainer, - AppclientCommandArguments appClientCommandArgs) throws IOException { - Builder builder = AppClientContainer.newBuilder(targetServers); - - /* - * Augment the builder with settings from the app client options that can affect the builder itself. (This is distinct - * from options that affect what client to launch which are handled in creating the ACC itself. - */ - updateClientCredentials(builder, appClientCommandArgs); - List msc = clientContainer.getMessageSecurityConfig(); - if (msc != null) { - builder.getMessageSecurityConfig().addAll(clientContainer.getMessageSecurityConfig()); - } - - builder.logger(new ACCLogger(clientContainer.getLogService())); - - AuthRealm authRealm = clientContainer.getAuthRealm(); - if (authRealm != null) { - builder.authRealm(authRealm.getClassname()); - } - - List property = clientContainer.getProperty(); - if (property != null) { - builder.containerProperties(property); - } - - return builder; - } - - private static void updateClientCredentials(final Builder builder, final AppclientCommandArguments appClientCommandArgs) { - ClientCredential clientCredential = builder.getClientCredential(); - String user = (clientCredential != null ? clientCredential.getUserName() : null); - char[] pw = (clientCredential != null && clientCredential.getPassword() != null ? clientCredential.getPassword().get() : null); - - /* - * user on command line? - */ - String commandLineUser; - if ((commandLineUser = appClientCommandArgs.getUser()) != null) { - user = commandLineUser; - } - - /* - * password or passwordfile on command line? (theAppClientCommandArgs class takes care of reading the password from the - * file and/or handling the -password option. - */ - char[] commandLinePW; - if ((commandLinePW = appClientCommandArgs.getPassword()) != null) { - pw = commandLinePW; - } - - builder.clientCredentials(user, pw); - } - - private static AppClientContainer createContainer(Builder builder, CommandLaunchInfo launchInfo, - AppclientCommandArguments appClientArgs) throws Exception, UserError { - - /* - * The launchInfo already knows something about how to conduct the launch. - */ - ClientLaunchType launchType = launchInfo.getClientLaunchType(); - AppClientContainer container; - - switch (launchType) { - case JAR: - case DIR: - /* - * The client name in the launch info is a file path for the directory or JAR to launch. - */ - container = createContainerForAppClientArchiveOrDir(builder, launchInfo.getClientName(), appClientArgs.getMainclass(), - appClientArgs.getName()); - break; - - case URL: - container = createContainerForJWSLaunch(builder, launchInfo.getClientName(), appClientArgs.getMainclass(), - appClientArgs.getName()); - break; - - case CLASS: - container = createContainerForClassName(builder, launchInfo.getClientName()); - break; - - case CLASSFILE: - container = createContainerForClassFile(builder, launchInfo.getClientName()); - break; - - default: - container = null; - } - - if (container == null) { - throw new IllegalArgumentException("cannot choose app client launch type"); - } - - return container; - } - - private static AppClientContainer createContainerForAppClientArchiveOrDir(Builder builder, String appClientPath, String mainClassName, String clientName) throws Exception, UserError { - return builder.newContainer(Util.getURI(new File(appClientPath)), null /* callbackHandler */, mainClassName, clientName, appClientCommandArgs.isTextauth()); - } - - private static AppClientContainer createContainerForJWSLaunch(Builder builder, String appClientPath, String mainClassName, String clientName) throws Exception, UserError { - return builder.newContainer(URI.create(appClientPath), null /* callbackHandler */, mainClassName, clientName); - } - - - /** - * Place "." on the class path so that when we convert the class file path - * to a fully-qualified class name and try to load it, we'll find it. - */ - private static AppClientContainer createContainerForClassName(Builder builder, String className) throws Exception, UserError { - - ClassLoader loader = prepareLoaderToFindClassFile(Thread.currentThread().getContextClassLoader()); - Thread.currentThread().setContextClassLoader(loader); - - return builder.newContainer(Class.forName(className, true, loader)); - } - - private static ClassLoader prepareLoaderToFindClassFile(final ClassLoader currentLoader) throws MalformedURLException { - File currentDirPath = new File(System.getProperty("user.dir")); - return new GlassfishUrlClassLoader("AppClientFacade(" + currentDirPath + ")", - new URL[] {currentDirPath.toURI().toURL()}, currentLoader); - } - - private static AppClientContainer createContainerForClassFile(Builder builder, String classFilePath) - throws MalformedURLException, ClassNotFoundException, FileNotFoundException, IOException, Exception, UserError { - - Util.verifyFilePath(classFilePath); - - /* - * Strip off the trailing .class from the path and convert separator characters to dots to build a fully-qualified class - * name. - */ - String className = classFilePath.substring(0, classFilePath.lastIndexOf(".class")).replace(File.separatorChar, '.'); - - return createContainerForClassName(builder, className); - } - - private static ClientContainer readConfig(final String configPath, final ClassLoader loader) throws UserError, JAXBException, - FileNotFoundException, ParserConfigurationException, SAXException, URISyntaxException, IOException { - ClientContainer result = null; - Reader configReader = null; - String configFileLocationForErrorMessage = ""; - try { - /* - * During a Java Web Start launch, the config is passed as a property value. - */ - String configInProperty = System.getProperty(ACC_CONFIG_CONTENT_PROPERTY_NAME); - if (configInProperty != null) { - /* - * Awkwardly, the glassfish-acc.xml content refers to a config file. We work around this for Java Web Start launch by - * capturing the content of that config file into a property setting in the generated JNLP document. We need to write - * that content into a temporary file here on the client and then replace a placeholder in the glassfish-acc.xml content - * with the path to that temp file. - */ - final File securityConfigTempFile = Util.writeTextToTempFile(configInProperty, "wss-client-config", ".xml", false); - final Properties p = new Properties(); - p.setProperty("security.config.path", securityConfigTempFile.getAbsolutePath()); - configInProperty = Util.replaceTokens(configInProperty, p); - configReader = new StringReader(configInProperty); - } else { - /* - * This is not a Java Web Start launch, so read the configuration from a disk file. - */ - File configFile = checkXMLFile(configPath); - checkXMLFile(appClientCommandArgs.getConfigFilePath()); - configReader = new FileReader(configFile); - configFileLocationForErrorMessage = configFile.getAbsolutePath(); - } - - /* - * Although JAXB makes it very simple to parse the XML into Java objects, we have to do several things explicitly to use - * our local copies of DTDs and XSDs. - */ - SAXParserFactory spf = SAXParserFactory.newInstance(); - spf.setValidating(true); - spf.setNamespaceAware(true); - SAXParser parser = spf.newSAXParser(); - XMLReader reader = parser.getXMLReader(); - - /* - * Get the local entity resolver that knows about the bundled .dtd and .xsd files. - */ - reader.setEntityResolver(new SaxParserHandlerBundled()); - - /* - * To support installation-directory independence the default glassfish-acc.xml refers to the wss-config file using - * ${com.sun.aas.installRoot}... So preprocess the glassfish-acc.xml file to replace any tokens with the corresponding - * values, then submit that result to JAXB. - */ - InputSource inputSource = replaceTokensForParsing(configReader); - - SAXSource saxSource = new SAXSource(reader, inputSource); - JAXBContext jc = JAXBContext.newInstance(ClientContainer.class); - final ValidationEventCollector vec = new ValidationEventCollector(); - - Unmarshaller u = jc.createUnmarshaller(); - u.setEventHandler(vec); - result = (ClientContainer) u.unmarshal(saxSource); - if (vec.hasEvents()) { - /* - * The parser reported at least one warning or error. If all events were warnings, display them as a message and - * continue. Otherwise there was at least one error or fatal, so say so and try to continue but say that such errors - * might be fatal in future releases. - */ - boolean isError = false; - final StringBuilder sb = new StringBuilder(); - for (ValidationEvent ve : vec.getEvents()) { - sb.append(ve.getMessage()).append(LINE_SEP); - isError |= (ve.getSeverity() != ValidationEvent.WARNING); - } - - String messageIntroduction = localStrings.getLocalString(AppClientFacade.class, - isError ? "appclient.errParsingConfig" : "appclient.warnParsingConfig", - isError ? "Error parsing app client container configuration {0}. Attempting to continue. In future releases such parsing errors might become fatal. Please correct your configuration file." - : "Warning(s) parsing app client container configuration {0}. Continuing.", - new Object[] { configFileLocationForErrorMessage }); - - System.err.println(messageIntroduction + LINE_SEP + sb.toString()); - } - - return result; - } finally { - if (configReader != null) { - configReader.close(); - } - } - } - - private static InputSource replaceTokensForParsing(final Reader reader) throws FileNotFoundException, IOException, URISyntaxException { - char[] buffer = new char[1024]; - - CharArrayWriter writer = new CharArrayWriter(); - int charsRead; - while ((charsRead = reader.read(buffer)) != -1) { - writer.write(buffer, 0, charsRead); - } - writer.close(); - reader.close(); - - Map mapping = new HashMap<>(); - Properties props = System.getProperties(); - for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { - String propName = (String) e.nextElement(); - mapping.put(propName, props.getProperty(propName)); - } - - TokenResolver resolver = new TokenResolver(mapping); - String configWithTokensReplaced = resolver.resolve(writer.toString()); - InputSource inputSource = new InputSource(new StringReader(configWithTokensReplaced)); - return inputSource; - } - - private static File checkXMLFile(String xmlFullName) throws UserError { - try { - File f = new File(xmlFullName); - if (f.exists() && f.isFile() && f.canRead()) { - return f; - } else {// If given file does not exists - xmlMessage(xmlFullName); - return null; - } } catch (Exception ex) { - xmlMessage(xmlFullName); - return null; + ex.printStackTrace(); + System.exit(1); } } - - private static void xmlMessage(String xmlFullName) throws UserError { - UserError ue = new UserError(localStrings.getLocalString(stringsAnchor, "main.cannot_read_clientContainer_xml", - "Client Container xml: {0} not found or unable to read.\nYou may want to use the -xml option to locate your configuration xml.", - new String[] { xmlFullName })); - ue.setUsage(getUsage()); - throw ue; - - } } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientGroupFacade.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientGroupFacade.java index f1038d151d8..3e6556028c3 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientGroupFacade.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/AppClientGroupFacade.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -16,11 +17,23 @@ package org.glassfish.appclient.client; -import org.glassfish.appclient.client.acc.UserError; +import org.glassfish.appclient.client.acc.AppClientContainer; +import org.glassfish.embeddable.client.ApplicationClientClassLoader; +import org.glassfish.embeddable.client.UserError; /** + * The AppClientContainerAgent initializes instrumentation, class loaders and also + * the {@link AppClientContainer} instance, which must be reachable for this class then + * - and that was a problem. The solution is to "smuggle" the container using + * the class loader, which is the only thing which can be shared with the agent. + *

+ * With the usage of JPMS it got yet bit more complicated as we had to keep some order + * between classes and class loaders and we also noticed an issue with Windows which limit + * the length of the command line; therefore we introduced another layer which automatically + * detects some GlassFish's jar files and we don't need to add them to the -classpath argument. * * @author tjquinn + * @author David Matejcek */ public class AppClientGroupFacade { @@ -29,19 +42,14 @@ public class AppClientGroupFacade { */ public static void main(String[] args) { try { - if (AppClientFacade.acc() == null) { - /* - * The facade JAR has been run directly, not via the appclient script and not via Java Web Start. So we have no agent - * arguments and no instrumentation for registering transformations. - */ - AppClientFacade.prepareACC(null, null); - } - AppClientFacade.launch(args); + ApplicationClientClassLoader loader = (ApplicationClientClassLoader) Thread.currentThread() + .getContextClassLoader(); + loader.getApplicationClientContainer().launch(args); + } catch (UserError ue) { + ue.displayAndExit(); } catch (Exception ex) { ex.printStackTrace(); System.exit(1); - } catch (UserError ue) { - ue.displayAndExit(); } } } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSACCMaskingClassLoader.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSACCMaskingClassLoader.java index b2b9e521c97..5e4368c827a 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSACCMaskingClassLoader.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSACCMaskingClassLoader.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -42,7 +43,7 @@ class JWSACCMaskingClassLoader extends MaskingClassLoader { private final Collection endorsedPackagesToMask; JWSACCMaskingClassLoader(ClassLoader parent, Collection endorsedPackagesToMask) { - super(parent, Collections.EMPTY_SET /* punchins */, Collections.EMPTY_SET /* multiples */, + super(parent, Collections.emptySet() /* punchins */, Collections.emptySet() /* multiples */, false /* useExplicitCallsToFindSystemClass */); this.endorsedPackagesToMask = endorsedPackagesToMask; } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSAppClientContainerMain.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSAppClientContainerMain.java index 2cbfa87b1dc..8845e183568 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSAppClientContainerMain.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/JWSAppClientContainerMain.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -33,9 +34,9 @@ import javax.swing.SwingUtilities; -import org.glassfish.appclient.client.acc.UserError; import org.glassfish.appclient.client.jws.boot.ErrorDisplayDialog; import org.glassfish.appclient.client.jws.boot.LaunchSecurityHelper; +import org.glassfish.embeddable.client.UserError; /** * @@ -88,18 +89,14 @@ public static void main(String[] args) { try { now = System.currentTimeMillis(); - /* - * Process any arguments (conveyed as properties in the JNLP) intended for the JWS-aware ACC. - */ + // Process any arguments (conveyed as properties in the JNLP) intended for the JWS-aware ACC. processJWSArgs(); final String agentArgsText = System.getProperty("agent.args"); LaunchSecurityHelper.setPermissions(); - /* - * Prevent the Java Web Start class loader from delegating to its parent when resolving classes and resources that - * should come from the GlassFish-provided endorsed JARs. - */ + // Prevent the Java Web Start class loader from delegating to its parent when resolving + // classes and resources that should come from the GlassFish-provided endorsed JARs. insertMaskingLoader(); final ClientRunner runner = new ClientRunner(agentArgsText, args); @@ -133,8 +130,8 @@ private ClientRunner(final String agentArgsText, final String[] args) { @Override public void run() { try { - AppClientFacade.prepareACC(agentArgsText, null); - AppClientFacade.launch(args); + AppClientContainerHolder.init(agentArgsText, null); + AppClientContainerHolder.getInstance().launch(args); logger.log(Level.FINE, "JWSAppClientContainer finished after {0} ms", (System.currentTimeMillis() - now)); } catch (UserError ue) { if (!isTestMode()) { @@ -155,9 +152,7 @@ private static void insertMaskingLoader() throws IOException, NoSuchFieldExcepti props.load(sr); final ClassLoader jwsLoader = Thread.currentThread().getContextClassLoader(); - final ClassLoader mcl = getMaskingClassLoader(jwsLoader.getParent(), props); - final Field jwsLoaderParentField = ClassLoader.class.getDeclaredField("parent"); jwsLoaderParentField.setAccessible(true); jwsLoaderParentField.set(jwsLoader, mcl); 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 8d2fcef3299..b9b4cf304b4 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 @@ -83,7 +83,7 @@ private static File getRootDirectory() { */ URI jarURI = null; try { - jarURI = ACCClassLoader.class.getProtectionDomain().getCodeSource().getLocation().toURI(); + jarURI = ACCStartupContext.class.getProtectionDomain().getCodeSource().getLocation().toURI(); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AgentArguments.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AgentArguments.java index a49e078f102..d9fc18e50d8 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AgentArguments.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AgentArguments.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -23,7 +24,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.glassfish.appclient.client.CLIBootstrap; +import org.glassfish.embeddable.client.ApplicationClientCLIEncoding; import static java.util.Collections.emptyList; import static java.util.regex.Pattern.DOTALL; @@ -103,10 +104,10 @@ private void scan(String args) { Matcher agentArgMatcher = agentArgPattern.matcher(args); while (agentArgMatcher.find()) { String keyword = agentArgMatcher.group(KEYWORD); - /* - * Either the quoted string group or the unquoted string group from the matcher will be valid. - */ - String value = CLIBootstrap.decodeArg(agentArgMatcher.group(QUOTED) != null ? agentArgMatcher.group(QUOTED) : agentArgMatcher.group(UNQUOTED)); + // Either the quoted string group or the unquoted string group from the matcher will be valid. + String value = ApplicationClientCLIEncoding.decodeArg(agentArgMatcher.group(QUOTED) == null + ? agentArgMatcher.group(UNQUOTED) + : agentArgMatcher.group(QUOTED)); values.computeIfAbsent(keyword, e -> new ArrayList<>()).add(value); } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainer.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainer.java index b7f416f5efd..071b4ff6645 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainer.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation. + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -40,7 +40,8 @@ import java.lang.reflect.Modifier; import java.net.URI; import java.net.URL; -import java.net.URLClassLoader; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.text.MessageFormat; import java.util.Collection; import java.util.List; @@ -63,6 +64,8 @@ import org.glassfish.appclient.client.acc.config.Property; import org.glassfish.appclient.client.acc.config.Security; import org.glassfish.appclient.client.acc.config.TargetServer; +import org.glassfish.embeddable.client.ApplicationClientContainer; +import org.glassfish.embeddable.client.UserError; import org.glassfish.hk2.api.PerLookup; import org.glassfish.hk2.api.ServiceHandle; import org.glassfish.hk2.api.ServiceLocator; @@ -79,7 +82,7 @@ *

  • create a new builder for an ACC (see {@link #newBuilder} and {@link AppClientContainerBuilder}), *
  • optionally modify the configuration by invoking various builder methods, *
  • create an embedded instance of the ACC from the builder using {@link AppClientContainerBuilder#newContainer() }, - *
  • startClient the client using {@link #startClient(String[])}, and + *
  • startClient the client using {@link #launch(String[])}, and *
  • stop the container using {@link #stop()}. * * @@ -166,7 +169,7 @@ */ @Service @PerLookup -public class AppClientContainer { +public class AppClientContainer implements ApplicationClientContainer { // XXX move this /** Prop name for keeping temporary files */ @@ -194,20 +197,16 @@ public class AppClientContainer { @Inject private ServiceLocator habitat; - private Builder builder; - private Cleanup cleanup; - private State state = State.INSTANTIATED; // HK2 will create the instance + private volatile State state; private ClientMainClassSetting clientMainClassSetting; - private URLClassLoader classLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); + private TransformingClassLoader classLoader; private Launchable client; - private CallbackHandler callerSuppliedCallbackHandler; - /** returned from binding the app client to naming; used in preparing component invocation */ private String componentId; @@ -221,54 +220,32 @@ public static AppClientContainer.Builder newBuilder(final TargetServer[] targetS return new AppClientContainerBuilder(targetServers); } - /* - * ********************* ABOUT INITIALIZATION ******************** - * - * Note that, internally, the AppClientContainerBuilder's newContainer methods use HK2 to instantiate the - * AppClientContainer object (so we can inject references to various other services). - * - * The newContainer method then invokes one of the ACC's prepare methods to initialize the ACC fully. All - * that is left at that point is for the client's main method to be invoked. - * - */ - public void startClient(String[] args) throws Exception, UserError { - prepare(null); - launch(args); + private AppClientContainer() { + this.classLoader = (TransformingClassLoader) Thread.currentThread().getContextClassLoader(); + this.state = State.INSTANTIATED; } void prepareSecurity(final TargetServer[] targetServers, final List msgSecConfigs, final Properties containerProperties, final ClientCredential clientCredential, - final CallbackHandler callerSuppliedCallbackHandler, final URLClassLoader classLoader, final boolean isTextAuth) + final CallbackHandler callerSuppliedCallbackHandler, final boolean isTextAuth) throws ReflectiveOperationException, InjectionException, IOException, SAXException { - appClientContainerSecurityHelper.init(targetServers, msgSecConfigs, containerProperties, clientCredential, callerSuppliedCallbackHandler, classLoader, - client.getDescriptor(classLoader), isTextAuth); - } - - void setCallbackHandler(final CallbackHandler callerSuppliedCallbackHandler) { - this.callerSuppliedCallbackHandler = callerSuppliedCallbackHandler; - } - - void setBuilder(final Builder builder) { - this.builder = builder; + appClientContainerSecurityHelper.init(targetServers, msgSecConfigs, containerProperties, clientCredential, + callerSuppliedCallbackHandler, classLoader, client.getDescriptor(classLoader), isTextAuth); } - public void prepare(final Instrumentation inst) throws NamingException, IOException, InstantiationException, IllegalAccessException, - InjectionException, ClassNotFoundException, SAXException, NoSuchMethodException, UserError { + public void prepare(final Instrumentation inst) throws Exception, UserError { completePreparation(inst); } void setClient(final Launchable client) throws ClassNotFoundException { this.client = client; clientMainClassSetting = ClientMainClassSetting.set(client.getMainClass()); - } void processPermissions() throws IOException { // need to process the permissions files - if (classLoader instanceof ACCClassLoader) { - ((ACCClassLoader) classLoader).processDeclaredPermissions(); - } + classLoader.processDeclaredPermissions(); } protected Class loadClass(final String className) throws ClassNotFoundException { @@ -281,44 +258,37 @@ protected ClassLoader getClassLoader() { /** * Gets the ACC ready so the main class can run. This can be followed, immediately or after some time, by either an - * invocation of {@link #launch(java.lang.String[]) or by the JVM invoking the client's main method (as would happen + * invocation of {@link #launch(java.lang.String[])} + * @throws Exception or by the JVM invoking the client's main method (as would happen * during a java -jar theClient.jar launch. - * - * @throws java.lang.Exception + * @throws UserError */ - private void completePreparation(final Instrumentation inst) throws NamingException, IOException, InstantiationException, - IllegalAccessException, InjectionException, ClassNotFoundException, SAXException, NoSuchMethodException, UserError { + private void completePreparation(final Instrumentation inst) throws Exception, UserError { if (state != State.INSTANTIATED) { - throw new IllegalStateException(); + throw new IllegalStateException( + "Expected state was " + State.INSTANTIATED + ", but current state was " + state); } - /* - * Attach any names defined in the app client. Validate the descriptor first, then use it to bind names in the app - * client. This order is important - for example, to set up message destination refs correctly. - */ + // Attach any names defined in the app client. Validate the descriptor first, then use it to + // bind names in the app client. This order is important - for example, to set up message + // destination refs correctly. client.validateDescriptor(); final ApplicationClientDescriptor desc = client.getDescriptor(classLoader); componentId = componentEnvManager.bindToComponentNamespace(desc); - /* - * Arrange for cleanup now instead of during launch() because in some use cases the JVM will invoke the client's main - * method itself and launch will be skipped. - */ + // Arrange for cleanup now instead of during launch() because in some use cases the JVM will + // invoke the client's main method itself and launch will be skipped. cleanup = Cleanup.arrangeForShutdownCleanup(logger, habitat, desc); - /* - * Allow pre-destroy handling to work on the main class during clean-up. - */ + // Allow pre-destroy handling to work on the main class during clean-up. cleanup.setInjectionManager(injectionManager, ClientMainClassSetting.clientMainClass); - /* - * If this app client contains persistence unit refs, then initialize the PU handling. - */ + // If this app client contains persistence unit refs, then initialize the PU handling. Collection referencedPUs = desc.findReferencedPUs(); if (referencedPUs != null && !referencedPUs.isEmpty()) { - ProviderContainerContractInfoImpl pcci = new ProviderContainerContractInfoImpl((ACCClassLoader) getClassLoader(), inst, - client.getAnchorDir(), connectorRuntime); + ProviderContainerContractInfoImpl pcci = new ProviderContainerContractInfoImpl( + (TransformingClassLoader) getClassLoader(), inst, client.getAnchorDir(), connectorRuntime); for (PersistenceUnitDescriptor puDesc : referencedPUs) { PersistenceUnitLoader pul = new PersistenceUnitLoader(puDesc, pcci); desc.addEntityManagerFactory(puDesc.getName(), pul.getEMF()); @@ -340,47 +310,45 @@ private void completePreparation(final Instrumentation inst) throws NamingExcept managedBeanManager.loadManagedBeans(desc.getApplication()); cleanup.setManagedBeanManager(managedBeanManager); - /** - * We don't really need the main method here but we do need the side-effects. - */ + // We don't really need the main method here but we do need the side-effects. getMainMethod(); state = State.PREPARED; } - public void launch(String[] args) throws NoSuchMethodException, ClassNotFoundException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException, IOException, SAXException, InjectionException, UserError { + public void launch(String[] args) throws UserError { if (state != State.PREPARED) { - throw new IllegalStateException(); - } - Method mainMethod = getMainMethod(); - // build args to the main and call it - Object params[] = new Object[1]; - params[0] = args; - - if (logger.isLoggable(Level.FINE)) { - dumpLoaderURLs(); + throw new IllegalStateException("Unexpected state. Expected " + State.PREPARED + ", actual is " + state); + } + Thread.currentThread().setContextClassLoader(classLoader); + try { + Method mainMethod = getMainMethod(); + // build args to the main and call it + if (logger.isLoggable(Level.FINE)) { + logger.log(Level.FINE, + "Current thread's classloader: " + Thread.currentThread().getContextClassLoader()); + } + mainMethod.invoke(null, new Object[] {args}); + state = State.STARTED; + } catch (InvocationTargetException e) { + if (e.getCause() instanceof UserError) { + throw (UserError) e.getCause(); + } + throw new IllegalStateException("Launch failed.", e.getCause()); + } catch (Exception e) { + throw new IllegalStateException("Launch failed.", e); + } finally { + // We need to clean up when the EDT ends or, if there is no EDT, right away. + // In particular, JMS/MQ-related non-daemon threads might still be running due to open + // queueing connections. + cleanupWhenSafe(); } - mainMethod.invoke(null, params); - state = State.STARTED; - - /* - * We need to clean up when the EDT ends or, if there is no EDT, right away. In particular, JMS/MQ-related non-daemon - * threads might still be running due to open queueing connections. - */ - cleanupWhenSafe(); } private boolean isEDTRunning() { - Map threads = java.security.AccessController - .doPrivileged(new java.security.PrivilegedAction>() { - - @Override - public Map run() { - return Thread.getAllStackTraces(); - } - }); + Map threads = AccessController + .doPrivileged((PrivilegedAction>) Thread::getAllStackTraces); logger.fine("Checking for EDT thread..."); for (Map.Entry entry : threads.entrySet()) { @@ -402,38 +370,18 @@ private void cleanupWhenSafe() { if (isEDTRunning()) { final AtomicReference edt = new AtomicReference<>(); try { - SwingUtilities.invokeAndWait(new Runnable() { - @Override - public void run() { - edt.set(Thread.currentThread()); - } - }); + SwingUtilities.invokeAndWait(() -> edt.set(Thread.currentThread())); edt.get().join(); } catch (Exception e) { - + logger.log(Level.WARNING, "Waiting for Swing thread failed.", e); } } stop(); } - private void dumpLoaderURLs() { - final String sep = System.lineSeparator(); - final ClassLoader ldr = Thread.currentThread().getContextClassLoader(); - if (ldr instanceof ACCClassLoader) { - final ACCClassLoader loader = (ACCClassLoader) ldr; - final URL[] urls = loader.getURLs(); - - final StringBuilder sb = new StringBuilder("Class loader URLs:"); - for (URL url : urls) { - sb.append(" ").append(url.toExternalForm()).append(sep); - } - sb.append(sep); - logger.fine(sb.toString()); - } - } private Method getMainMethod() - throws NoSuchMethodException, ClassNotFoundException, IOException, SAXException, InjectionException, UserError { + throws UserError, ReflectiveOperationException, InjectionException, IOException, SAXException { // determine the main method using reflection // verify that it is public static void and takes // String[] as the only argument @@ -459,28 +407,25 @@ private Method getMainMethod() return result; } + /** * Stops the app client container. *

    - * Note that the calling program should not stop the ACC if there might be other threads running, such as the Swing - * event dispatcher thread. Stopping the ACC can shut down various services that those continuing threads might try to - * use. + * Note that the calling program should not stop the ACC if there might be other threads + * running, such as the Swing event dispatcher thread. Stopping the ACC can shut down various + * services that those continuing threads might try to use. *

    - * Also note that stopping the ACC will have no effect on any thread that the app client itself might have created. If - * the calling program needs to control such threads it and the client code running in the threads should agree on how - * they will communicate with each other. The ACC cannot help with this. + * Also note that stopping the ACC will have no effect on any thread that the app client itself + * might have created. If the calling program needs to control such threads it and the client + * code running in the threads should agree on how they will communicate with each other. + * The ACC cannot help with this. */ public void stop() { - /* - * Because stop can be invoked automatically at the end of launch, allow the developer's driver program to invoke stop - * again without penalty. - */ + // Because stop can be invoked automatically at the end of launch, allow the developer's + // driver program to invoke stop again without penalty. if (state == State.STOPPED) { return; } - if (state != State.STARTED) { - throw new IllegalStateException(); - } cleanup.start(); state = State.STOPPED; } @@ -493,7 +438,7 @@ enum ClientMainClassSetting { static String clientMainClassName; static volatile Class clientMainClass; - static boolean isInjected = false; + static boolean isInjected; static ClientMainClassSetting set(final String name) { clientMainClassName = name; @@ -515,12 +460,11 @@ static Class getClientMainClass(final ClassLoader loader, InjectionManager injec throw new IllegalStateException("neither client main class nor its class name has been set"); } clientMainClass = Class.forName(clientMainClassName, true, loader); - if (logger.isLoggable(Level.FINE)) { - logger.log(Level.FINE, "Loaded client main class {0}", clientMainClassName); - } + logger.log(Level.FINE, "Loaded client main class {0}", clientMainClassName); } - ComponentInvocation ci = new ComponentInvocation(componentId, ComponentInvocation.ComponentInvocationType.APP_CLIENT_INVOCATION, - container, acDesc.getApplication().getAppName(), acDesc.getModuleName()); + ComponentInvocation ci = new ComponentInvocation(componentId, + ComponentInvocation.ComponentInvocationType.APP_CLIENT_INVOCATION, container, + acDesc.getApplication().getAppName(), acDesc.getModuleName()); invocationManager.preInvoke(ci); InjectionException injExc = null; @@ -603,7 +547,7 @@ enum State { * EAR that contains multiple app clients as submodules within it; the ACC needs the calling program to specify which of * the possibly several app client modules is the one to execute. * - * @param mainClassName + * @param clientMainClassName * @return */ public void setClientMainClassName(final String clientMainClassName) throws ClassNotFoundException { @@ -621,22 +565,17 @@ void setClientMainClass(final Class clientMainClass) { */ private static void prepareURLStreamHandling() { // Set the HTTPS URL stream handler. - java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { - @Override - public Object run() { - URL.setURLStreamHandlerFactory(new DirContextURLStreamHandlerFactory()); - return null; - } - }); + PrivilegedAction action = () -> { + URL.setURLStreamHandlerFactory(new DirContextURLStreamHandlerFactory()); + return null; + }; + AccessController.doPrivileged(action); } - void setClassLoader(ACCClassLoader classLoader) { - this.classLoader = classLoader; - } /** - * Prescribes the exposed behavior of ACC configuration that can be set up further, and can be used to newContainer an - * ACC. + * Prescribes the exposed behavior of ACC configuration that can be set up further, and can be + * used to newContainer an ACC. */ public interface Builder { diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerBuilder.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerBuilder.java index d65a66c207c..725fce7617b 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerBuilder.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -18,11 +18,11 @@ package org.glassfish.appclient.client.acc; import com.sun.enterprise.container.common.spi.util.InjectionException; -import com.sun.enterprise.module.bootstrap.BootException; import com.sun.enterprise.util.LocalStringManager; import com.sun.enterprise.util.LocalStringManagerImpl; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URISyntaxException; import java.net.URLClassLoader; @@ -39,6 +39,7 @@ import org.glassfish.appclient.client.acc.config.Property; import org.glassfish.appclient.client.acc.config.TargetServer; import org.glassfish.appclient.client.acc.config.util.XML; +import org.glassfish.embeddable.client.UserError; import org.glassfish.enterprise.iiop.api.GlassFishORBHelper; import org.xml.sax.SAXException; @@ -69,12 +70,13 @@ public class AppClientContainerBuilder implements AppClientContainer.Builder { private static final LocalStringManager localStrings = new LocalStringManagerImpl(AppClientContainerBuilder.class); + private final URLClassLoader classLoader; + /** caller-specified target servers */ private TargetServer[] targetServers; private AuthRealm authRealm; - private final URLClassLoader classLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); /** * The caller can pre-set the client credentials using the clientCredentials method. The ACC will use the @@ -95,10 +97,6 @@ public class AppClientContainerBuilder implements AppClientContainer.Builder { */ private Properties containerProperties; - AppClientContainerBuilder() { - - } - /** * Creates a new builder with the specified target servers and client URI. * @@ -107,6 +105,7 @@ public class AppClientContainerBuilder implements AppClientContainer.Builder { */ AppClientContainerBuilder(final TargetServer[] targetServers) { this.targetServers = targetServers; + this.classLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); } public AppClientContainer newContainer(final Class mainClass, final CallbackHandler callerSpecifiedCallbackHandler) throws Exception { @@ -155,27 +154,27 @@ public AppClientContainer newContainer(final URI clientURI) throws Exception, Us private AppClientContainer createContainer(final Launchable client, final CallbackHandler callerSuppliedCallbackHandler, final boolean isTextAuth) - throws BootException, URISyntaxException, ReflectiveOperationException, InjectionException, IOException, SAXException { + throws ReflectiveOperationException, InjectionException, IOException, SAXException { AppClientContainer container = ACCModulesManager.getService(AppClientContainer.class); // process the packaged permissions.xml container.processPermissions(); container.setClient(client); - container.setBuilder(this); - CallbackHandler callbackHandler = (callerSuppliedCallbackHandler != null ? callerSuppliedCallbackHandler - : getCallbackHandlerFromDescriptor(client.getDescriptor(classLoader).getCallbackHandler())); - container.prepareSecurity(targetServers, messageSecurityConfigs, containerProperties, clientCredential, callbackHandler, - classLoader, isTextAuth); + CallbackHandler callbackHandler = callerSuppliedCallbackHandler == null + ? getCallbackHandlerFromDescriptor(client.getDescriptor(classLoader).getCallbackHandler()) + : callerSuppliedCallbackHandler; + container.prepareSecurity(targetServers, messageSecurityConfigs, containerProperties, clientCredential, + callbackHandler, isTextAuth); return container; } private CallbackHandler getCallbackHandlerFromDescriptor(final String callbackHandlerName) - throws ClassNotFoundException, InstantiationException, IllegalAccessException { + throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, SecurityException { if (callbackHandlerName != null && !callbackHandlerName.equals("")) { Class callbackHandlerClass = (Class) Class.forName(callbackHandlerName, true, classLoader); - return callbackHandlerClass.newInstance(); + return callbackHandlerClass.getDeclaredConstructor().newInstance(); } return null; diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerSecurityHelper.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerSecurityHelper.java index 1720cab8de1..03f967dd75f 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerSecurityHelper.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppClientContainerSecurityHelper.java @@ -66,7 +66,7 @@ void init(final TargetServer[] targetServers, final List final ApplicationClientDescriptor acDesc, final boolean isTextAuth) throws ReflectiveOperationException, InjectionException, IOException { - this.classLoader = (classLoader == null) ? Thread.currentThread().getContextClassLoader() : classLoader; + this.classLoader = classLoader; initLoginConfig(); CallbackHandler callbackHandler = initSecurity(callerSuppliedCallbackHandler, acDesc); @@ -105,7 +105,7 @@ private void initLoginConfig() throws IOException { * config file contains a blank then ConfigFile class expects the URL to contain a blank, not %20 for example. So, we * need to use the deprecated File.toURL() method to create such a URL. */ - System.setProperty("java.security.auth.login.config", configFile.toURL().toString()); + System.setProperty("java.security.auth.login.config", configFile.toURI().toURL().toString()); } /** diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppclientCommandArguments.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppclientCommandArguments.java index 62a74159860..84c2e77b997 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppclientCommandArguments.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/AppclientCommandArguments.java @@ -35,6 +35,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.glassfish.embeddable.client.UserError; + /** * Encapsulates handling of appclient script command arguments and options. *

    diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/CommandLaunchInfo.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/CommandLaunchInfo.java index 5f036684141..16815de9a9e 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/CommandLaunchInfo.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/CommandLaunchInfo.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -48,29 +49,16 @@ public class CommandLaunchInfo { /* records the client JAR file path, directory path, class name, or class file path */ private String clientName; - private String appcPath = null; - -// /** -// * Creates and returns a new CommandLaunchInfo instance. -// *

    -// * Typically the caller is the agent which will pass the agent arguments -// * it received when the VM invoked its premain method. -// * -// * @param agentArgs string of agent arguments -// * @return new CommandLaunchInfo object -// */ -// public static CommandLaunchInfo newInstance(final String agentArgs) throws UserError { -// CommandLaunchInfo result = new CommandLaunchInfo(agentArgs); -// return result; -// } - - public static CommandLaunchInfo newInstance(final AgentArguments agentArgs) throws UserError { + private String appcPath; + + + public static CommandLaunchInfo newInstance(final AgentArguments agentArgs) { final CommandLaunchInfo result = new CommandLaunchInfo(agentArgs); return result; } - private CommandLaunchInfo(final AgentArguments agentArgs) throws UserError { + private CommandLaunchInfo(final AgentArguments agentArgs) { clientLaunchType = saveArgInfo(agentArgs); } @@ -98,8 +86,7 @@ public String getAppcPath() { return appcPath; } - private ClientLaunchType saveArgInfo( - final AgentArguments agentArgs) throws UserError { + private ClientLaunchType saveArgInfo(final AgentArguments agentArgs) { if (agentArgs == null){ return ClientLaunchType.UNKNOWN; } @@ -117,7 +104,7 @@ private ClientLaunchType saveArgInfo( } private String lastFromList(final List list) { - return (list.isEmpty() ? null : list.get(list.size() - 1)); + return list.isEmpty() ? null : list.get(list.size() - 1); } private ClientLaunchType processClientArg(final String clientSpec) { @@ -132,9 +119,7 @@ private ClientLaunchType processClientArg(final String clientSpec) { if (clientName.startsWith("\"") && clientName.endsWith("\"")) { clientName = clientName.substring(1, clientName.length() - 1); } - ClientLaunchType type = ClientLaunchType.byType(clientType); - - return type; + return ClientLaunchType.byType(clientType); } private void processAppcPath(final String appcPath) { diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/FacadeLaunchable.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/FacadeLaunchable.java index e6a6bb66da6..f3818b51ed8 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/FacadeLaunchable.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/FacadeLaunchable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -46,6 +46,7 @@ import org.glassfish.api.deployment.archive.ReadableArchive; import org.glassfish.appclient.common.ACCAppClientArchivist; +import org.glassfish.embeddable.client.UserError; import org.glassfish.hk2.api.ServiceLocator; import org.xml.sax.SAXException; @@ -267,15 +268,8 @@ public ApplicationClientDescriptor getDescriptor(final URLClassLoader loader) th */ archivist.setAnnotationProcessingRequested( ! isJWSLaunch); - final ACCClassLoader tempLoader = AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public ACCClassLoader run() { - return new ACCClassLoader(loader.getURLs(), loader.getParent()); - } - - }); - + PrivilegedAction action = () -> new TransformingClassLoader(loader.getURLs(), loader.getParent()); + final TransformingClassLoader tempLoader = AccessController.doPrivileged(action); archivist.setClassLoader(tempLoader); diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/Launchable.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/Launchable.java index 6632b10c2db..4eafbfdad61 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/Launchable.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/Launchable.java @@ -34,6 +34,7 @@ import javax.xml.stream.XMLStreamException; import org.glassfish.api.deployment.archive.ReadableArchive; +import org.glassfish.embeddable.client.UserError; import org.glassfish.hk2.api.ServiceLocator; import org.xml.sax.SAXException; @@ -104,9 +105,9 @@ static Launchable newLaunchable(final URI uri, * ACCClassLoader instance yet. Create one if needed * before proceeding. */ - ACCClassLoader cl = ACCClassLoader.instance(); + TransformingClassLoader cl = TransformingClassLoader.instance(); if (cl == null) { - cl = ACCClassLoader.newInstance(Thread.currentThread().getContextClassLoader(), false); + cl = TransformingClassLoader.newInstance(Thread.currentThread().getContextClassLoader(), false); } cl.appendURL(clientOrFacadeURL); } @@ -122,15 +123,8 @@ static ApplicationClientDescriptor openWithAnnoProcessingAndTempLoader( final ReadableArchive facadeRA, final ReadableArchive clientRA) throws IOException, SAXException { archivist.setAnnotationProcessingRequested(true); - final ACCClassLoader tempLoader = AccessController.doPrivileged( - new PrivilegedAction() { - - @Override - public ACCClassLoader run() { - return new ACCClassLoader(loader.getURLs(), loader.getParent()); - } - } - ); + PrivilegedAction action = () -> new TransformingClassLoader(loader.getURLs(), loader.getParent()); + final TransformingClassLoader tempLoader = AccessController.doPrivileged(action); archivist.setClassLoader(tempLoader); final ApplicationClientDescriptor acDesc = archivist.open(facadeRA, clientRA); diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/LocalStrings.properties b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/LocalStrings.properties index 21ec1154e4e..537af995688 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/LocalStrings.properties +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/LocalStrings.properties @@ -75,7 +75,3 @@ appclient.cannotOpenModuleManifest=Error opening manifest for module {0} appclient.cannotCloseModuleManifest=Error closing manifest for module {0} appclient.multClientsNoChoice=The application contains multiple app clients; please choose one using -mainclass {0} or -name {1} appclient.missingValue=Value for {0} expected but was not configured or assigned - -main.usage=Usage :\n\tappclient [ | -client ] \n\t\t[-mainclass |-name ] \n\t\t[-xml ] \n\t\t[-textauth] [-user ] [-password |-passwordfile ] \n\t\t[-targetserver host[:port][,host[:port]...] \n\t\t[app-args] -main.usage.1=or :\n\tappclient [ ]\n\t\t[ | -jar ] \n\t\t[app args] -main.badVersion=Current Java version {0} is too low; {1} or later required diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/MainClassLaunchable.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/MainClassLaunchable.java index 9ae37b1ceed..a65bf0f7f0e 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/MainClassLaunchable.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/MainClassLaunchable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -33,6 +33,7 @@ import java.net.URLClassLoader; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Objects; import java.util.jar.Attributes; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; @@ -71,8 +72,8 @@ public ApplicationClientDescriptor getDescriptor(final URLClassLoader loader) th // There is no developer-provided descriptor possible so just use a default one. if (acDesc == null) { ReadableArchive tempArchive = null; - PrivilegedAction action = () -> new ACCClassLoader(loader.getURLs(), loader.getParent()); - final ACCClassLoader tempLoader = AccessController.doPrivileged(action); + PrivilegedAction action = () -> new TransformingClassLoader(loader.getURLs(), loader.getParent()); + final TransformingClassLoader tempLoader = AccessController.doPrivileged(action); tempArchive = createArchive(tempLoader, mainClass); final AppClientArchivist acArchivist = getArchivist(tempArchive, tempLoader); archivist.setClassLoader(tempLoader); @@ -109,9 +110,10 @@ private ReadableArchive createArchive(final ClassLoader loader, final Class m final ZipEntry mainClassEntry = new ZipEntry(mainClassResourceName); jos.putNextEntry(mainClassEntry); InputStream is = loader.getResourceAsStream(mainClassResourceName); + Objects.requireNonNull(is, "Resource not found " + mainClassResourceName + " by class loader " + loader); int bytesRead; - byte[] buffer = new byte[1024]; - while ( (bytesRead = is.read(buffer)) != -1) { + byte[] buffer = new byte[4096]; + while ((bytesRead = is.read(buffer)) != -1) { jos.write(buffer, 0, bytesRead); } is.close(); @@ -119,12 +121,9 @@ private ReadableArchive createArchive(final ClassLoader loader, final Class m jos.close(); MemoryMappedArchive mma = new MemoryMappedArchive(baos.toByteArray()); - /* - * Some archive-related processing looks for the file type from the URI, so set it - * to something. - */ + // Some archive-related processing looks for the file type from the URI, + // so set it to something. mma.setURI(URI.create("file:///tempClient.jar")); - return mma; } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java index a4eb7cf63cd..2649b8a97d7 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ProviderContainerContractInfoImpl.java @@ -48,7 +48,7 @@ */ public class ProviderContainerContractInfoImpl extends ProviderContainerContractInfoBase { - private final ACCClassLoader classLoader; + private final TransformingClassLoader classLoader; private final Instrumentation inst; private final String applicationLocation; @@ -63,7 +63,7 @@ public class ProviderContainerContractInfoImpl extends ProviderContainerContract * @param inst VM's instrumentation object */ public ProviderContainerContractInfoImpl( - final ACCClassLoader classLoader, + final TransformingClassLoader classLoader, final Instrumentation inst, final String applicationLocation, final ConnectorRuntime connectorRuntime) { diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TargetServerHelper.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TargetServerHelper.java index 4d005ff89b3..0eb9b55cb00 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TargetServerHelper.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TargetServerHelper.java @@ -23,6 +23,7 @@ import org.glassfish.appclient.client.acc.config.Property; import org.glassfish.appclient.client.acc.config.Security; import org.glassfish.appclient.client.acc.config.TargetServer; +import org.glassfish.embeddable.client.UserError; import org.glassfish.enterprise.iiop.api.GlassFishORBHelper; /** diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TestMain.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TestMain.java index 05aa7820b9f..f78fba3b5aa 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TestMain.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TestMain.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to Eclipse Foundation. * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,27 +18,19 @@ package org.glassfish.appclient.client.acc; /** - * * @author tjquinn */ public class TestMain { private static final String JAR_CLIENT_NAME = "there/myClient.jar"; - private static final String DIR_CLIENT_NAME = "here/myClient"; private static final String USER_VALUE = "joe-the-user"; - private static final String PASSWORDFILE_NAME = "topSecret.stuff"; /** * @param args the command line arguments */ public static void main(String[] args) { - try { - final AgentArguments agentArgs = AgentArguments.newInstance( - "mode=acscript" + ",client=jar=" + JAR_CLIENT_NAME + ",arg=-textauth" + ",arg=-user,arg=" + USER_VALUE); - CommandLaunchInfo.newInstance(agentArgs); - } catch (UserError ex) { - System.err.println(ex.getLocalizedMessage()); - - } + final AgentArguments agentArgs = AgentArguments.newInstance( + "mode=acscript" + ",client=jar=" + JAR_CLIENT_NAME + ",arg=-textauth" + ",arg=-user,arg=" + USER_VALUE); + CommandLaunchInfo.newInstance(agentArgs); } } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TransformingClassLoader.java similarity index 59% rename from appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java rename to appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TransformingClassLoader.java index 0cbb5695175..c2013ef1f27 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/ACCClassLoader.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/TransformingClassLoader.java @@ -21,11 +21,14 @@ import com.sun.enterprise.util.io.FileUtils; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.instrument.ClassFileTransformer; import java.lang.instrument.IllegalClassFormatException; +import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Path; import java.security.CodeSource; import java.security.PermissionCollection; import java.security.PrivilegedAction; @@ -34,10 +37,12 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; -import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Stream; -import org.glassfish.appclient.common.ClassPathUtils; import org.glassfish.appclient.common.ClientClassLoaderDelegate; +import org.glassfish.embeddable.client.ApplicationClientClassLoader; import org.glassfish.main.jdke.cl.GlassfishUrlClassLoader; import static java.security.AccessController.doPrivileged; @@ -47,83 +52,64 @@ * * @author tjquinn */ -public class ACCClassLoader extends GlassfishUrlClassLoader { +public class TransformingClassLoader extends GlassfishUrlClassLoader { static { registerAsParallelCapable(); } - private static final String AGENT_LOADER_CLASS_NAME = "org.glassfish.appclient.client.acc.agent.ACCAgentClassLoader"; - private static ACCClassLoader instance; + private static final Function PATH_TO_URL = p -> { + try { + return p.toUri().toURL(); + } catch (MalformedURLException e) { + throw new IllegalStateException("Could not convert path to url: " + p, e); + } + }; - private ACCClassLoader shadow; - private boolean shouldTransform; + private static TransformingClassLoader instance; - private final List transformers = Collections.synchronizedList(new ArrayList()); + private TransformingClassLoader shadow; + private final boolean shouldTransform; + private final List transformers = Collections.synchronizedList(new ArrayList<>()); private ClientClassLoaderDelegate clientCLDelegate; - public static synchronized ACCClassLoader newInstance(ClassLoader parent, boolean shouldTransform) { + /** + * @param parent + * @param shouldTransform + * @return new class loader + * @throws IllegalStateException + * @throws IllegalArgumentException + */ + public static synchronized TransformingClassLoader newInstance(ClassLoader parent, boolean shouldTransform) { if (instance != null) { - throw new IllegalStateException("already set"); + throw new IllegalStateException("Already set"); } - - ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); - boolean currentCLWasAgentCL = currentClassLoader.getClass().getName().equals(AGENT_LOADER_CLASS_NAME); - ClassLoader parentForACCCL = currentCLWasAgentCL ? currentClassLoader.getParent() : currentClassLoader; - - PrivilegedAction action = () -> { - URL[] classpath = ClassPathUtils.getJavaClassPathForAppClient(); - return new ACCClassLoader(classpath, parentForACCCL, shouldTransform); + PrivilegedAction action = () -> { + return parent instanceof ApplicationClientClassLoader + // Parent already comes with user dependencies + ? new TransformingClassLoader(new URL[0], parent, shouldTransform) + // Otherwise adopt system class path, environment options, whatever. + : new TransformingClassLoader(createClassPath(), parent, shouldTransform); }; instance = doPrivileged(action); - - if (currentCLWasAgentCL) { - try { - adjustACCAgentClassLoaderParent(instance); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - return instance; } - public static ACCClassLoader instance() { + public static TransformingClassLoader instance() { return instance; } - private static void adjustACCAgentClassLoaderParent(ACCClassLoader instance) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException { - ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); - - if (systemClassLoader.getClass().getName().equals(AGENT_LOADER_CLASS_NAME)) { - if (systemClassLoader instanceof Consumer) { - - @SuppressWarnings("unchecked") - Consumer consumerOfClassLoader = (Consumer) systemClassLoader; - - consumerOfClassLoader.accept(instance); - - System.setProperty("org.glassfish.appclient.acc.agentLoaderDone", "true"); - } - } - } - - - public ACCClassLoader(ClassLoader parent, final boolean shouldTransform) { - super("ApplicationClient", new URL[0], parent); + private TransformingClassLoader(URL[] classpath, ClassLoader parent, boolean shouldTransform) { + super("Transformer", classpath, parent); this.shouldTransform = shouldTransform; - clientCLDelegate = new ClientClassLoaderDelegate(this); + this.clientCLDelegate = new ClientClassLoaderDelegate(this); } - public ACCClassLoader(URL[] urls, ClassLoader parent) { - super("ApplicationClient", urls, parent); - clientCLDelegate = new ClientClassLoaderDelegate(this); - } - - private ACCClassLoader(URL[] urls, ClassLoader parent, boolean shouldTransform) { - this(urls, parent); - this.shouldTransform = shouldTransform; + public TransformingClassLoader(URL[] urls, ClassLoader parent) { + super("Transformer", urls, parent); + this.shouldTransform = false; + this.clientCLDelegate = new ClientClassLoaderDelegate(this); } public synchronized void appendURL(final URL url) { @@ -137,21 +123,11 @@ public void addTransformer(final ClassFileTransformer xf) { transformers.add(xf); } - public void setShouldTransform(final boolean shouldTransform) { - this.shouldTransform = shouldTransform; - } - - synchronized ACCClassLoader shadow() { + synchronized TransformingClassLoader shadow() { if (shadow == null) { - shadow = doPrivileged(new PrivilegedAction() { - @Override - public ACCClassLoader run() { - return new ACCClassLoader(getURLs(), getParent()); - } - - }); + PrivilegedAction action = () -> new TransformingClassLoader(getURLs(), getParent()); + shadow = doPrivileged(action); } - return shadow; } @@ -218,15 +194,27 @@ public void processDeclaredPermissions() throws IOException { @Override public Enumeration getResources(String name) throws IOException { - final ResourceLocator locator = new ResourceLocator(this, getParentClassLoader(), true); + final ResourceLocator locator = new ResourceLocator(this, getParent(), true); return locator.getResources(name); } - private ClassLoader getParentClassLoader() { - final ClassLoader parent = getParent(); - if (parent == null) { - return getSystemClassLoader(); + private static URL[] createClassPath() { + final Stream cpPaths = convertClassPathToPaths(System.getProperty("java.class.path")); + final Stream envPaths = convertClassPathToPaths(System.getenv("APPCPATH")); + final Predicate filterOutGfClient = f -> !f.endsWith(Path.of("gf-client.jar")); + return Stream.concat(cpPaths, envPaths).map(Path::toAbsolutePath).map(Path::normalize).distinct() + .filter(filterOutGfClient).map(PATH_TO_URL).toArray(URL[]::new); + } + + private static Stream convertClassPathToPaths(final String classPath) { + if (classPath == null || classPath.isBlank()) { + return Stream.empty(); + } + try { + return Stream.of(classPath.split(File.pathSeparator)).map(File::new).map(File::toPath); + } catch (Exception e) { + throw new IllegalArgumentException("Could not parse the classpath: " + classPath, e); } - return parent; } + } diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java index bc10fd0657e..d945b3aa510 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/acc/UndeployedLaunchable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Contributors to the Eclipse Foundation + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -38,6 +38,7 @@ import org.glassfish.api.deployment.archive.ReadableArchive; import org.glassfish.deployment.common.ModuleDescriptor; import org.glassfish.deployment.common.RootDeploymentDescriptor; +import org.glassfish.embeddable.client.UserError; import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.main.jdke.i18n.LocalStringsImpl; import org.xml.sax.SAXException; @@ -77,8 +78,7 @@ static UndeployedLaunchable newUndeployedLaunchable( */ Archivist archivist = af.getArchivist("car", classLoader); if (archivist == null) { - throw new UserError(localStrings.get("appclient.invalidArchive", - ra.getURI().toASCIIString())); + throw new UserError(localStrings.get("appclient.invalidArchive", ra.getURI().toASCIIString())); } final ArchiveType moduleType = archivist.getModuleType(); @@ -227,14 +227,8 @@ private String extractMainClassFromArchive(final ReadableArchive clientRA) throw public ApplicationClientDescriptor getDescriptor(final URLClassLoader loader) throws IOException, SAXException { this.classLoader = loader; if (acDesc == null) { - final AppClientArchivist _archivist = getArchivist( - AccessController.doPrivileged(new PrivilegedAction() { - - @Override - public ACCClassLoader run() { - return new ACCClassLoader(loader.getURLs(), loader.getParent()); - } - })); + PrivilegedAction action = () -> new TransformingClassLoader(loader.getURLs(), loader.getParent()); + final AppClientArchivist _archivist = getArchivist(AccessController.doPrivileged(action)); _archivist.setAnnotationProcessingRequested(true); acDesc = _archivist.open(clientRA); diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/ErrorDisplayDialog.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/ErrorDisplayDialog.java index 677cdeb5d41..9f590a41b2f 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/ErrorDisplayDialog.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/ErrorDisplayDialog.java @@ -29,7 +29,7 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; -import org.glassfish.appclient.client.acc.UserError; +import org.glassfish.embeddable.client.UserError; /** * Displays errors detected after Java Web Start has launched the diff --git a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/JWSACCMain.java b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/JWSACCMain.java index 9a73e1c9a56..858fc519c34 100644 --- a/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/JWSACCMain.java +++ b/appserver/appclient/client/acc/src/main/java/org/glassfish/appclient/client/jws/boot/JWSACCMain.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2022 Contributors to the Eclipse Foundation * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -60,21 +60,12 @@ */ public class JWSACCMain implements Runnable { -// /** path to a class in one of the app server lib jars downloaded by Java Web Start */ -// private static final String APPSERVER_LIB_CLASS_NAME = "com.sun.enterprise.server.ApplicationServer"; - /** name of the permissions template */ private static final String PERMISSIONS_TEMPLATE_NAME = "jwsclient.policy"; /** placeholder used in the policy template to substitute dynamically-generated grant clauses */ private static final String GRANT_CLAUSES_PROPERTY_EXPR = "${grant.clauses}"; - /** line separator */ - private static final String lineSep = System.getProperty("line.separator"); - - /** the user-specified security policy template to use */ - private static String jwsPolicyTemplateURL = null; - /** unpublished command-line argument conveying jwsacc information */ private static final String JWSACC_ARGUMENT_PREFIX = "-jwsacc"; @@ -167,7 +158,8 @@ public static void main(String[] args) { *components or the JVM will never exit. */ } catch (Throwable thr) { - System.exit(1); + thr.printStackTrace(); + System.exit(1); } } @@ -191,14 +183,14 @@ public void run() { System.setProperty("com.sun.aas.downloaded.appclient.jar", downloadedAppclientJarFile.getAbsolutePath()); Thread.currentThread().setContextClassLoader(loader); - + System.err.println("XXXX: JWSACCMain.run set CL to thread: " + loader); /* *Use the prepared class loader to load the ACC main method, prepare *the arguments to the constructor, and invoke the static main method. */ - Class mainClass = Class.forName("com.sun.enterprise.appclient.MainWithModuleSupport", + Class mainClass = Class.forName("com.sun.enterprise.appclient.MainWithModuleSupport", true /* initialize */, loader); - Constructor constr = mainClass.getConstructor(new Class[] {String[].class, URL[].class}); + Constructor constr = mainClass.getDeclaredConstructor(String[].class, URL[].class); constr.newInstance(args, persistenceJarURLs); } catch(Throwable thr) { exitValue = 1; diff --git a/appserver/appclient/client/acc/src/main/resources/org/glassfish/appclient/client/acc/LocalStrings.properties b/appserver/appclient/client/acc/src/main/resources/org/glassfish/appclient/client/acc/LocalStrings.properties index 16dbdaeeaae..7710227c618 100644 --- a/appserver/appclient/client/acc/src/main/resources/org/glassfish/appclient/client/acc/LocalStrings.properties +++ b/appserver/appclient/client/acc/src/main/resources/org/glassfish/appclient/client/acc/LocalStrings.properties @@ -62,7 +62,3 @@ appclient.serverWithoutValue=The -targetserver option must be followed by host[: appclient.portNotValid=The server expression {0} contains an invalid port number {1} appclient.cannotOpenModuleManifest=Error opening manifest for module {0} appclient.cannotCloseModuleManifest=Error closing manifest for module {0} - -main.usage=Usage 1:\n\tappclient [ | -client ] \n\t\t[-mainclass |-name ] \n\t\t[-xml ] \n\t\t[-textauth] [-user ] [-password |-passwordfile ] \n\t\t[-targetserver host[:port][,host[:port]]...] \n\t\t[app-args] -main.usage.1=Usage 2:\n\tappclient [ ]\n\t\t[ | -jar ] \n\t\t[app args] -main.badVersion=Current Java version {0} is too low; {1} or later required diff --git a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/AppclientCommandArgumentsTest.java b/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/AppclientCommandArgumentsTest.java index fec1252ff62..18fe3e57fc7 100644 --- a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/AppclientCommandArgumentsTest.java +++ b/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/AppclientCommandArgumentsTest.java @@ -27,6 +27,7 @@ import java.util.Properties; import java.util.logging.Logger; +import org.glassfish.embeddable.client.UserError; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/CommandLaunchInfoTest.java b/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/CommandLaunchInfoTest.java index 1bd9fb45ffc..3a94f23759f 100644 --- a/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/CommandLaunchInfoTest.java +++ b/appserver/appclient/client/acc/src/test/java/org/glassfish/appclient/client/acc/CommandLaunchInfoTest.java @@ -24,6 +24,7 @@ import java.util.List; import org.glassfish.appclient.client.acc.CommandLaunchInfo.ClientLaunchType; +import org.glassfish.embeddable.client.UserError; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient index 2befdb1a79b..41521673128 100644 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient @@ -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. @@ -70,9 +70,4 @@ esac . "${AS_INSTALL}/config/asenv.conf" chooseJava - -ACC_MODULEPATH="${AS_INSTALL}/lib/bootstrap" -ACC_INSTALL_LIB="${AS_INSTALL}/lib/install/applications"; -ACC_CLASSPATH="${AS_INSTALL}/lib/gf-client.jar:${AS_INSTALL}/lib/appclient/weld-se-shaded.jar:$AS_INSTALL/admin-cli.jar:$AS_DERBY_INSTALL/lib/*:$ACC_INSTALL_LIB/__ds_jdbc_ra/jdbc-ra-ds.jar:$ACC_INSTALL_LIB/__cp_jdbc_ra/jdbc-ra-cp.jar:$ACC_INSTALL_LIB/__xa_jdbc_ra/jdbc-ra-xa.jar:$ACC_INSTALL_LIB/__dm_jdbc_ra/jdbc-ra-dm.jar:$ACC_INSTALL_LIB/jmsra/imqjmsra.jar:${AS_IMQ_LIB}/imq.jar:${AS_IMQ_LIB}/imqadmin.jar:${AS_IMQ_LIB}/imqutil.jar:${AS_IMQ_LIB}/fscontext.jar:$AS_INSTALL/modules/*" - -eval "`"${ACCJava}" -Dorg.glassfish.appclient.shell $cygwinProp --module-path "${ACC_MODULEPATH}" --add-modules ALL-MODULE-PATH -cp "${ACC_CLASSPATH}" org.glassfish.appclient.client.CLIBootstrap "$@"`" +eval "`"${ACCJava}" -Dorg.glassfish.appclient.shell $cygwinProp --module-path "${AS_INSTALL}/lib/bootstrap" --add-modules ALL-MODULE-PATH -classpath "${AS_INSTALL}/lib/gf-client.jar" org.glassfish.appclient.client.acc.agent.CLIBootstrap "$@"`" diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat index cb12e49a19e..81d430c0fc5 100644 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.bat @@ -66,12 +66,10 @@ rem issue the error so we don't have to do i18n of our own message from the scri goto :EOF :main -set AS_INSTALL="%~dp0.." +set ARGS=%* +set AS_INSTALL=%~dp0.. call "%AS_INSTALL%\config\asenv.bat" call :chooseJava -set ACC_MODULEPATH="%AS_INSTALL%\lib\bootstrap" -set ACC_INSTALL_LIB="%AS_INSTALL%\lib\install\applications"; -set ACC_CLASSPATH="%AS_INSTALL%\lib\gf-client.jar:%AS_INSTALL%\lib\appclient\weld-se-shaded.jar:%AS_INSTALL%\admin-cli.jar:%AS_DERBY_INSTALL%\lib\*:%ACC_INSTALL_LIB%\__ds_jdbc_ra\jdbc-ra-ds.jar:%ACC_INSTALL_LIB%\__cp_jdbc_ra\jdbc-ra-cp.jar:%ACC_INSTALL_LIB%\__xa_jdbc_ra\jdbc-ra-xa.jar:%ACC_INSTALL_LIB%\__dm_jdbc_ra\jdbc-ra-dm.jar:%ACC_INSTALL_LIB%\jmsra\imqjmsra.jar:%AS_IMQ_LIB%\imq.jar:%AS_IMQ_LIB%\imqadmin.jar:%AS_IMQ_LIB%\imqutil.jar:%AS_IMQ_LIB%\fscontext.jar:%AS_INSTALL%\modules\*" - -%JAVA% %ASADMIN_JVM_OPTIONS% --module-path "%ACC_MODULEPATH%" --add-modules ALL-MODULE-PATH -cp "%ACC_CLASSPATH%" org.glassfish.appclient.client.CLIBootstrap %* +FOR /F "delims=" %i IN (%JAVA% --module-path "%AS_INSTALL%\lib\bootstrap" --add-modules ALL-MODULE-PATH -classpath "%AS_INSTALL%\lib\gf-client.jar" org.glassfish.appclient.client.acc.agent.CLIBootstrap %*) DO set CMD=%i +%CMD% %ARGS% diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.js b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.js index e4c2b8aeb17..eec2950ab6e 100644 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.js +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/appclient.js @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Contributors to the Eclipse Foundation * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -32,7 +33,7 @@ var builtinEndorsedDirSetting = quoteMultiStringIfNeeded( AS_INSTALL + "\\lib\\endorsed" + pathSep + - AS_INSTALL_MOD + + AS_INSTALL_MOD + "\\endorsed", pathSep); var mainClassIdentRequired = 1; @@ -123,13 +124,13 @@ function processArgs() { var accNonvaluedOptions = ["-textauth", "-noappinvoke", "-usage", "-help"]; //var re = new RegExp("\"([^\"]+)\"|[^\"\\s]+)","g"); var re = /"([^"]+)"|([^"\s]+)/g; - + // var tokens = inputArgs.split(" "); // var tokens = re.exec(inputArgs); var tokens = inputArgs.match(re); for (tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) { var token = tokens[tokenIndex]; - + var matched=null; matched = matchToWithType(token, jvmValuedOptions, "JVM"); if (matched == null) { @@ -152,7 +153,7 @@ function processArgs() { expecting = null; } } - + if (matched == null) { if (expecting != null) { recordArg(expectingArgType, expecting, token); diff --git a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient index 5af013ede1f..e707a7dea16 100755 --- a/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient +++ b/appserver/appclient/client/appclient-scripts/src/main/resources/glassfish/bin/package-appclient @@ -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. diff --git a/appserver/tests/appserv-tests/config/common.xml b/appserver/tests/appserv-tests/config/common.xml index 710bf2420e2..81fdc22e475 100644 --- a/appserver/tests/appserv-tests/config/common.xml +++ b/appserver/tests/appserv-tests/config/common.xml @@ -61,17 +61,26 @@ Variables used: - + + + + - - + + + + @@ -1399,8 +1408,14 @@ AS_ADMIN_MASTERPASSWORD=${master.password} - + + + + + @@ -1409,6 +1424,28 @@ AS_ADMIN_MASTERPASSWORD=${master.password} + + + + + + + + + + + + + + + + + + + + + + diff --git a/appserver/tests/appserv-tests/config/properties.xml b/appserver/tests/appserv-tests/config/properties.xml index 96a131e3c93..745af652514 100644 --- a/appserver/tests/appserv-tests/config/properties.xml +++ b/appserver/tests/appserv-tests/config/properties.xml @@ -105,6 +105,25 @@ AS_ADMIN_MASTERPASSWORD=${master.password} + + + + + + + + + + + + + + + + + @@ -136,7 +155,8 @@ AS_ADMIN_MASTERPASSWORD=${master.password} We use the test script (not appclient) if the user wants to launch app clients using Java Web Start. --> - @@ -162,7 +182,8 @@ AS_ADMIN_MASTERPASSWORD=${master.password} - diff --git a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.xml b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.xml index 69e2cd12d2a..176972fb941 100644 --- a/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.xml +++ b/appserver/tests/appserv-tests/devtests/cdi/javaee-integration/normal-bean-injection-ear/build.xml @@ -46,7 +46,7 @@ - + - - - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/build.xml b/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/build.xml index 7935d7069af..d81b6cb761d 100644 --- a/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/build.xml +++ b/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/build.xml @@ -44,10 +44,12 @@ + modulepath="${env.S1AS_HOME}/lib/bootstrap" + classpath="${mvn.lib.dir}/junit.jar:${s1astest.classpath}" + debug="on" includeantruntime="false" failonerror="true"> + + + @@ -79,6 +81,11 @@ + + + + + diff --git a/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/ut/ArchiveTest.java b/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/ut/ArchiveTest.java index a2138a8a7b2..fef3d80697c 100644 --- a/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/ut/ArchiveTest.java +++ b/appserver/tests/appserv-tests/devtests/connector/v3/administered-object-definition/ut/ArchiveTest.java @@ -67,7 +67,7 @@ private void doTestApplicationArchive() throws Exception{ ApplicationArchivist reader = (ApplicationArchivist) TestUtil.getByType(ApplicationArchivist.class); reader.setAnnotationProcessingRequested(true); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); reader.setClassLoader(classLoader); @@ -122,7 +122,7 @@ private void doTestWebArchive() throws Exception{ File archive = new File(archiveDir, appArchiveName); assertTrue("Do not fing the archive "+archive.getAbsolutePath(), archive.exists()); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); WebArchivist reader = (WebArchivist) TestUtil.getByType(WebArchivist.class); @@ -233,7 +233,7 @@ private void doTestEJBArchive() throws Exception{ File archive = new File(archiveDir, appArchiveName); assertTrue("Do not fing the archive "+archive.getAbsolutePath(), archive.exists()); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); EjbArchivist reader = (EjbArchivist) TestUtil.getByType(EjbArchivist.class); diff --git a/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/build.xml b/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/build.xml index 6175f553644..c15bfec6632 100644 --- a/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/build.xml +++ b/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/build.xml @@ -18,10 +18,10 @@ --> - - - - ]> + + + +]> @@ -32,60 +32,68 @@ - - + + - - + + - - + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -95,7 +103,7 @@ - + diff --git a/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/ut/ArchiveTest.java b/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/ut/ArchiveTest.java index 55171d11b2f..5ea30dfa897 100644 --- a/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/ut/ArchiveTest.java +++ b/appserver/tests/appserv-tests/devtests/connector/v3/connection-factory-definition/ut/ArchiveTest.java @@ -68,7 +68,7 @@ private void doTestApplicationArchive() throws Exception{ ApplicationArchivist reader = (ApplicationArchivist) TestUtil.getByType(ApplicationArchivist.class); reader.setAnnotationProcessingRequested(true); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); reader.setClassLoader(classLoader); @@ -127,7 +127,7 @@ private void doTestWebArchive() throws Exception{ File archive = new File(archiveDir, appArchiveName); assertTrue("Do not fing the archive "+archive.getAbsolutePath(), archive.exists()); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); WebArchivist reader = (WebArchivist) TestUtil.getByType(WebArchivist.class); @@ -236,7 +236,7 @@ private void doTestEJBArchive() throws Exception{ File archive = new File(archiveDir, appArchiveName); assertTrue("Do not fing the archive "+archive.getAbsolutePath(), archive.exists()); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); EjbArchivist reader = (EjbArchivist) TestUtil.getByType(EjbArchivist.class); diff --git a/appserver/tests/appserv-tests/devtests/connector/v3/ejb32-mdb/build.xml b/appserver/tests/appserv-tests/devtests/connector/v3/ejb32-mdb/build.xml index 3207e79bcc7..18d6653ecf5 100644 --- a/appserver/tests/appserv-tests/devtests/connector/v3/ejb32-mdb/build.xml +++ b/appserver/tests/appserv-tests/devtests/connector/v3/ejb32-mdb/build.xml @@ -83,14 +83,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/connector/v3/jms-destination-definition/ut/ArchiveTest.java b/appserver/tests/appserv-tests/devtests/connector/v3/jms-destination-definition/ut/ArchiveTest.java index a34da4f5521..fbca68cbe6a 100644 --- a/appserver/tests/appserv-tests/devtests/connector/v3/jms-destination-definition/ut/ArchiveTest.java +++ b/appserver/tests/appserv-tests/devtests/connector/v3/jms-destination-definition/ut/ArchiveTest.java @@ -70,7 +70,7 @@ private void doTestApplicationArchive() throws IOException, SAXParseException { ApplicationArchivist reader = (ApplicationArchivist) TestUtil.getByType(ApplicationArchivist.class); reader.setAnnotationProcessingRequested(true); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); reader.setClassLoader(classLoader); Application applicationDesc = reader.open(archive); @@ -115,7 +115,7 @@ private void doTestApplicationClientArchive() throws IOException, SAXParseExcept File archive = new File(archiveDir, appArchiveName); assertTrue("Do not find the archive: " + archive.getAbsolutePath(), archive.exists()); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); AppClientArchivist reader = (AppClientArchivist)TestUtil.getByType(AppClientArchivist.class); @@ -221,7 +221,7 @@ private void doTestWebArchive() throws IOException, SAXParseException { File archive = new File(archiveDir, appArchiveName); assertTrue("Do not find the archive: " + archive.getAbsolutePath(), archive.exists()); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); WebArchivist reader = (WebArchivist) TestUtil.getByType(WebArchivist.class); @@ -327,7 +327,7 @@ private void doTestEJBArchive() throws IOException, SAXParseException { File archive = new File(archiveDir, appArchiveName); assertTrue("Do not find the archive: " + archive.getAbsolutePath(), archive.exists()); - ASURLClassLoader classLoader = new ASURLClassLoader(this.getClass().getClassLoader()); + ASURLClassLoader classLoader = new ASURLClassLoader(appArchiveName, this.getClass().getClassLoader()); classLoader.addURL(archive.toURL()); EjbArchivist reader = (EjbArchivist) TestUtil.getByType(EjbArchivist.class); diff --git a/appserver/tests/appserv-tests/devtests/deployment/config/common.xml b/appserver/tests/appserv-tests/devtests/deployment/config/common.xml index b3cb31ba5b9..bfed63cc0f9 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/config/common.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/config/common.xml @@ -133,6 +133,7 @@ + diff --git a/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ear/build.xml b/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ear/build.xml index 0a57ca6a8e5..e5ba39cb66f 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ear/build.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ear/build.xml @@ -144,7 +144,6 @@ resultproperty="result"> - diff --git a/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejb/build.xml b/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejb/build.xml index 96d09a39122..a600ce80235 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejb/build.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejb/build.xml @@ -114,6 +114,11 @@ + + + + + diff --git a/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejbwithsuffix/build.xml b/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejbwithsuffix/build.xml index 6cd74e797a8..6b21522c596 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejbwithsuffix/build.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/directorydeploy/ejbwithsuffix/build.xml @@ -115,7 +115,11 @@ - + + + + + diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/override/build.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/override/build.xml index 5f53e7e6ee7..58b18f05bfa 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/override/build.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/dol/override/build.xml @@ -56,7 +56,7 @@ -${inst} + ${inst} - + + + + + diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/build.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/build.xml index 9af8e54a1f3..77556763caf 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/build.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/build.xml @@ -37,9 +37,6 @@ - - @@ -52,30 +49,11 @@ - - - - - - - - - - - - - - @@ -97,8 +75,6 @@ - - @@ -115,42 +91,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -${inst} + ${inst} - + + + + + @@ -222,28 +170,6 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/application.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/application.xml deleted file mode 100644 index 166e0cd0ea4..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/application.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - -Application description -ValidationApp - -employee-service-icon16x16.jpg - - -validation.rar - - -emp app role -employee_app - - -admin app role -administrator_app - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/weblogic-application.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/weblogic-application.xml deleted file mode 100644 index 1f3247be50e..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/META-INF/weblogic-application.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - param1 - val1 - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/ra.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/ra.xml deleted file mode 100644 index 83995a076ee..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/ra.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - SimpleVersionableRA - deploymentTestCo - StartupClassRA - 0.1 - - - connector.ResourceAdapterImpl - - - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/weblogic-ra.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/weblogic-ra.xml deleted file mode 100644 index 4f2edd1111d..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar/wlsRar/META-INF/weblogic-ra.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - ResourceAdapter - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/application.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/application.xml deleted file mode 100644 index 166e0cd0ea4..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/application.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - -Application description -ValidationApp - -employee-service-icon16x16.jpg - - -validation.rar - - -emp app role -employee_app - - -admin app role -administrator_app - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/weblogic-application.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/weblogic-application.xml deleted file mode 100644 index 38d63832b20..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar2/META-INF/weblogic-application.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - param1 - val1 - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/application.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/application.xml deleted file mode 100644 index 166e0cd0ea4..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/application.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - -Application description -ValidationApp - -employee-service-icon16x16.jpg - - -validation.rar - - -emp app role -employee_app - - -admin app role -administrator_app - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/weblogic-application.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/weblogic-application.xml deleted file mode 100644 index e44c3f1140d..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsEar3/META-INF/weblogic-application.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - true - - - dictionary - - - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/ra.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/ra.xml deleted file mode 100644 index 18280631ce8..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/ra.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - SimpleVersionableRA - deploymentTestCo - StartupClassRA - 0.1 - - - connector.ResourceAdapterImpl - - - - - diff --git a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/weblogic-ra.xml b/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/weblogic-ra.xml deleted file mode 100644 index 4f2edd1111d..00000000000 --- a/appserver/tests/appserv-tests/devtests/deployment/dol/validation/wlsRar/META-INF/weblogic-ra.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - ResourceAdapter - diff --git a/appserver/tests/appserv-tests/devtests/deployment/versioning/versioning-common.xml b/appserver/tests/appserv-tests/devtests/deployment/versioning/versioning-common.xml index 7488e71c539..1c2b8daac52 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/versioning/versioning-common.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/versioning/versioning-common.xml @@ -35,8 +35,8 @@ @param ${force} (optional) --> - - + + - - - + + + @@ -64,9 +64,9 @@ @param ${versionExpression} (optional) --> - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + @@ -125,7 +125,7 @@ - + - + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - + + + + + - - - + + + + + - - - + + + + + - - - + + - - - + + + + + - - - + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + + - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - + + + - - - + + + + + - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - - - + + + + - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - + + + + + + + + - + - + - + - - + + - - + + - + - + - + - + - + @@ -500,7 +530,7 @@ @param ${xmlVersionIdentifier} (optional) --> - + @@ -522,36 +552,38 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - + - + - - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - @@ -640,9 +678,9 @@ - - + - - - - - - - - - - - - - - - - - - + + - - - - + + + + - - - - + + + + - - - + + - - - + + - - - - + + + + + + + + - - - - - - - + + + + + + + - + @@ -777,31 +822,31 @@ - + - - - + + + - + - + - + - + - + - - - + + + diff --git a/appserver/tests/appserv-tests/devtests/deployment/webservices/annotations-common.xml b/appserver/tests/appserv-tests/devtests/deployment/webservices/annotations-common.xml index 71c9efd0b09..18e86707e8e 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/webservices/annotations-common.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/webservices/annotations-common.xml @@ -70,7 +70,7 @@ diff --git a/appserver/tests/appserv-tests/devtests/deployment/webservices/noinf/build.xml b/appserver/tests/appserv-tests/devtests/deployment/webservices/noinf/build.xml index 1c5021e4c76..e4b9a7a85af 100644 --- a/appserver/tests/appserv-tests/devtests/deployment/webservices/noinf/build.xml +++ b/appserver/tests/appserv-tests/devtests/deployment/webservices/noinf/build.xml @@ -18,7 +18,7 @@ --> - + ]> diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/adapted/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/adapted/build.xml index e257621f29b..aecba6bd67f 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/adapted/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/adapted/build.xml @@ -32,7 +32,7 @@ - + @@ -63,13 +63,10 @@ - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/core/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/core/build.xml index ccadb697582..3bc0964e91b 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/core/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/core/build.xml @@ -32,7 +32,7 @@ - + @@ -63,13 +63,10 @@ - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/exceptions/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/exceptions/build.xml index c8920160ce3..858fc9b8470 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/exceptions/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb30/clientview/exceptions/build.xml @@ -63,13 +63,10 @@ - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session/build.xml index 0bae76fae6c..d2e57df0e3d 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session/build.xml @@ -31,73 +31,67 @@ - - - - - - - - + + + + + + + - - - - - - - - - - - + + + + + + + + + + - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session5/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session5/build.xml index 20be0d6aca8..35c6d758324 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session5/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb30/hello/session5/build.xml @@ -66,6 +66,7 @@ + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb30/persistence/tx_propagation/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb30/persistence/tx_propagation/build.xml index f674fc1d055..675f1158fa6 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb30/persistence/tx_propagation/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb30/persistence/tx_propagation/build.xml @@ -120,13 +120,10 @@ - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/localandremote/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/localandremote/build.xml index 1d571d1b77c..393ed43546f 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/localandremote/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/localandremote/build.xml @@ -61,15 +61,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/remote/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/remote/build.xml index 4e78e11e25b..c09503c6084 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/remote/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/remote/build.xml @@ -61,15 +61,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/threadpoolconfig/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/threadpoolconfig/build.xml index f05fe8c448b..9c3cd430d3c 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/threadpoolconfig/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/asynchronous/threadpoolconfig/build.xml @@ -64,14 +64,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/generics/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/generics/build.xml index 8cce1ef2b57..48c21f863b2 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/generics/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/generics/build.xml @@ -60,15 +60,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/javamodule/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/javamodule/build.xml index 9e7c657373b..aa502258367 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/javamodule/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/javamodule/build.xml @@ -60,15 +60,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/jaxrs/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/jaxrs/build.xml index c83a5586f35..ea1d027622b 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/jaxrs/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/jaxrs/build.xml @@ -2,7 +2,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/managedbean/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/managedbean/build.xml index d511bfb09cc..8b3701424b3 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/managedbean/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/managedbean/build.xml @@ -60,15 +60,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/sinitcallejb/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/sinitcallejb/build.xml index bbd697beae5..a4f99ef2f67 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/sinitcallejb/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/ejblite/sinitcallejb/build.xml @@ -60,15 +60,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/disable_nonportable_jndi/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/disable_nonportable_jndi/build.xml index 6f1651d3094..83797da4037 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/disable_nonportable_jndi/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/disable_nonportable_jndi/build.xml @@ -64,14 +64,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/ear/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/ear/build.xml index 1c13adebe55..67d6a03008d 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/ear/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/ear/build.xml @@ -70,15 +70,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/jcdifull/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/jcdifull/build.xml index 6a4ce1153f4..ed211807681 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/jcdifull/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/jcdifull/build.xml @@ -32,12 +32,18 @@ - + - - + + + + + @@ -49,9 +55,9 @@ - - - + + + @@ -69,15 +75,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/passact/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/passact/build.xml index 830df673186..117d9e5daf7 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/passact/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/passact/build.xml @@ -64,14 +64,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote1/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote1/build.xml index bc32871bbbe..9c709454bb5 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote1/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote1/build.xml @@ -64,14 +64,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote2/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote2/build.xml index ac3db23b0c3..a1f9e79ab86 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote2/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/remote2/build.xml @@ -61,15 +61,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/schema/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/schema/build.xml index d4b406dc5d8..94e8b682107 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/schema/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/schema/build.xml @@ -61,14 +61,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/sfsbscnc/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/sfsbscnc/build.xml index d19618fb6aa..64ed9cef075 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/sfsbscnc/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/sfsbscnc/build.xml @@ -61,15 +61,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/webandejb/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/webandejb/build.xml index c4c777bffce..213aaeeff0a 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/webandejb/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/full/webandejb/build.xml @@ -60,15 +60,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/security/simple/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/security/simple/build.xml index 8c27fee2dfc..55f4e6abf17 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/security/simple/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/security/simple/build.xml @@ -40,8 +40,7 @@ - - + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/cache/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/cache/build.xml index 4843f0be76f..df657149382 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/cache/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/cache/build.xml @@ -61,14 +61,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/hello/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/hello/build.xml index ee9fb7ee6cb..639f5fa5a9f 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/hello/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/hello/build.xml @@ -63,14 +63,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/multi-module/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/multi-module/build.xml index f43c1ad8919..7b88f9ab28f 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/multi-module/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/multi-module/build.xml @@ -120,15 +120,13 @@ - - - - - - + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/threemodules/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/threemodules/build.xml index 9a42369fc85..b127b47f76b 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/threemodules/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/singleton/threemodules/build.xml @@ -120,15 +120,13 @@ - - - - - - + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/mdb/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/mdb/build.xml index 1cb6ec25fe6..bd357bd5f1d 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/mdb/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/mdb/build.xml @@ -74,15 +74,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/methodintf/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/methodintf/build.xml index 59c1e88a1b7..c372cfc679a 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/methodintf/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb31/timer31/methodintf/build.xml @@ -57,15 +57,10 @@ - - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml index 5c1de87e73c..35320707ef4 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/embedded/autoclose/build.xml @@ -63,20 +63,11 @@ - - - - - - - - - + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/annotation/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/annotation/build.xml index b27f71b6817..6cd67847cfd 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/annotation/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/annotation/build.xml @@ -57,14 +57,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/descriptor/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/descriptor/build.xml index 990413f00e2..9d5f32dbb3f 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/descriptor/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/aroundconstruct/descriptor/build.xml @@ -58,14 +58,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/annotation/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/annotation/build.xml index e505cb6f98d..c0bbc289a08 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/annotation/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/annotation/build.xml @@ -57,14 +57,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/descriptor/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/descriptor/build.xml index f8c413b3580..3bbdf208fab 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/descriptor/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/constructor-level/descriptor/build.xml @@ -58,14 +58,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/annotation/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/annotation/build.xml index d5a4011366c..9171bf6cd76 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/annotation/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/annotation/build.xml @@ -57,14 +57,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/descriptor/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/descriptor/build.xml index 3ae0f442dd6..3d4a9ced23d 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/descriptor/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/get_method_lc/descriptor/build.xml @@ -58,14 +58,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/interceptors-inheritance/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/interceptors-inheritance/build.xml index 393200f6961..67b025c481f 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/interceptors-inheritance/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/interceptors-inheritance/build.xml @@ -57,14 +57,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/annotation/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/annotation/build.xml index a5e63b73d56..e47dea9910c 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/annotation/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/annotation/build.xml @@ -57,14 +57,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/descriptor/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/descriptor/build.xml index 23f6a43bcaf..158bbb7ee4e 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/descriptor/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/interceptors/lc-method-constructor-level/descriptor/build.xml @@ -58,14 +58,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/intfces/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/intfces/build.xml index 9d158671427..d1cdfacb38d 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/intfces/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/intfces/build.xml @@ -32,7 +32,7 @@ - + @@ -49,27 +49,24 @@ - + - + - + - + @@ -80,36 +77,30 @@ - + - + - + - + - - - - - - - + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/mdb/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/mdb/build.xml index 3207e79bcc7..18d6653ecf5 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/mdb/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/mdb/build.xml @@ -83,14 +83,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/methodintf/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/methodintf/build.xml index 5a9ce770a20..24f5c347459 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/methodintf/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/methodintf/build.xml @@ -57,14 +57,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/basic/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/basic/build.xml index 6e7cb99c935..7c331af1fee 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/basic/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/basic/build.xml @@ -61,14 +61,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/descriptor/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/descriptor/build.xml index b7441aefc02..e498455a73e 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/descriptor/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/descriptor/build.xml @@ -61,14 +61,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/lifecycle_cb_txattr/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/lifecycle_cb_txattr/build.xml index 5276631d350..a9a0b4ed58f 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/lifecycle_cb_txattr/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/sfsb/lifecycle_cb_txattr/build.xml @@ -61,14 +61,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/ejb32/timer/opallowed/build.xml b/appserver/tests/appserv-tests/devtests/ejb/ejb32/timer/opallowed/build.xml index 5fd83c67a72..86c8c81616d 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/ejb32/timer/opallowed/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/ejb32/timer/opallowed/build.xml @@ -31,99 +31,96 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/ejb/stubs/standaloneclient/build.xml b/appserver/tests/appserv-tests/devtests/ejb/stubs/standaloneclient/build.xml index cc024134b01..0fc9918b262 100644 --- a/appserver/tests/appserv-tests/devtests/ejb/stubs/standaloneclient/build.xml +++ b/appserver/tests/appserv-tests/devtests/ejb/stubs/standaloneclient/build.xml @@ -32,42 +32,39 @@ - + - - - + + - - - - - - + + + + + - - - + @@ -94,17 +91,12 @@ - - - - - - - + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/jdbc/flushconnectionpool/build.xml b/appserver/tests/appserv-tests/devtests/jdbc/flushconnectionpool/build.xml index f63f3cb5d05..97acbc8cb14 100755 --- a/appserver/tests/appserv-tests/devtests/jdbc/flushconnectionpool/build.xml +++ b/appserver/tests/appserv-tests/devtests/jdbc/flushconnectionpool/build.xml @@ -49,10 +49,9 @@ - + + value="**/SimpleBMP.class, **/SimpleBMPHome.class,**/*Client*.class"/> @@ -60,7 +59,6 @@ - @@ -72,8 +70,7 @@ - + @@ -82,7 +79,6 @@ - @@ -92,29 +88,22 @@ - - - - - - - - - - + + + ]> @@ -37,50 +37,39 @@ - - - + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - - - - + + + + + - - - + + + diff --git a/appserver/tests/appserv-tests/devtests/naming/injection/build.xml b/appserver/tests/appserv-tests/devtests/naming/injection/build.xml index 625a71baf4b..e6d7642e2fe 100644 --- a/appserver/tests/appserv-tests/devtests/naming/injection/build.xml +++ b/appserver/tests/appserv-tests/devtests/naming/injection/build.xml @@ -73,14 +73,10 @@ - - - - - + + + + diff --git a/appserver/tests/appserv-tests/devtests/security/ejb-mutual-ssl/build.xml b/appserver/tests/appserv-tests/devtests/security/ejb-mutual-ssl/build.xml index 6ca67c20743..ed786c60143 100644 --- a/appserver/tests/appserv-tests/devtests/security/ejb-mutual-ssl/build.xml +++ b/appserver/tests/appserv-tests/devtests/security/ejb-mutual-ssl/build.xml @@ -39,7 +39,7 @@ - + @@ -70,43 +70,46 @@ - + - - - - - + + + + + - + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -114,6 +117,6 @@ - + diff --git a/appserver/tests/appserv-tests/devtests/security/ejb-oneway-ssl/build.xml b/appserver/tests/appserv-tests/devtests/security/ejb-oneway-ssl/build.xml index 561375d6fac..98e180ca32a 100644 --- a/appserver/tests/appserv-tests/devtests/security/ejb-oneway-ssl/build.xml +++ b/appserver/tests/appserv-tests/devtests/security/ejb-oneway-ssl/build.xml @@ -37,7 +37,7 @@ - + @@ -58,22 +58,22 @@ - - + + - - - - - + + + + + - + @@ -82,17 +82,21 @@ - - - - - - - - - + + + + + + + + + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/security/simple-perf/build.xml b/appserver/tests/appserv-tests/devtests/security/simple-perf/build.xml index 3e0613676f4..148d4984527 100644 --- a/appserver/tests/appserv-tests/devtests/security/simple-perf/build.xml +++ b/appserver/tests/appserv-tests/devtests/security/simple-perf/build.xml @@ -35,7 +35,7 @@ - + @@ -56,28 +56,28 @@ - + - - - - - - - - - - - + + + + + + + + + + + - + @@ -86,18 +86,22 @@ - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/appserver/tests/appserv-tests/devtests/security/standalone/loginctxdriver/build.xml b/appserver/tests/appserv-tests/devtests/security/standalone/loginctxdriver/build.xml index 6e9533c0898..93f3ebd87ca 100644 --- a/appserver/tests/appserv-tests/devtests/security/standalone/loginctxdriver/build.xml +++ b/appserver/tests/appserv-tests/devtests/security/standalone/loginctxdriver/build.xml @@ -45,7 +45,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -82,7 +82,7 @@ - + @@ -100,18 +100,21 @@ - - - - - - - - - - + + + + + + + + + + + + + - - diff --git a/appserver/tests/appserv-tests/devtests/transaction/ee/cli/build.xml b/appserver/tests/appserv-tests/devtests/transaction/ee/cli/build.xml index a33174188a7..5e496a7cb32 100644 --- a/appserver/tests/appserv-tests/devtests/transaction/ee/cli/build.xml +++ b/appserver/tests/appserv-tests/devtests/transaction/ee/cli/build.xml @@ -228,7 +228,7 @@ @@ -290,7 +290,7 @@ diff --git a/appserver/tests/community/gfproject/build-impl.xml b/appserver/tests/community/gfproject/build-impl.xml index 8daa55edef3..af3a0e41d0a 100644 --- a/appserver/tests/community/gfproject/build-impl.xml +++ b/appserver/tests/community/gfproject/build-impl.xml @@ -52,8 +52,8 @@ - - + + diff --git a/appserver/tests/quicklook/amx/pom.xml b/appserver/tests/quicklook/amx/pom.xml index b05c3b5e615..10854aef91f 100644 --- a/appserver/tests/quicklook/amx/pom.xml +++ b/appserver/tests/quicklook/amx/pom.xml @@ -17,34 +17,34 @@ --> - + 4.0.0 org.glassfish.quicklook admin Admin Quicklook Tests jar - org.glassfish.quicklook - quicklook + org.glassfish.quicklook + quicklook 7.0.21-SNAPSHOT - ../pom.xml Runs the tests on admin/asadmin code - src - - - maven-compiler-plugin - - iso-8859-1 - 1.5 - 1.5 - - - + src + + + maven-compiler-plugin + + iso-8859-1 + 11 + + + - + org.testng testng diff --git a/appserver/tests/quicklook/build.xml b/appserver/tests/quicklook/build.xml index 516fe978e00..0684c07c850 100644 --- a/appserver/tests/quicklook/build.xml +++ b/appserver/tests/quicklook/build.xml @@ -44,14 +44,16 @@ - - - - - + + + + + + + - + @@ -451,7 +453,7 @@ - + @@ -491,10 +493,10 @@ - + - + @@ -510,7 +512,7 @@ - + diff --git a/appserver/tests/quicklook/ejb/remoteview/pom.xml b/appserver/tests/quicklook/ejb/remoteview/pom.xml index 379831bcf89..674c32d4d60 100644 --- a/appserver/tests/quicklook/ejb/remoteview/pom.xml +++ b/appserver/tests/quicklook/ejb/remoteview/pom.xml @@ -60,7 +60,7 @@ org.testng testng - 6.11 + 7.10.2 diff --git a/appserver/tests/quicklook/ejb/remoteview/src/test/RemoteViewTestNG.java b/appserver/tests/quicklook/ejb/remoteview/src/test/RemoteViewTestNG.java index 13d0344ddfe..e217766cdc1 100644 --- a/appserver/tests/quicklook/ejb/remoteview/src/test/RemoteViewTestNG.java +++ b/appserver/tests/quicklook/ejb/remoteview/src/test/RemoteViewTestNG.java @@ -46,9 +46,8 @@ public void helloRemote() throws Exception{ test_result = true; } catch(ExecutionException e) { test_result = false; - System.out.println("Got async ExecutionException. Cause is " + - e.getCause().getMessage()); - e.getCause().printStackTrace(); + System.out.println("Got async ExecutionException."); + e.printStackTrace(); } Assert.assertEquals(test_result, true,"Unexpected Results"); } @@ -66,7 +65,8 @@ public void portableGlobal() throws Exception{ test_result = true; } catch(Exception e) { test_result = false; - System.out.println("Exception from portableGlobal:"+e); + System.err.println("Exception from portableGlobal"); + e.printStackTrace(); } Assert.assertEquals(test_result, true,"Unexpected Results"); } @@ -84,17 +84,18 @@ public void nonPortableGlobal() throws Exception{ test_result = true; } catch(Exception e) { test_result = false; - System.out.println("Exception from portableGlobal:"+e); + System.err.println("Exception from portableGlobal:"); + e.printStackTrace(); } Assert.assertEquals(test_result, true,"Unexpected Results"); } private static void callHome(HelloHome home) throws Exception { HelloRemote hr = home.create(); - //System.out.println("2.x HelloRemote.hello() says " + hr.hello()); + System.out.println("2.x HelloRemote.hello() says " + hr.hello()); } private static void callBusHome(Hello h) { - String hret = h.hello(); - //System.out.println("Hello.hello() says " + h.hello()); + String hret = h.hello(); + System.out.println("Hello.hello() says " + h.hello()); } } diff --git a/appserver/tests/quicklook/gfproject/build-impl.xml b/appserver/tests/quicklook/gfproject/build-impl.xml index 8d994e0a4ec..48b3b3b3172 100644 --- a/appserver/tests/quicklook/gfproject/build-impl.xml +++ b/appserver/tests/quicklook/gfproject/build-impl.xml @@ -45,11 +45,22 @@ - - - - - + + + + + + + + + + + + + + + + @@ -61,7 +72,7 @@ - + @@ -72,9 +83,7 @@ - - - + @@ -104,14 +113,14 @@ - + - + @@ -154,7 +163,7 @@ - + @@ -168,7 +177,7 @@ - + @@ -204,7 +213,7 @@ - + @@ -215,7 +224,7 @@ - + @@ -243,7 +252,7 @@ - + @@ -357,7 +366,9 @@ - + @@ -368,7 +379,9 @@ - + diff --git a/appserver/tests/quicklook/pom.xml b/appserver/tests/quicklook/pom.xml index ca0bcccb7cd..4e8de5fb4cc 100644 --- a/appserver/tests/quicklook/pom.xml +++ b/appserver/tests/quicklook/pom.xml @@ -1,7 +1,7 @@ - + 4.0.0 org.eclipse.ee4j project 1.0.9 - + org.glassfish.quicklook quicklook 7.0.21-SNAPSHOT - jar + pom Glassfish Quicklook Bundle This pom describes how to run QuickLook tests on the Glassfish Bundle @@ -40,45 +42,47 @@ maven-antrun-plugin - 3.0.0 + 3.1.0 default-test test - - - + + + + + + - - - - + - - + + - + - + - + @@ -86,15 +90,16 @@ - + - + - + @@ -102,40 +107,40 @@ - + - + - + - + - + - + - + @@ -199,12 +204,11 @@ - - - com.beust - jcommander - 1.72 - + + com.beust + jcommander + 1.72 + @@ -217,7 +221,7 @@ true - + true @@ -227,7 +231,7 @@ true - + test_wd @@ -253,7 +257,7 @@ true - + test_em @@ -267,7 +271,7 @@ true - + dev_debug diff --git a/appserver/tests/quicklook/testng/testng_cluster.xml b/appserver/tests/quicklook/testng/testng_cluster.xml index 217eea97ae8..b405faa8b79 100644 --- a/appserver/tests/quicklook/testng/testng_cluster.xml +++ b/appserver/tests/quicklook/testng/testng_cluster.xml @@ -18,7 +18,7 @@ - + diff --git a/appserver/tests/quicklook/testng/testng_debug.xml b/appserver/tests/quicklook/testng/testng_debug.xml index 68a900f55c1..55b82433d93 100644 --- a/appserver/tests/quicklook/testng/testng_debug.xml +++ b/appserver/tests/quicklook/testng/testng_debug.xml @@ -18,7 +18,7 @@ - + diff --git a/appserver/tests/quicklook/testng/testng_em.xml b/appserver/tests/quicklook/testng/testng_em.xml index 722ad4fa061..94645548ba8 100644 --- a/appserver/tests/quicklook/testng/testng_em.xml +++ b/appserver/tests/quicklook/testng/testng_em.xml @@ -18,7 +18,7 @@ - + diff --git a/appserver/tests/quicklook/testng/testng_full_profile.xml b/appserver/tests/quicklook/testng/testng_full_profile.xml index 9f690d69146..398b5a4d0ed 100644 --- a/appserver/tests/quicklook/testng/testng_full_profile.xml +++ b/appserver/tests/quicklook/testng/testng_full_profile.xml @@ -19,7 +19,7 @@ - + @@ -49,7 +49,7 @@ - - + @@ -53,7 +53,7 @@ -