This is an automated email from the ASF dual-hosted git repository. duncangrant pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
The following commit(s) were added to refs/heads/master by this push: new 0625c77 BROOKLYN-626: fix jmxmp new aa67e6d Merge pull request #1097 from aledsage/fix/BROOkLYN-626 0625c77 is described below commit 0625c77023324ad7f541080bd006a43fd197b5ea Author: Aled Sage <aled.s...@gmail.com> AuthorDate: Tue May 12 10:52:15 2020 +0100 BROOKLYN-626: fix jmxmp --- karaf/features/src/main/feature/feature.xml | 1 - .../java/org/apache/brooklyn/feed/jmx/JmxHelper.java | 17 +++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/karaf/features/src/main/feature/feature.xml b/karaf/features/src/main/feature/feature.xml index eafcfa9..9157b1d 100644 --- a/karaf/features/src/main/feature/feature.xml +++ b/karaf/features/src/main/feature/feature.xml @@ -254,7 +254,6 @@ <feature name="brooklyn-software-base" version="${project.version}" description="Brooklyn Software Base"> <bundle>mvn:org.apache.brooklyn/brooklyn-software-base/${project.version}</bundle> - <bundle dependency="true">wrap:mvn:org.glassfish.external/opendmk_jmxremote_optional_jar/${opendmk_jmxremote_optional_jar.version}$Import-Package=javax.management.openmbean,*</bundle> <feature>brooklyn-software-winrm</feature> <feature>brooklyn-policy</feature> </feature> diff --git a/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxHelper.java b/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxHelper.java index dd93d72..0fd1384 100644 --- a/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxHelper.java +++ b/software/base/src/main/java/org/apache/brooklyn/feed/jmx/JmxHelper.java @@ -306,16 +306,13 @@ public class JmxHelper { * Handles loading the {@link JMXConnector} in OSGi, where we need to supply the classloader. */ public static JMXConnector newConnector(JMXServiceURL url, Map<String, ?> env) throws IOException { - Map<String, Object> envCopy = MutableMap.copyOf(env); - String protocol = url.getProtocol(); - if ("jmxmp".equalsIgnoreCase(protocol)) { - envCopy.put(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER, javax.management.remote.jmxmp.JMXMPConnector.class.getClassLoader()); - envCopy.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, javax.management.remote.jmxmp.JMXMPConnector.class.getClassLoader()); - } else if ("rmi".equalsIgnoreCase(protocol)) { - envCopy.put(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER, javax.management.remote.rmi.RMIConnector.class.getClassLoader()); - envCopy.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER, javax.management.remote.rmi.RMIConnector.class.getClassLoader()); - } - return JMXConnectorFactory.connect(url, envCopy); + // Fix for BROOKLYN-626 + // In Karaf 4.2.8, they added jmxmp support via a jar in boot/lib/ + // This means it's on the root classpath without it being a proper/normal bundle! + // We need to use the classes from that ClassLoader rather than our own bundle, otherwise + // we get ClassCastException when we deserialize a jmxmp message and try to cast it to + // `Message` from the other ClassLoader. + return JMXConnectorFactory.connect(url, env); } @SuppressWarnings({ "rawtypes", "unchecked" })