Skip to content

Commit

Permalink
GJULE integration with GlassFish
Browse files Browse the repository at this point in the history
- own folder and CL for bootstrap dependencies - no need for JVM options
- sorted logging.properties
- HK2 services ARE NOT the logging system, but USE the logging system
- AdminMain sets the log manager, but doesn't set the configuration yet - this
  step is on the server (it has to load logging.properties first). All log
  records are buffered automatically -> no need for earlyLogMessages any more,
  they also contained around 20 selected messages, but all other logs were lost.

- url classloaders have toString
- DirectoryClassLoader doesn't throw IOE but ISE -> if anything would go wrong,
  we have ISE with stacktrace instead of NPE following swallowed IOE.

- Fixed some log messages
- Fixed SecurityManager complaints in QuickLook tests
  • Loading branch information
dmatej committed Jul 19, 2022
1 parent b68a6a8 commit 1d6cdb2
Show file tree
Hide file tree
Showing 135 changed files with 3,963 additions and 7,362 deletions.
5 changes: 4 additions & 1 deletion appserver/admin/cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@
<manifest>
<mainClass>org.glassfish.admin.cli.AsadminMain</mainClass>
<addClasspath>true</addClasspath>
+ <classpathPrefix>../../modules</classpathPrefix>
<classpathPrefix>../../modules</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>../../lib/bootstrap/glassfish-jul-extension.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@
<jvm-options>-Dcom.ctc.wstx.returnNullForDefaultNamespace=true</jvm-options>

<jvm-options>-XX:NewRatio=2</jvm-options>
<jvm-options>-Xbootclasspath/a:${com.sun.aas.installRoot}/lib/grizzly-npn-api.jar</jvm-options>
<jvm-options>--add-opens=java.base/java.io=ALL-UNNAMED</jvm-options>
<jvm-options>--add-opens=java.base/java.lang=ALL-UNNAMED</jvm-options>
<jvm-options>--add-opens=java.base/java.util=ALL-UNNAMED</jvm-options>
Expand Down
7 changes: 4 additions & 3 deletions appserver/appclient/client/acc-standalone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
</developers>

<properties>
<path.apps>../lib/install/applications</path.apps>
<path.appclient>../lib/appclient</path.appclient>
<path.lib>../lib</path.lib>
<path.apps>${path.lib}/install/applications</path.apps>
<path.appclient>${path.lib}/appclient</path.appclient>
<path.derby>../../javadb/lib</path.derby>
<path.mq>../../mq/lib</path.mq>

Expand All @@ -65,7 +66,7 @@
<classpath.mq>${path.mq}/imq.jar ${path.mq}/imqadmin.jar ${path.mq}/imqutil.jar ${path.mq}/fscontext.jar ${path.apps}/jmsra/imqjmsra.jar</classpath.mq>
<classpath.weld>${path.appclient}/weld-se-shaded.jar</classpath.weld>

<classpath.additions>${classpath.mq} ${classpath.derby} ${classpath.jaxrra} ${classpath.jdbcra} ${classpath.weld}</classpath.additions>
<classpath.additions>${path.lib}/bootstrap/glassfish-jul-extension.jar ${classpath.mq} ${classpath.derby} ${classpath.jaxrra} ${classpath.jdbcra} ${classpath.weld}</classpath.additions>
</properties>

<dependencies>
Expand Down
5 changes: 5 additions & 0 deletions appserver/appclient/client/acc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
</properties>

<dependencies>
<dependency>
<groupId>org.glassfish.main</groupId>
<artifactId>glassfish-jul-extension</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Contributors to Eclipse Foundation.
* Copyright (c) 2021, 2022 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
Expand Down Expand Up @@ -32,6 +32,7 @@
import java.util.logging.SimpleFormatter;

import org.glassfish.appclient.client.acc.config.LogService;
import org.glassfish.main.jul.GlassFishLogger;

/**
* Logger that conforms to the glassfish-acc.xml config file settings for logging while, in some cases, also adjusting
Expand All @@ -50,14 +51,14 @@
*
* @author tjquinn
*/
public class ACCLogger extends Logger {
public class ACCLogger extends GlassFishLogger {

private static final String ACC_LOGGER_NAME = "GlassFish.ACC";

private static final Level DEFAULT_ACC_LOG_LEVEL = Level.INFO;

public ACCLogger(final LogService logService) throws IOException {
super(ACC_LOGGER_NAME, null);
super(ACC_LOGGER_NAME);
init(logService);
}

Expand All @@ -66,9 +67,7 @@ private void init(final LogService logService) throws IOException {
final Handler configuredFileHandler = createHandler(logService, level);
final ResourceBundle rb = ResourceBundle.getBundle(ACCLogger.class.getPackage().getName() + ".LogStrings");

/*
* Set existing loggers to at least the configured level.
*/
// Set existing loggers to at least the configured level.
for (Enumeration<String> names = LogManager.getLogManager().getLoggerNames(); names.hasMoreElements();) {
final String loggerName = names.nextElement();
final Logger logger = LogManager.getLogManager().getLogger(loggerName);
Expand All @@ -94,7 +93,7 @@ private static Level chooseLevel(final LogService logService) {
Level level = DEFAULT_ACC_LOG_LEVEL;
if (logService != null) {
String configLevelText = logService.getLevel();
if (configLevelText != null && (!configLevelText.equals(""))) {
if (configLevelText != null && !configLevelText.isEmpty()) {
try {
level = Level.parse(configLevelText);
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 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 All @@ -21,21 +22,24 @@
import com.sun.enterprise.security.SecurityContext;
import com.sun.enterprise.transaction.api.JavaEETransactionManager;
import com.sun.enterprise.util.Utility;
import org.glassfish.api.invocation.ComponentInvocation;
import org.glassfish.api.invocation.InvocationManager;
import org.glassfish.concurrent.LogFacade;
import org.glassfish.enterprise.concurrent.spi.ContextHandle;
import org.glassfish.enterprise.concurrent.spi.ContextSetupProvider;
import org.glassfish.internal.deployment.Deployment;

import jakarta.enterprise.concurrent.ContextService;
import jakarta.enterprise.concurrent.ManagedTask;
import jakarta.transaction.*;
import jakarta.transaction.Status;
import jakarta.transaction.Transaction;

import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.glassfish.api.invocation.ComponentInvocation;
import org.glassfish.api.invocation.InvocationManager;
import org.glassfish.concurrent.LogFacade;
import org.glassfish.enterprise.concurrent.spi.ContextHandle;
import org.glassfish.enterprise.concurrent.spi.ContextSetupProvider;
import org.glassfish.internal.deployment.Deployment;

public class ContextSetupProviderImpl implements ContextSetupProvider {

private transient InvocationManager invocationManager;
Expand All @@ -44,11 +48,11 @@ public class ContextSetupProviderImpl implements ContextSetupProvider {
// transactionManager should be null for ContextService since it uses TransactionSetupProviderImpl
private transient JavaEETransactionManager transactionManager;

private static final Logger logger = LogFacade.getLogger();
private static final Logger LOG = LogFacade.getLogger();

static final long serialVersionUID = -1095988075917755802L;

static enum CONTEXT_TYPE {CLASSLOADING, SECURITY, NAMING, WORKAREA}
enum CONTEXT_TYPE {CLASSLOADING, SECURITY, NAMING, WORKAREA}

private boolean classloading, security, naming, workArea;

Expand Down Expand Up @@ -109,7 +113,7 @@ public ContextHandle saveContext(ContextService contextService, Map<String, Stri
@Override
public ContextHandle setup(ContextHandle contextHandle) throws IllegalStateException {
if (! (contextHandle instanceof InvocationContext)) {
logger.log(Level.SEVERE, LogFacade.UNKNOWN_CONTEXT_HANDLE);
LOG.log(Level.SEVERE, LogFacade.UNKNOWN_CONTEXT_HANDLE);
return null;
}
InvocationContext handle = (InvocationContext) contextHandle;
Expand Down Expand Up @@ -148,7 +152,7 @@ public ContextHandle setup(ContextHandle contextHandle) throws IllegalStateExcep
@Override
public void reset(ContextHandle contextHandle) {
if (! (contextHandle instanceof InvocationContext)) {
logger.log(Level.SEVERE, LogFacade.UNKNOWN_CONTEXT_HANDLE);
LOG.log(Level.SEVERE, LogFacade.UNKNOWN_CONTEXT_HANDLE);
return;
}
InvocationContext handle = (InvocationContext) contextHandle;
Expand All @@ -174,7 +178,7 @@ public void reset(ContextHandle contextHandle) {
transactionManager.rollback();
}
} catch (Exception ex) {
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, ex.toString());
LOG.log(Level.SEVERE, "Cannot commit or rollback the transaction or get it's status.", ex);
}
}
transactionManager.clearThreadTx();
Expand All @@ -184,8 +188,9 @@ public void reset(ContextHandle contextHandle) {
private boolean isApplicationEnabled(String appId) {
if (appId != null) {
Application app = applications.getApplication(appId);
if (app != null)
if (app != null) {
return deployment.isAppEnabled(app);
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

/**
* Classloader that is responsible to load the ear libraries (lib/*.jar etc)
*
*/
public class EarLibClassLoader extends ASURLClassLoader {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@
<include>jakartaee.jar</include>
<include>appserv-rt.jar</include>
<include>gf-client.jar</include>
<include>grizzly-npn-api.jar</include>
</includes>
<outputDirectory>${install.dir.name}/glassfish/lib</outputDirectory>
</fileSet>
Expand All @@ -276,9 +275,10 @@
<fileSet>
<directory>${temp.dir}</directory>
<includes>
<include>glassfish-jul-extension.jar</include>
<include>grizzly-npn-api.jar</include>
</includes>
<outputDirectory>${install.dir.name}/glassfish/lib</outputDirectory>
<outputDirectory>${install.dir.name}/glassfish/lib/bootstrap</outputDirectory>
</fileSet>

<!-- felix -->
Expand Down Expand Up @@ -324,6 +324,7 @@
<exclude>felix.jar</exclude>
<exclude>nucleus-domain.jar</exclude>
<exclude>appserver-domain.jar</exclude>
<exclude>glassfish-jul-extension.jar</exclude>
<exclude>grizzly-npn-api.jar</exclude>
<exclude>cli-optional.jar</exclude>
<exclude>appserver-cli.jar</exclude>
Expand Down
6 changes: 4 additions & 2 deletions appserver/distributions/web/src/main/assembly/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@
<outputDirectory>${install.dir.name}/glassfish/lib</outputDirectory>
</fileSet>

<!-- modules/lib -->
<!-- lib/bootstrap -->
<fileSet>
<directory>${temp.dir}</directory>
<includes>
<include>glassfish-jul-extension.jar</include>
<include>grizzly-npn-api.jar</include>
</includes>
<outputDirectory>${install.dir.name}/glassfish/lib</outputDirectory>
<outputDirectory>${install.dir.name}/glassfish/lib/bootstrap</outputDirectory>
</fileSet>

<!-- felix -->
Expand Down Expand Up @@ -228,6 +229,7 @@
<exclude>felix.jar</exclude>
<exclude>nucleus-domain.jar</exclude>
<exclude>appserver-domain.jar</exclude>
<exclude>glassfish-jul-extension.jar</exclude>
<exclude>grizzly-npn-api.jar</exclude>
<exclude>cli-optional.jar</exclude>
<exclude>appserver-cli.jar</exclude>
Expand Down
92 changes: 81 additions & 11 deletions appserver/logging/logging.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#
# Copyright (c) 2022 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 All @@ -14,29 +15,98 @@
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
#

.level=INFO
systemRootLoggerLevel=INFO

com.hazelcast.level=WARNING

com.sun.enterprise.glassfish.level=INFO
com.sun.enterprise.glassfish.bootstrap.level=INFO
com.sun.enterprise.security.level=INFO
com.sun.webui.level=INFO

jakarta.level=INFO

jakarta.enterprise.ejb.container.level=INFO

jakarta.enterprise.inject.level=INFO

jakarta.enterprise.resource.corba.level=INFO
jakarta.enterprise.resource.jta.level=INFO
jakarta.enterprise.system.webservices.saaj.level=INFO
jakarta.enterprise.system.container.ejb.level=INFO
jakarta.enterprise.system.container.ejb.mdb.level=INFO
jakarta.enterprise.resource.mail.level=INFO
jakarta.enterprise.system.webservices.rpc.level=INFO
jakarta.enterprise.system.container.web.level=INFO
jakarta.enterprise.resource.javamail.level=INFO
jakarta.enterprise.resource.jdo.level=INFO
jakarta.enterprise.resource.jms.level=INFO
jakarta.enterprise.system.webservices.registry.level=INFO
jakarta.enterprise.resource.jta.level=INFO
jakarta.enterprise.resource.resourceadapter.level=INFO
jakarta.enterprise.resource.sqltrace.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.application.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.resource.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.config.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.context.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.facelets.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.lifecycle.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.managedbean.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.renderkit.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.resource.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.taglib.level=INFO
jakarta.enterprise.resource.webcontainer.jsf.timing.level=INFO
javax.org.glassfish.persistence.level=INFO

jakarta.enterprise.system.level=INFO
jakarta.enterprise.system.container.cmp.level=INFO
jakarta.enterprise.system.container.ejb.level=INFO
jakarta.enterprise.system.container.ejb.mdb.level=INFO
jakarta.enterprise.system.container.web.level=INFO
jakarta.enterprise.system.core.level=INFO
jakarta.enterprise.system.core.classloading.level=INFO
jakarta.enterprise.system.core.config.level=INFO
jakarta.enterprise.system.core.security.level=INFO
jakarta.enterprise.system.core.selfmanagement.level=INFO
jakarta.enterprise.system.core.transaction.level=INFO
jakarta.enterprise.system.jmx.level=INFO
jakarta.enterprise.system.security.ssl.level=INFO
jakarta.enterprise.system.tools.admin.level=INFO
jakarta.enterprise.system.tools.backup.level=INFO
jakarta.enterprise.system.tools.deployment.level=INFO
jakarta.enterprise.system.tools.deployment.common.level=WARNING
jakarta.enterprise.system.tools.deployment.dol.level=WARNING
jakarta.enterprise.system.tools.monitor.level=INFO
jakarta.enterprise.system.util.level=INFO
jakarta.enterprise.system.webservices.saaj.level=INFO
jakarta.enterprise.system.webservices.rpc.level=INFO
jakarta.enterprise.system.webservices.registry.level=INFO

jakarta.enterprise.web.level=INFO
jakarta.enterprise.web.core.level=INFO
jakarta.enterprise.web.util.level=INFO
jakarta.enterprise.web.vs.__asadmin.level=INFO
jakarta.enterprise.web.vs.server.level=INFO

jakarta.mail.level=INFO


jakarta.ws.rs.client.level=INFO

MBeans.level=INFO

org.apache.catalina.level=INFO
org.apache.coyote.level=INFO
org.apache.jasper.level=INFO

org.eclipse.krazo.level=INFO
org.eclipse.persistence.session.level=INFO

org.glassfish.level=INFO
org.glassfish.admingui.level=INFO
org.glassfish.grizzly.level=INFO
org.glassfish.grizzly.http2.level=INFO
org.glassfish.jersey.level=INFO
org.glassfish.jersey.message.internal.TracingLogger.level=INFO
org.glassfish.main.level=INFO
org.glassfish.naming.level=INFO
org.eclipse.persistence.session.level=INFO
org.glassfish.persistence.level=INFO
org.glassfish.security.level=INFO
org.hibernate.validator.internal.util.Version.level=WARNING

org.jvnet.hk2.level=INFO
org.jvnet.hk2.osgiadapter.level=WARNING

sun.level=INFO

Loading

0 comments on commit 1d6cdb2

Please sign in to comment.