RFR: 7455: Add support for jolokia JMX service connection [v8]

Martin Skarsaune duke at openjdk.org
Thu May 2 18:20:16 UTC 2024


On Tue, 6 Feb 2024 21:05:21 GMT, Alex Macdonald <aptmac at openjdk.org> wrote:

>> Update 2: So https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.rjmx.ext/META-INF/services/javax.management.remote.JMXConnectorProvider is not detected by `javax.management.remote.JMXConnectorFactory`' s classloader. 
>> I also tried to use  `org.openjdk.jmc.rjmx.common.internal.RJMXConnection` 's classloader, but that no longer works as the `.ext` module is not visible from `rjmx.common`  (?). 
>> 
>> 		Map<String, Object> envCopy = new HashMap<>(env);
>> 		envCopy.put(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER, this.getClass().getClassLoader());
>> 
>> 
>> 
>> Bottom line seems to me that the JMX protocol extension mechanism no longer works in JMC 9 (?)
>
>> Update 2: So https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.rjmx.ext/META-INF/services/javax.management.remote.JMXConnectorProvider is not detected by `javax.management.remote.JMXConnectorFactory`' s classloader. I also tried to use `org.openjdk.jmc.rjmx.common.internal.RJMXConnection` 's classloader, but that no longer works as the `.ext` module is not visible from `rjmx.common` (?).
>> 
>> ```
>> 		Map<String, Object> envCopy = new HashMap<>(env);
>> 		envCopy.put(JMXConnectorFactory.PROTOCOL_PROVIDER_CLASS_LOADER, this.getClass().getClassLoader());
>> ```
>> 
>> Bottom line seems to me that the JMX protocol extension mechanism no longer works in JMC 9 (?)
> 
> Hi! What you mentioned about how the `.ext` module is not visible from common is what I think the issue here is. When bringing over the bulk of the rjmx code from jmc/application to jmc/core one of the problems I faced was how to get the Services loaded by the core-side code if they are only visible in jmc/application. For the rjmx services, I came up with an initializer class [[0]](https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.rjmx/src/main/java/org/openjdk/jmc/rjmx/internal/ServiceFactoryInitializer.java#L49) that looks at the `rjmx.service` extension and adds them to a List to be consumed by `ServerHandle` when creating a `ConnectionHandle`. This way the services can be passed from jmc/application into jmc/core through the ConnectionHandle.
> 
> Unfortunately it looks like I only considered the case of the rjmx.service extension, and not rjmx.ext. I think the `ServiceFactoryInitializer` is probably the best place to start looking to fix this, and making sure it can also handle the other valid extension points.
> 
> Edit: I've opened a bug for this on the JMC jira: https://bugs.openjdk.org/browse/JMC-8178
> 
> [0] https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.rjmx/src/main/java/org/openjdk/jmc/rjmx/internal/ServiceFactoryInitializer.java#L49

@aptmac : I believe I have addressed all comments so far, apart from enabling coverage test (next on my list). 
Status:
Test connection ✅ 
Do flight recording ✅ 
Open JMX console 🔴  - here I only get a spinner. I have tried to debug, but I'm struggling a bit with my debug setup

-------------

PR Comment: https://git.openjdk.org/jmc/pull/548#issuecomment-1986831677


More information about the jmc-dev mailing list