Skip to content
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

Deploy datasource for Jakarta Persistence early #25430

Merged
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) 2022, 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 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 @@ -314,7 +314,7 @@ private void completePreparation(final Instrumentation inst) throws NamingExcept
client.getAnchorDir(), connectorRuntime);
for (PersistenceUnitDescriptor puDesc : referencedPUs) {
PersistenceUnitLoader pul = new PersistenceUnitLoader(puDesc, pcci);
desc.addEntityManagerFactory(puDesc.getName(), pul.getEMF());
desc.addEntityManagerFactory(puDesc.getName(), pul.getEntityManagerFactory());
}

cleanup.setEMFs(pcci.emfs());
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2025 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
Expand All @@ -24,7 +25,7 @@
public class JPAContainer implements Container {

@Override
public Class<? extends Deployer> getDeployer() {
public Class<? extends Deployer<?,?>> getDeployer() {
return JPADeployer.class;
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -20,8 +21,9 @@
import org.glassfish.api.deployment.ApplicationContext;

/**
* Represents Application Container for JPA One instance of this object is
* created per deployed bundle.
* Represents Application Container for Jakarta Persistence.
* <p>
* One instance of this object is created per deployed bundle.
*
* @author Mitesh Meswani
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 2025 Contributors to the Eclipse Foundation.
* Copyright (c) 2008, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -18,7 +18,6 @@
package org.glassfish.persistence.jpa;

import com.sun.enterprise.deployment.PersistenceUnitDescriptor;
import com.sun.enterprise.deployment.PersistenceUnitsDescriptor;
import com.sun.enterprise.util.i18n.StringManager;
import com.sun.logging.LogDomains;

Expand All @@ -35,10 +34,11 @@
import java.util.logging.Logger;

import org.glassfish.api.naming.SimpleJndiName;
import org.glassfish.deployment.common.RootDeploymentDescriptor;
import org.glassfish.persistence.jpa.schemageneration.SchemaGenerationProcessor;
import org.glassfish.persistence.jpa.schemageneration.SchemaGenerationProcessorFactory;

import static jakarta.persistence.ValidationMode.AUTO;
import static jakarta.persistence.ValidationMode.CALLBACK;
import static java.util.Collections.unmodifiableMap;
import static java.util.logging.Level.FINE;
import static java.util.logging.Level.INFO;
Expand Down Expand Up @@ -123,16 +123,16 @@ public PersistenceUnitLoader(PersistenceUnitDescriptor persistenceUnitToInstanti
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(providerContainerContractInfo.getClassLoader());
try {
entityManagerFactory = loadPU(persistenceUnitToInstantiate);
entityManagerFactory = loadPersistenceUnit(persistenceUnitToInstantiate);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}

/**
* @return The emf loaded.
* @return The EntityManagerFactory loaded.
*/
public EntityManagerFactory getEMF() {
public EntityManagerFactory getEntityManagerFactory() {
return entityManagerFactory;
}

Expand All @@ -153,7 +153,7 @@ private void setSystemPropertyToEnableDoPrivilegedInEclipseLink() {
*
* @param persistenceUnitDescriptor PersistenceUnitDescriptor to be loaded.
*/
private EntityManagerFactory loadPU(PersistenceUnitDescriptor persistenceUnitDescriptor) {
private EntityManagerFactory loadPersistenceUnit(PersistenceUnitDescriptor persistenceUnitDescriptor) {
checkForUpgradeFromTopLinkEssentials(persistenceUnitDescriptor);
checkForDataSourceOverride(persistenceUnitDescriptor);
calculateDefaultDataSource(persistenceUnitDescriptor);
Expand Down Expand Up @@ -211,7 +211,7 @@ private EntityManagerFactory loadPU(PersistenceUnitDescriptor persistenceUnitDes

// Check if the persistence unit requires Bean Validation
ValidationMode validationMode = getValidationMode(persistenceUnitDescriptor);
if (validationMode == ValidationMode.AUTO || validationMode == ValidationMode.CALLBACK) {
if (validationMode == AUTO || validationMode == CALLBACK) {
overRides.put(VALIDATOR_FACTORY, providerContainerContractInfo.getValidatorFactory());
}

Expand All @@ -223,10 +223,11 @@ private EntityManagerFactory loadPU(PersistenceUnitDescriptor persistenceUnitDes

logger.logp(FINE, "PersistenceUnitLoader", "loadPU", "emf = {0}", entityManagerFactory);

PersistenceUnitsDescriptor parent = persistenceUnitDescriptor.getParent();
RootDeploymentDescriptor containingBundle = parent.getParent();
providerContainerContractInfo.registerEMF(
persistenceUnitInfo.getPersistenceUnitName(), persistenceUnitDescriptor.getPuRoot(), containingBundle, entityManagerFactory);
persistenceUnitInfo.getPersistenceUnitName(),
persistenceUnitDescriptor.getPuRoot(),
persistenceUnitDescriptor.getParent().getParent(),
entityManagerFactory);

if (fineMsgLoggable) {
logger.fine("Finished loading persistence unit for application: " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class SshClusterITest {

private static final String DOMAIN_NAME = "domain1";

private static final Path PATH_DOCKER_GF_ROOT = Path.of("/opt", "glassfish7");
private static final Path PATH_DOCKER_GF_ROOT = Path.of("/opt", "glassfish8");
private static final Path PATH_DOCKER_GF_DOMAINS = PATH_DOCKER_GF_ROOT.resolve(Path.of("glassfish", "domains"));
private static final Path PATH_DOCKER_GF_NODES = PATH_DOCKER_GF_ROOT.resolve(Path.of("glassfish", "nodes"));
private static final Path PATH_DOCKER_GF_DOMAIN1_SERVER_LOG = PATH_DOCKER_GF_DOMAINS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class GlassFishContainer extends GenericContainer<GlassFishContainer> {

public GlassFishContainer(Network network, String hostname, String logPrefix, String command) {
super("eclipse-temurin:17.0.13_11-jdk");
super("eclipse-temurin:24_36-jdk");
withNetwork(network)
.withEnv("TZ", "UTC").withEnv("LC_ALL", "en_US.UTF-8")
.withStartupAttempts(1)
Expand Down
125 changes: 77 additions & 48 deletions appserver/tests/appserv-tests/devtests/jdbc/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,66 +191,66 @@
</target>

<target name="run-tests1">
<ant dir="appauth" target="all"/>
<ant dir="appauthtx" target="all"/>
<ant dir="contauth" target="all"/>
<ant dir="contauthtx" target="all"/>
<ant dir="contauth1" target="all"/>
<ant dir="contauth1tx" target="all"/>
<ant dir="reconfig" target="all"/>
<run-jdbc-test path="appauth" target="all"/>
<run-jdbc-test path="appauthtx" target="all"/>
<run-jdbc-test path="contauth" target="all"/>
<run-jdbc-test path="contauthtx" target="all"/>
<run-jdbc-test path="contauth1" target="all"/>
<run-jdbc-test path="contauth1tx" target="all"/>
<run-jdbc-test path="reconfig" target="all"/>
</target>

<target name="run-tests2">
<ant dir="autocommit" target="all"/>
<ant dir="jdbcjmsauth" target="all"/>
<ant dir="nopasswdfordb" target="all"/>
<ant dir="txpassthrough" target="all"/>
<ant dir="txafternontx" target="all"/>
<ant dir="txafternontxjndi" target="all"/>
<ant dir="notxops" target="all"/>
<ant dir="nonacc" target="all"/>
<ant dir="lazyassoc" target="all"/>
<run-jdbc-test path="autocommit" target="all"/>
<run-jdbc-test path="jdbcjmsauth" target="all"/>
<run-jdbc-test path="nopasswdfordb" target="all"/>
<run-jdbc-test path="txpassthrough" target="all"/>
<run-jdbc-test path="txafternontx" target="all"/>
<run-jdbc-test path="txafternontxjndi" target="all"/>
<run-jdbc-test path="notxops" target="all"/>
<run-jdbc-test path="nonacc" target="all"/>
<run-jdbc-test path="lazyassoc" target="all"/>
</target>

<target name="run-tests3">
<ant dir="markconnectionasbad.local" target="all"/>
<ant dir="markconnectionasbad.xa" target="all"/>
<ant dir="statementwrapper" target="all"/>
<ant dir="maxconnectionusage" target="all"/>
<ant dir="switchoffACCconnpooling" target="all"/>
<ant dir="multipleusercredentials" target="all"/>
<ant dir="multiplecloseconnection" target="all"/>
<ant dir="statementtimeout" target="all"/>
<ant dir="conval" target="all"/>
<ant dir="conval" target="all-assoc-with-thread"/>
<ant dir="connleaktracing" target="all"/>
<ant dir="conncreationretry" target="all"/>
<run-jdbc-test path="markconnectionasbad.local" target="all"/>
<run-jdbc-test path="markconnectionasbad.xa" target="all"/>
<run-jdbc-test path="statementwrapper" target="all"/>
<run-jdbc-test path="maxconnectionusage" target="all"/>
<run-jdbc-test path="switchoffACCconnpooling" target="all"/>
<run-jdbc-test path="multipleusercredentials" target="all"/>
<run-jdbc-test path="multiplecloseconnection" target="all"/>
<run-jdbc-test path="statementtimeout" target="all"/>
<run-jdbc-test path="conval" target="all"/>
<run-jdbc-test path="conval" target="all-assoc-with-thread"/>
<run-jdbc-test path="connleaktracing" target="all"/>
<run-jdbc-test path="conncreationretry" target="all"/>
</target>

<target name="run-tests4">
<ant dir="validateatmostonceperiod" target="all"/>
<ant dir="connsharing" target="nonxa"/>
<ant dir="connsharing/nonxa" target="all-assoc-with-thread"/>
<ant dir="cpds" target="all"/>
<ant dir="txisolation" target="all"/>
<ant dir="stmtCaching_hit_miss" target="all"/>
<ant dir="pooling" target="all"/>
<ant dir="dmmcf" target="all"/>
<ant dir="dmmcf.markconnectionasbad.xa" target="all"/>
<ant dir="dmmcf.appclient" target="all"/>
<run-jdbc-test path="validateatmostonceperiod" target="all"/>
<run-jdbc-test path="connsharing" target="nonxa"/>
<run-jdbc-test path="connsharing/nonxa" target="all-assoc-with-thread"/>
<run-jdbc-test path="cpds" target="all"/>
<run-jdbc-test path="txisolation" target="all"/>
<run-jdbc-test path="stmtCaching_hit_miss" target="all"/>
<run-jdbc-test path="pooling" target="all"/>
<run-jdbc-test path="dmmcf" target="all"/>
<run-jdbc-test path="dmmcf.markconnectionasbad.xa" target="all"/>
<run-jdbc-test path="dmmcf.appclient" target="all"/>
</target>

<target name="run-tests5">
<ant dir="tracingsql" target="all"/>
<ant dir="datasource40" target="all"/>
<ant dir="custom-validation" target="all"/>
<ant dir="custom-validation-1" target="all"/>
<ant dir="flushconnectionpool" target="all"/>
<ant dir="connleakreclaimnotify" target="all"/>
<ant dir="stmtCaching_hit_miss.monitoring" target="all"/>
<ant dir="jpa-dsd" target="all" />
<ant dir="jpa-dsd" target="all-appclient-exposed-dsd"/>
<ant dir="stmtCaching_hit_miss.fixed" target="all"/>
<run-jdbc-test path="tracingsql" target="all"/>
<run-jdbc-test path="datasource40" target="all"/>
<run-jdbc-test path="custom-validation" target="all"/>
<run-jdbc-test path="custom-validation-1" target="all"/>
<run-jdbc-test path="flushconnectionpool" target="all"/>
<run-jdbc-test path="connleakreclaimnotify" target="all"/>
<run-jdbc-test path="stmtCaching_hit_miss.monitoring" target="all"/>
<run-jdbc-test path="jpa-dsd" target="all" />
<run-jdbc-test path="jpa-dsd" target="all-appclient-exposed-dsd"/>
<run-jdbc-test path="stmtCaching_hit_miss.fixed" target="all"/>
</target>

<target name="ee-all">
Expand Down Expand Up @@ -581,4 +581,33 @@
ant all (Executes all the jdbc tests)
</echo>
</target>

<macrodef name="run-jdbc-test" xmlns:if="ant:if" xmlns:unless="ant:unless">
<attribute name="path" />
<attribute name="target" />
<sequential>
<local name="do-run-test" />
<condition property="do-run-test" else="false">
<or>
<equals arg1="${env.jdbc}" arg2="@{path}" />
<not>
<isset property="env.jdbc" />
</not>
</or>
</condition>

<sequential if:true="${do-run-test}">
<local name="absolute.path" />
<property name="absolute.path" location="@{path}" />
<echo message="${line.separator} ${line.separator}" />
<echo message=" **************************************************" />
<echo message=" * Running @{path} " />
<echo message=" * Path: ${absolute.path} " />
<echo message=" * jdbc: ${env.jdbc} " />
<echo message=" **************************************************" />
<echo message="${line.separator} ${line.separator}" />
<ant dir="@{path}" target="@{target}" />
</sequential>
</sequential>
</macrodef>
</project>
22 changes: 0 additions & 22 deletions appserver/tests/appserv-tests/devtests/jdbc/jpa-dsd/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,6 @@
</target>

<target name="setup" depends="init-common">
<!-- <antcall target="deploy-jdbc-common">
<param name="jdbc.conpool.name" value="jdbc-xa-pool"/>
<param name="db.class" value="org.apache.derby.jdbc.ClientXADataSource"/>
<param name="jdbc.resource.type" value="javax.sql.XADataSource"/>
<param name="jdbc.resource.name" value="jdbc/xa"/>
</antcall>
<antcall target="asadmin-common">
<param name="admin.command" value="set"/>
<param name="operand.props"
value="${resources.dottedname.prefix}.jdbc-connection-pool.jdbc-xa-pool.property.connectionAttributes=;create=true"/>
</antcall>-->


<antcall target="execute-sql-common">
<param name="sql.file" value="sql/create.sql"/>
<param name="db.url" value="jdbc:derby://localhost:1527/${db.name};create=true;"/>
Expand All @@ -80,14 +67,6 @@
<param name="sql.file" value="sql/drop.sql"/>
<param name="db.url" value="jdbc:derby://localhost:1527/${db.name};create=true;"/>
</antcall>
<!-- <antcall target="delete-jdbc-resource-common">
<param name="jdbc.resource.name" value="jdbc/xa"/>
</antcall>

<antcall target="delete-jdbc-connpool-common">
<param name="jdbc.conpool.name" value="jdbc-xa-pool"/>
</antcall>-->

</target>

<target name="build" depends="compile">
Expand Down Expand Up @@ -119,7 +98,6 @@

<target name="run" depends="init-common">
<antcall target="runclient-common"/>
<!-- <antcall target="runclient-standalone"/>-->
</target>

<target name="undeploy" depends="init-common">
Expand Down
2 changes: 1 addition & 1 deletion appserver/tests/appserv-tests/devtests/jdbc/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ list_test_ids(){
}

test_run(){
${S1AS_HOME}/bin/asadmin start-domain domain1
${S1AS_HOME}/bin/asadmin start-domain $GLASSFISH_SUSPEND domain1
${S1AS_HOME}/bin/asadmin start-database
cd ${APS_HOME}/devtests/jdbc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.glassfish.api.deployment.ApplicationContainer;
import org.glassfish.api.deployment.ApplicationContext;

public class WeldApplicationContainer implements ApplicationContainer {
public class WeldApplicationContainer implements ApplicationContainer<Object> {

public WeldApplicationContainer() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@
import static org.jboss.weld.manager.BeanManagerLookupService.lookupBeanManager;

@Service
public class WeldDeployer extends SimpleDeployer<WeldContainer, WeldApplicationContainer>
implements PostConstruct, EventListener {
public class WeldDeployer extends SimpleDeployer<WeldContainer, WeldApplicationContainer> implements PostConstruct, EventListener {

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

Expand Down Expand Up @@ -367,21 +366,6 @@ public void event(Event<?> event) {
}
}

@Override
protected void generateArtifacts(DeploymentContext dc) throws DeploymentException {

}

@Override
protected void cleanArtifacts(DeploymentContext dc) throws DeploymentException {

}

@Override
public <V> V loadMetaData(Class<V> type, DeploymentContext context) {
return null;
}

public BeanDeploymentArchive getBeanDeploymentArchiveForBundle(BundleDescriptor bundle) {
LOG.log(FINEST, "getBeanDeploymentArchiveForBundle(bundle.class={0})", bundle.getClass());
return bundleToBeanDeploymentArchive.get(bundle);
Expand Down
Loading