From 9a4c23fd800e30a3e582ccdec56dedca105a341d Mon Sep 17 00:00:00 2001 From: Eduard-Gabriel Munteanu Date: Fri, 25 Oct 2024 11:05:30 +0300 Subject: [PATCH] Port to machine agents shipping Java 11 Java 11 does not supply a SOAP implementation, unlike Java 8. A choice was made to go with the latest libraries from the Eclipse Metro project to avoid security vulnerabilities associated with old and deprecated versions. This breaks compatibility with Java 8 and Java 11+ is now required, which explains bumping the major version of the extension. This change also deals with issues resulting from the way the machine agent loads extensions, along with interactions between thread pools and class loaders in Java 9 and above. It ensures SOAP handling initialization does not happen in the constructor of the extension's main class, otherwise the class loader will fail to locate certain classes when launched via the machine agent (although tests pass). --- CHANGELOG.md | 4 +++- pom.xml | 16 +++++++++++++--- .../extensions/datapower/DataPowerMonitor.java | 7 +++---- .../datapower/util/SoapMessageUtil.java | 14 +++++++------- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bde4aa1..f377167 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,4 +32,6 @@ ### 2.0.1: * Updated extension commons to 2.2.13. - \ No newline at end of file + +### 3.0.0: +* Ported to machine agents shipping Java 11, which is now a minimum requirement. diff --git a/pom.xml b/pom.xml index fcad820..04ec4e0 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.appdynamics.extensions datapower-monitoring-extension - 2.0.1 + 3.0.0 jar datapower-monitoring-extension http://maven.apache.org @@ -48,6 +48,16 @@ 4.13.1 test + + jakarta.xml.soap + jakarta.xml.soap-api + 3.0.2 + + + com.sun.xml.messaging.saaj + saaj-impl + 3.0.4 + @@ -58,8 +68,8 @@ maven-compiler-plugin 2.3.2 - 1.8 - 1.8 + 11 + 11 diff --git a/src/main/java/com/appdynamics/extensions/datapower/DataPowerMonitor.java b/src/main/java/com/appdynamics/extensions/datapower/DataPowerMonitor.java index 4b3d426..7ed5f1c 100644 --- a/src/main/java/com/appdynamics/extensions/datapower/DataPowerMonitor.java +++ b/src/main/java/com/appdynamics/extensions/datapower/DataPowerMonitor.java @@ -37,10 +37,6 @@ public class DataPowerMonitor extends ABaseMonitor { private MonitorContextConfiguration configuration; - public DataPowerMonitor() { - soapMessageUtil = new SoapMessageUtil(); - } - protected String getDefaultMetricPrefix() { return METRIC_PREFIX; } @@ -98,6 +94,9 @@ protected void initializeMoreStuff(Map args) { configuration = getContextConfiguration(); logger.info("initializing metric.xml file"); configuration.setMetricXml(args.get("metric-file"), Stat.Stats.class); + + // Keep this here instead of the constructor to ensure the proper class loader is used. + soapMessageUtil = new SoapMessageUtil(); } private boolean useBulkApi(Map server) { diff --git a/src/main/java/com/appdynamics/extensions/datapower/util/SoapMessageUtil.java b/src/main/java/com/appdynamics/extensions/datapower/util/SoapMessageUtil.java index 7a4c1b2..a07c9d4 100644 --- a/src/main/java/com/appdynamics/extensions/datapower/util/SoapMessageUtil.java +++ b/src/main/java/com/appdynamics/extensions/datapower/util/SoapMessageUtil.java @@ -12,13 +12,13 @@ import org.w3c.dom.NodeList; import javax.xml.namespace.QName; -import javax.xml.soap.MessageFactory; -import javax.xml.soap.SOAPBody; -import javax.xml.soap.SOAPElement; -import javax.xml.soap.SOAPEnvelope; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPMessage; -import javax.xml.soap.SOAPPart; +import jakarta.xml.soap.MessageFactory; +import jakarta.xml.soap.SOAPBody; +import jakarta.xml.soap.SOAPElement; +import jakarta.xml.soap.SOAPEnvelope; +import jakarta.xml.soap.SOAPException; +import jakarta.xml.soap.SOAPMessage; +import jakarta.xml.soap.SOAPPart; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.Collection;