Skip to content
Open
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) 2022, 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 2026 Contributors to the Eclipse Foundation.
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -40,9 +40,6 @@ public static Logger getLogger() {
return CDI_LOGGER;
}

@LogMessageInfo(message = "Setting Context Class Loader for {0} to {1}.", level = "FINER")
public static final String SETTING_CONTEXT_CLASS_LOADER = CDI_LOGMSG_PREFIX + "-00001";

@LogMessageInfo(message = "BeanDeploymentArchiveImpl::addBeanClass - adding {0} to {1}.", level = "FINE")
public static final String ADD_BEAN_CLASS = CDI_LOGMSG_PREFIX + "-00002";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 2021, 2025, 2026 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 @@ -52,7 +52,6 @@
import org.jboss.weld.ejb.spi.EjbDescriptor;

import static java.util.logging.Level.FINE;
import static java.util.logging.Level.FINER;
import static java.util.logging.Level.FINEST;
import static java.util.logging.Level.SEVERE;
import static java.util.logging.Level.WARNING;
Expand All @@ -64,7 +63,6 @@
import static org.glassfish.cdi.CDILoggerInfo.PROCESSING_BECAUSE_SCOPE_ANNOTATION;
import static org.glassfish.cdi.CDILoggerInfo.PROCESSING_CDI_ENABLED_ARCHIVE;
import static org.glassfish.cdi.CDILoggerInfo.PROCESSING_WEB_INF_LIB;
import static org.glassfish.cdi.CDILoggerInfo.SETTING_CONTEXT_CLASS_LOADER;
import static org.glassfish.weld.WeldDeployer.WELD_BOOTSTRAP;
import static org.glassfish.weld.connector.WeldUtils.BEANS_XML_FILENAME;
import static org.glassfish.weld.connector.WeldUtils.CLASS_SUFFIX;
Expand All @@ -88,16 +86,16 @@ public class BeanDeploymentArchiveImpl implements BeanDeploymentArchive {

private static final Logger LOG = CDILoggerInfo.getLogger();

// Workaround: WELD-781
// The classloader for this BDA. It is exposed via getModuleClassLoaderForBDA() and
// supplied to Weld through the per-BDA ResourceLoader SPI (see WeldDeployer.enable),
// so Weld loads classes and resources of this archive with the right classloader.
private final ClassLoader moduleClassLoaderForBDA;

private String id;
private String friendlyId = "";

private Collection<String> cdiAnnotatedClassNames;

private boolean deploymentComplete;

private final List<String> moduleClassNames; // Names of classes in the module
private final List<String> beanClassNames; // Names of bean classes in the module
private final List<Class<?>> moduleClasses; // Classes in the module
Expand Down Expand Up @@ -197,18 +195,6 @@ public Collection<BeanDeploymentArchive> getBeanDeploymentArchives() {

@Override
public Collection<String> getBeanClasses() {
// This method is called during BeanDeployment.deployBeans, so this would
// be the right time to place the module classloader for the BDA as the TCL
if (LOG.isLoggable(FINER)) {
LOG.log(FINER, SETTING_CONTEXT_CLASS_LOADER, new Object[] { this.id, this.moduleClassLoaderForBDA });
}

if (!isDeploymentComplete()) {
// The TCL is unset at the end of deployment of CDI beans in WeldDeployer.event
// XXX: This is a workaround for issue https://issues.jboss.org/browse/WELD-781.
// Remove this as soon as the SPI comes in.
Thread.currentThread().setContextClassLoader(this.moduleClassLoaderForBDA);
}
return beanClassNames;
}

Expand Down Expand Up @@ -723,11 +709,4 @@ private URL getBeansXMLFileURL(ReadableArchive archive, String beansXMLPath) thr
return url;
}

public boolean isDeploymentComplete() {
return deploymentComplete;
}

public void setDeploymentComplete(boolean deploymentComplete) {
this.deploymentComplete = deploymentComplete;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 2021, 2025, 2026 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 @@ -400,7 +400,6 @@ private void enable(ApplicationInfo appInfo, WeldBootstrap bootstrap) {
addCdiServicesToNonModuleBdas(deploymentImpl.getLibJarRootBdas(), injectionManager);
addCdiServicesToNonModuleBdas(deploymentImpl.getRarRootBdas(), injectionManager);

ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
invocationManager.pushAppEnvironment(new WeldApplicationEnvironment(appInfo));
try {
doBootstrapStartup(appInfo, bootstrap, deploymentImpl);
Expand All @@ -410,14 +409,6 @@ private void enable(ApplicationInfo appInfo, WeldBootstrap bootstrap) {
throw new DeploymentException(msgPrefix + t.getMessage(), t);
} finally {
invocationManager.popAppEnvironment();

// The TCL is originally the EAR classloader and is reset during Bean deployment to the
// corresponding module classloader in BeanDeploymentArchiveImpl.getBeans
// for Bean classloading to succeed.
//
// The TCL is reset to its old value here.
Thread.currentThread().setContextClassLoader(originalClassLoader);
deploymentComplete(deploymentImpl);
}
}

Expand Down Expand Up @@ -530,12 +521,6 @@ private void enableEjbSupport(WeldBootstrap bootstrap, DeploymentImpl deployment
}
}

private void deploymentComplete(DeploymentImpl deploymentImpl) {
for (BeanDeploymentArchive oneBda : deploymentImpl.getBeanDeploymentArchives()) {
((BeanDeploymentArchiveImpl) oneBda).setDeploymentComplete(true);
}
}

private void doBootstrapShutdown(ApplicationInfo appInfo) {
WeldBootstrap bootstrap = appInfo.getTransientAppMetaData(WELD_BOOTSTRAP, WeldBootstrap.class);
String bootstrapShutdown = appInfo.getTransientAppMetaData(WELD_BOOTSTRAP_SHUTDOWN, String.class);
Expand Down
Loading