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

Alex Macdonald aptmac 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

Nice! I gave this a bit of a look and something interesting is going on but I can't tell just what yet. If I'm running the built application and connecting to jolokia I can confirm that JFR looks to be working correctly, and that the JMX Console pages are working.

But, if I'm running it through Eclipse using our run configurations then the JMX Console pages are all blank (and this is true for any JVM and not just the one with jolokia attached to it). At the moment it's not obvious to me what's happening, the ConsoleEditor is running through the code okay to create the pages but for some reason nothing is showing up. I'll poke around a bit more when I can find some time.

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

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


More information about the jmc-dev mailing list