RFR: 7455: Add support for jolokia JMX service connection [v8]
Alex Macdonald
aptmac at openjdk.org
Tue Feb 6 21:08:58 UTC 2024
On Tue, 6 Feb 2024 08:48:44 GMT, Martin Skarsaune <duke 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 (?)
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.
[0] https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.rjmx/src/main/java/org/openjdk/jmc/rjmx/internal/ServiceFactoryInitializer.java#L49
-------------
PR Comment: https://git.openjdk.org/jmc/pull/548#issuecomment-1930749297
More information about the jmc-dev
mailing list