Skip to content

New SystemProperties logging global changes #25569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2021, 2025 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
Expand Down Expand Up @@ -29,6 +29,7 @@

import static com.sun.enterprise.util.Utility.isAllNull;
import static com.sun.enterprise.util.Utility.isEmpty;
import static org.glassfish.main.jdke.props.SystemProperties.setProperty;

/**
* This class uses Java reflection to invoke Derby NetworkServerControl class.
Expand Down Expand Up @@ -125,10 +126,10 @@ public DerbyControl(final String derbyCommand, final String derbyHost, final Str

// Do not set derby.system.home if derbyHome is empty
if (!isEmpty(derbyHome)) {
System.setProperty("derby.system.home", derbyHome);
setProperty("derby.system.home", derbyHome, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all usages updated, could we have setProperty(String, String), that would default the 3rd parameter to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to force decision if it should or should not overwrite existing value - which is quite important. Correctly no such events should ever happen, but it is not always true.

}
// Set the property to not overwrite log file
System.setProperty("derby.infolog.append", "true");
setProperty("derby.infolog.append", "true", true);
}

// constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.xml.sax.SAXException;

import static org.glassfish.appclient.client.acc.AppClientContainer.ClientMainClassSetting.getClientMainClass;
import static org.glassfish.main.jdke.props.SystemProperties.setProperty;

/**
* Embeddable Glassfish app client container (ACC).
Expand Down Expand Up @@ -303,7 +304,7 @@ private void completePreparation(final Instrumentation inst) throws Exception, U
prepareURLStreamHandling();

// This is required for us to enable interrupt jaxws service creation calls
System.setProperty("jakarta.xml.ws.spi.Provider", "com.sun.xml.ws.spi.ProviderImpl");
setProperty("jakarta.xml.ws.spi.Provider", "com.sun.xml.ws.spi.ProviderImpl", true);
// InjectionManager's injectClass will be called from getMainMethod

// Load any managed beans
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -47,6 +47,7 @@
import static org.glassfish.internal.api.ORBLocator.OMG_ORB_INIT_HOST_PROPERTY;
import static org.glassfish.internal.api.ORBLocator.OMG_ORB_INIT_PORT_PROPERTY;
import static org.glassfish.internal.api.ORBLocator.ORB_SSL_CLIENT_REQUIRED;
import static org.glassfish.main.jdke.props.SystemProperties.setProperty;

/**
* Implements a builder for accumulating configuration information for the app client container and then starting the
Expand Down Expand Up @@ -239,7 +240,7 @@ private void defineIfNotDefined(final String propName, final String newPropValue
"Value for {0} expected but was not configured or assigned", new Object[] { propName }));

}
System.setProperty(propName, newPropValue);
setProperty(propName, newPropValue, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static java.util.Arrays.asList;
import static org.glassfish.appclient.client.acc.Util.writeTextToTempFile;
import static org.glassfish.embeddable.GlassFishVariable.INSTALL_ROOT;
import static org.glassfish.main.jdke.props.SystemProperties.setProperty;

/**
*
Expand Down Expand Up @@ -101,7 +102,7 @@ private void initLoginConfig() throws IOException {

// The Java com.sun.security.auth.login.ConfigFile class expects the
// java.security.auth.login.config property value to be a URL
System.setProperty("java.security.auth.login.config", configFile.toURI().toURL().toExternalForm());
setProperty("java.security.auth.login.config", configFile.toURI().toURL().toExternalForm(), true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import org.glassfish.appclient.client.acc.AppClientContainer;
import org.glassfish.appclient.client.acc.JWSACCClassLoader;

import static org.glassfish.main.jdke.props.SystemProperties.setProperty;

/**
* Alternate main class for ACC, used when launched by Java Web Start.
* <p>
Expand Down Expand Up @@ -180,7 +182,7 @@ public void run() {
*Set a property that the ACC will retrieve during a JWS launch
*to locate the app client jar file.
*/
System.setProperty("com.sun.aas.downloaded.appclient.jar", downloadedAppclientJarFile.getAbsolutePath());
setProperty("com.sun.aas.downloaded.appclient.jar", downloadedAppclientJarFile.getAbsolutePath(), true);

Thread.currentThread().setContextClassLoader(loader);
System.err.println("XXXX: JWSACCMain.run set CL to thread: " + loader);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 2025 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
Expand Down Expand Up @@ -56,6 +56,7 @@
import org.glassfish.hk2.api.ServiceLocator;

import static org.glassfish.embeddable.GlassFishVariable.INSTANCE_ROOT;
import static org.glassfish.main.jdke.props.SystemProperties.setProperty;

/**
* GlassFish implementation of the EJBContainerProvider.
Expand Down Expand Up @@ -115,7 +116,7 @@ public EJBContainer createEJBContainer(Map<?, ?> properties) throws EJBException
boolean ok = false;
Locations l = getLocations(properties);
try {
System.setProperty(IS_EJB_CONTAINER, "true");
setProperty(IS_EJB_CONTAINER, "true", true);
createContainer(properties, l);
Set<DeploymentElement> modules = addModules(properties, l);
if (!DeploymentElement.hasEJBModule(modules)) {
Expand All @@ -139,7 +140,7 @@ public EJBContainer createEJBContainer(Map<?, ?> properties) throws EJBException
_logger.info("[EJBContainerProviderImpl] Error cleaning up..." + t1);
}
container = null;
System.clearProperty(IS_EJB_CONTAINER);
setProperty(IS_EJB_CONTAINER, null, true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2025 Contributors to the Eclipse Foundation
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -37,6 +37,7 @@
import org.glassfish.embeddable.GlassFishRuntime;
import org.glassfish.embeddable.spi.RuntimeBuilder;
import org.glassfish.main.boot.osgi.OSGiFrameworkLauncher;
import org.glassfish.main.jdke.props.SystemProperties;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
Expand Down Expand Up @@ -145,7 +146,8 @@ public GlassFishRuntime build(BootstrapProperties bsOptions, ClassLoader classlo
bsOptions.setProperty(OSGI_PLATFORM.getPropertyName(), OsgiPlatform.Felix.name());
}

System.setProperty(UBER_JAR_URI, jar.toString()); // embedded-osgi-main module will need this to extract the modules.
// embedded-osgi-main module will need this to extract the modules.
SystemProperties.setProperty(UBER_JAR_URI, jar.toString(), true);

String osgiMainModule = "jar:" + jar.toString() + "!/uber-osgi-main.jar";
bsOptions.setProperty("glassfish.auto.start", osgiMainModule);
Expand All @@ -160,10 +162,9 @@ public GlassFishRuntime build(BootstrapProperties bsOptions, ClassLoader classlo
}

bsOptions.setProperty(AUTO_START_BUNDLES_PROP, autoStartBundleLocation);
System.setProperty(AUTO_START_BUNDLES_PROP, autoStartBundleLocation);

System.setProperty(INSTALL_ROOT.getSystemPropertyName(), installRoot);
System.setProperty(INSTANCE_ROOT.getSystemPropertyName(), instanceRoot);
SystemProperties.setProperty(AUTO_START_BUNDLES_PROP, autoStartBundleLocation, true);
SystemProperties.setProperty(INSTALL_ROOT.getSystemPropertyName(), installRoot, true);
SystemProperties.setProperty(INSTANCE_ROOT.getSystemPropertyName(), instanceRoot, true);

String version = loadVersion();
bsOptions.setProperty(FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.glassfish.simpleglassfishapi; version=" + version);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
* Copyright (c) 2023, 2025 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
Expand Down Expand Up @@ -36,7 +36,6 @@
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.api.Param;
Expand All @@ -59,6 +58,7 @@
import org.jvnet.hk2.config.types.Property;
import org.jvnet.hk2.config.types.PropertyBag;

import static java.util.logging.Level.SEVERE;
import static org.glassfish.config.support.Constants.NAME_REGEX;

/**
Expand Down Expand Up @@ -297,14 +297,8 @@ private boolean setInternalProperty(String propertyName) {
transaction.commit();
} catch (Exception ex) {
transaction.rollback();
Logger logger = LogDomains.getLogger(LbConfig.class, LogDomains.ADMIN_LOGGER);
LocalStringManagerImpl localStrings = new LocalStringManagerImpl(LbConfig.class);
String msg = localStrings.getLocalString(
"UnableToSetPropertyInLbconfig",
"Unable to set property {0} in lbconfig with name {1}",
propertyName, getName());
logger.log(Level.SEVERE, msg);
logger.log(Level.FINE, "Exception when trying to set property " + propertyName + " in lbconfig " + getName(), ex);
Logger logger = LogDomains.getLogger(LbConfig.class, LogDomains.ADMIN_LOGGER, false);
logger.log(SEVERE, "Unable to set property " + propertyName + " in lbconfig with name " + getName(), ex);
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#

UnableToSetPropertyInLbconfig=Unable to set property {0} in lbconfig with name {1}
LbConfigIsInUse=LB configuration [{0}] is in use by another load balancer.
DeleteLbConfigFailed=Unable to remove lb config {0}.
RequiredTargetOrConfig=CLI251: Either option --target or operand config_name is required for this command.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2025 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
Expand Down Expand Up @@ -30,60 +31,47 @@
import org.glassfish.grizzly.config.dom.NetworkListener;
import org.glassfish.hk2.api.PostConstruct;
import org.glassfish.hk2.runlevel.RunLevel;
import org.glassfish.main.jdke.props.SystemProperties;
import org.glassfish.orb.admin.config.IiopListener;
import org.glassfish.orb.admin.config.IiopService;
import org.jvnet.hk2.annotations.Service;

/**
*/
@Service
@RunLevel(StartupRunLevel.VAL)
public class ORBConnectorStartup implements PostConstruct {

// RMI-IIOP delegate constants
private static final String ORB_UTIL_CLASS_PROPERTY =
"javax.rmi.CORBA.UtilClass";
private static final String RMIIIOP_STUB_DELEGATE_CLASS_PROPERTY =
"javax.rmi.CORBA.StubClass";
private static final String RMIIIOP_PRO_DELEGATE_CLASS_PROPERTY =
"javax.rmi.CORBA.PortableRemoteObjectClass";

// ORB constants: OMG standard
private static final String OMG_ORB_CLASS_PROPERTY =
"org.omg.CORBA.ORBClass";
private static final String OMG_ORB_SINGLETON_CLASS_PROPERTY =
"org.omg.CORBA.ORBSingletonClass";

private static final String ORB_CLASS =
"com.sun.corba.ee.impl.orb.ORBImpl";
private static final String ORB_SINGLETON_CLASS =
"com.sun.corba.ee.impl.orb.ORBSingleton";

private static final String ORB_SE_CLASS =
"com.sun.corba.se.impl.orb.ORBImpl";
private static final String ORB_SE_SINGLETON_CLASS =
"com.sun.corba.se.impl.orb.ORBSingleton";

private static final String RMI_UTIL_CLASS =
"com.sun.corba.ee.impl.javax.rmi.CORBA.Util";
private static final String RMI_STUB_CLASS =
"com.sun.corba.ee.impl.javax.rmi.CORBA.StubDelegateImpl";
private static final String RMI_PRO_CLASS =
"com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject";

@Inject @Named(ServerEnvironment.DEFAULT_INSTANCE_NAME)
private static final String ORB_UTIL_CLASS_PROPERTY = "javax.rmi.CORBA.UtilClass";
private static final String RMIIIOP_STUB_DELEGATE_CLASS_PROPERTY = "javax.rmi.CORBA.StubClass";
private static final String RMIIIOP_PRO_DELEGATE_CLASS_PROPERTY = "javax.rmi.CORBA.PortableRemoteObjectClass";

// ORB constants: OMG standard
private static final String OMG_ORB_CLASS_PROPERTY = "org.omg.CORBA.ORBClass";
private static final String OMG_ORB_SINGLETON_CLASS_PROPERTY = "org.omg.CORBA.ORBSingletonClass";

private static final String ORB_CLASS = "com.sun.corba.ee.impl.orb.ORBImpl";
private static final String ORB_SINGLETON_CLASS = "com.sun.corba.ee.impl.orb.ORBSingleton";

private static final String ORB_SE_CLASS = "com.sun.corba.se.impl.orb.ORBImpl";
private static final String ORB_SE_SINGLETON_CLASS = "com.sun.corba.se.impl.orb.ORBSingleton";

private static final String RMI_UTIL_CLASS = "com.sun.corba.ee.impl.javax.rmi.CORBA.Util";
private static final String RMI_STUB_CLASS = "com.sun.corba.ee.impl.javax.rmi.CORBA.StubDelegateImpl";
private static final String RMI_PRO_CLASS = "com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject";

@Inject
@Named(ServerEnvironment.DEFAULT_INSTANCE_NAME)
Config config;

@Inject
private GrizzlyService grizzlyService;

public void postConstruct()
{
public void postConstruct() {
setORBSystemProperties();
initializeLazyListener();
}

/**
/**
* Set ORB-related system properties that are required in case
* user code in the app server or app client container creates a
* new ORB instance. The default result of calling
Expand All @@ -92,47 +80,11 @@ public void postConstruct()
* to a different ORB than the RMI-IIOP delegates.
*/
private void setORBSystemProperties() {

java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public java.lang.Object run() {
if (System.getProperty(OMG_ORB_CLASS_PROPERTY) == null) {
// Assume Sun ee ORB at all times.
// set ORB based on JVM vendor
//
// if (System.getProperty("java.vendor").equals("Sun Microsystems Inc.")) {
// System.setProperty(OMG_ORB_CLASS_PROPERTY, ORB_SE_CLASS);
// } else {
// if not Sun, then set to EE class
System.setProperty(OMG_ORB_CLASS_PROPERTY, ORB_CLASS);
// }
}

if (System.getProperty(OMG_ORB_SINGLETON_CLASS_PROPERTY) == null) {
// Assume Sun ee ORB at all times.
//
// set ORBSingleton based on JVM vendor
// if (System.getProperty("java.vendor").equals("Sun Microsystems Inc.")) {
// System.setProperty(OMG_ORB_SINGLETON_CLASS_PROPERTY, ORB_SE_SINGLETON_CLASS);
// } else {
// if not Sun, then set to EE class
System.setProperty(OMG_ORB_SINGLETON_CLASS_PROPERTY, ORB_SINGLETON_CLASS);
// }
}

System.setProperty(ORB_UTIL_CLASS_PROPERTY,
RMI_UTIL_CLASS);

System.setProperty(RMIIIOP_STUB_DELEGATE_CLASS_PROPERTY,
RMI_STUB_CLASS);

System.setProperty(RMIIIOP_PRO_DELEGATE_CLASS_PROPERTY,
RMI_PRO_CLASS);

return null;
}
}
);
SystemProperties.setProperty(OMG_ORB_CLASS_PROPERTY, ORB_CLASS, false);
SystemProperties.setProperty(OMG_ORB_SINGLETON_CLASS_PROPERTY, ORB_SINGLETON_CLASS, false);
SystemProperties.setProperty(ORB_UTIL_CLASS_PROPERTY, RMI_UTIL_CLASS, true);
SystemProperties.setProperty(RMIIIOP_STUB_DELEGATE_CLASS_PROPERTY, RMI_STUB_CLASS, true);
SystemProperties.setProperty(RMIIIOP_PRO_DELEGATE_CLASS_PROPERTY, RMI_PRO_CLASS, true);
}

/**
Expand Down
Loading