From 8b21596d42b222ff510873e44acc5446d2ca1aac Mon Sep 17 00:00:00 2001 From: Markus Jung Date: Fri, 2 Feb 2024 14:28:53 +0100 Subject: [PATCH] [TOMEE-4295] load mp-common via codesource instead of scanning for lib jar --- .../TomEEMicroProfileListener.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java index 83dcae0bbe5..004c6fb044c 100644 --- a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java +++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java @@ -30,7 +30,6 @@ import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; import org.apache.tomee.catalina.event.AfterApplicationCreated; -import org.apache.tomee.installer.Paths; import org.apache.tomee.microprofile.health.MicroProfileHealthChecksEndpoint; import org.apache.tomee.microprofile.openapi.MicroProfileOpenApiRegistration; import org.apache.tomee.microprofile.opentracing.MicroProfileOpenTracingExceptionMapper; @@ -42,7 +41,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.net.MalformedURLException; import java.net.URL; import java.security.CodeSource; import java.util.Collection; @@ -58,10 +56,6 @@ public class TomEEMicroProfileListener { private static final Logger LOGGER = Logger.getInstance(LogCategory.OPENEJB.createChild("tomcat"), TomEEMicroProfileListener.class); - private static final String[] MICROPROFILE_LIBS_IMPLS_PREFIXES = new String[]{ - "mp-common" - }; - private static final String[] MICROPROFILE_EXTENSIONS = new String[]{ "org.apache.tomee.microprofile.jwt.cdi.MPJWTCDIExtension", "org.apache.cxf.microprofile.client.cdi.RestClientExtension", @@ -98,17 +92,8 @@ public void enhanceScannableUrls(@Observes final EnhanceScannableUrlsEvent enhan } } - final Paths paths = new Paths(new File(System.getProperty("openejb.home"))); - for (final String prefix : MICROPROFILE_LIBS_IMPLS_PREFIXES) { - final File file = paths.findTomEELibJar(prefix); - if (file != null) { - try { - containerUrls.add(file.toURI().toURL()); - } catch (final MalformedURLException e) { - // ignored - } - } - } + // Add mp-common jar so classes like MicroProfileHealthChecksEndpoint are scanned as well + containerUrls.add(getClass().getProtectionDomain().getCodeSource().getLocation()); SystemInstance.get().setProperty("openejb.cxf-rs.cache-application", "false"); }