JMXConnectorFactory.connect to standalone ActiveMQ Artemis server

185 views
Skip to first unread message

Harald Ueland

unread,
Mar 21, 2024, 3:30:16 PM3/21/24
to WildFly
Hi, I'm struggling to get JMX management to standalone Artemis server (running on same server as Wildfly) working with Wildfly 29.0.1.Final. This works perfectly running Wildfly 23.0.1.FInal.

My code:

JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"),

Map.of(JMXConnector.CREDENTIALS,

new String[] { "user", "pass" }));


Following error occurs:


Caused by: javax.naming.NameNotFoundException: WFNAM00004: Name "/localhost:1099/jmxrmi" is not found
        at org.wildfly....@2.0.1.Final//org.wildfly.naming.client.util.NamingUtils$1.lookupNative(NamingUtils.java:95)
        at org.wildfly....@2.0.1.Final//org.wildfly.naming.client.AbstractContext.lookup(AbstractContext.java:84)
        at org.wildfly....@2.0.1.Final//org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:144)
        at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
        at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
        at java.management.rmi/javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1839)
        at java.management.rmi/javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1813)

        at java.management.rmi/javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:302)


Help is very appreciated!

Bartosz Baranowski

unread,
Mar 22, 2024, 5:29:26 AM3/22/24
to WildFly
I might be wrong, but AFAIR by default WFLY does not enable JMX/RMI agent, instead it has its own protocol, if you want, you can enable it by specifying proper jAVA_OPTS to server.

https://www.mastertheboss.com/jbossas/monitoring/how-to-get-the-list-of-mbeans-in-jboss-or-wildfy/
https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html

Harald Ueland

unread,
Mar 22, 2024, 5:50:30 AM3/22/24
to WildFly
Hi,

I'm not trying to enable JMX/RMI agent in Wildfly. I'm just trying to get JMX management of remote ActiveMQ Artemis broker. I'm using it to monitor queues in my Wildfly application. And as mentioned, the exact same code worked perfectly with Wildfly 23.0.1. Maybe something changed from wildfly-naming-client 1.x to wildfly-naming-client 2.x?

Bartosz Baranowski

unread,
Mar 22, 2024, 6:28:46 AM3/22/24
to WildFly


https://docs.oracle.com/en/java/javase/17/management/monitoring-and-management-using-jmx-technology.html#GUID-1C798094-1CC3-4804-B4F2-0DCF2E0030CF
Connecting to the JMX Agent Programmatically

After you have enabled the JMX agent, a client can use the following URL to access the monitoring service:

Copy
service:jmx:rmi:///jndi/rmi://hostName:portNum/jmxrmi

Also:

Local Monitoring and Management

Earlier while starting the Java VM or Java application, you set the following property to allow the JMX client access to a local Java VM:

Copy
com.sun.management.jmxremote

Bartosz Baranowski

unread,
Mar 22, 2024, 6:31:20 AM3/22/24
to WildFly

Emmanuel Hugonnet

unread,
Mar 22, 2024, 6:49:14 AM3/22/24
to Harald Ueland, WildFly
I think the issue lies in which InitialContext is used.
I'm wondering if in 23 you are getting a WildFlyRootContext.
I guess you would like to use a diffrent naming context in that case.

Emmanuel

Le 22/03/2024 à 10:50, Harald Ueland a écrit :
> Hi,
>
> I'm not trying to enable JMX/RMI agent in Wildfly. I'm just trying to get JMX management of remote ActiveMQ Artemis broker. I'm using it
> to monitor queues in my Wildfly application. And as mentioned, the exact same code worked perfectly with Wildfly 23.0.1. Maybe something
> changed from wildfly-naming-client 1.x to wildfly-naming-client 2.x?
>
> fredag 22. mars 2024 kl. 10:29:26 UTC+1 skrev Bartosz Baranowski:
>
> I might be wrong, but AFAIR by default WFLY does not enable JMX/RMI agent, instead it has its own protocol, if you want, you can
> enable it by specifying proper jAVA_OPTS to server.
>
> https://www.mastertheboss.com/jbossas/monitoring/how-to-get-the-list-of-mbeans-in-jboss-or-wildfy/
> https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html
> On Thursday, March 21, 2024 at 8:30:16 PM UTC+1 Harald Ueland wrote:
>
> Hi, I'm struggling to get JMX management to standalone Artemis server (running on same server as Wildfly) working with Wildfly
> 29.0.1.Final. This works perfectly running Wildfly 23.0.1.FInal.
>
> My code:
>
> JMXConnectorFactory.connect(new JMXServiceURL(/"/service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"),
>
> Map.of(JMXConnector.CREDENTIALS,
>
> new String[] { "user", "pass" }));
>
> Following error occurs:
>
> Caused by: javax.naming.NameNotFoundException: WFNAM00004: Name "/localhost:1099/jmxrmi" is not found
>         at org.wildfly....@2.0.1.Final//org.wildfly.naming.client.util.NamingUtils$1.lookupNative(NamingUtils.java:95)
>         at org.wildfly....@2.0.1.Final//org.wildfly.naming.client.AbstractContext.lookup(AbstractContext.java:84)
>         at org.wildfly....@2.0.1.Final//org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:144)
>         at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
>         at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
>         at java.management.rmi/javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1839)
>         at java.management.rmi/javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1813)
>
>         at java.management.rmi/javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:302)
>
>
> Help is very appreciated!
>
> --
> You received this message because you are subscribed to the Google Groups "WildFly" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wildfly/abcfade5-c9bf-4521-8bcd-c9be1f5c1616n%40googlegroups.com
> <https://groups.google.com/d/msgid/wildfly/abcfade5-c9bf-4521-8bcd-c9be1f5c1616n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Emmanuel Hugonnet

unread,
Mar 22, 2024, 6:54:09 AM3/22/24
to Harald Ueland, WildFly
I think you should pass a different  INITIAL_CONTEXT_FACTORY in your environment for example.
Map.of(JMXConnector.CREDENTIALS,

        new String[] { "user", "pass" }),
       INITIAL_CONTEXT_FACTORY, "whatever used to work" );

Emmanuel

Harald Ueland

unread,
Mar 22, 2024, 8:04:58 AM3/22/24
to WildFly
I'm trying to use INITIAL_CONTEXT_FACTORY "com.sun.jndi.rmi.registry.RegistryContextFactory", but then I get "Caused by: java.lang.ClassNotFoundException: com.sun.jndi.rmi.registry.RegistryContextFactory". Seems like Wildfly does not have access to RMI classes, and hence cannot resolve Context for rmi: name scheme.  I'm running Wildfly inside OpenJDK 11 JRE.

Bartosz Baranowski

unread,
Mar 22, 2024, 8:27:50 AM3/22/24
to WildFly

Emmanuel Hugonnet

unread,
Mar 22, 2024, 8:42:34 AM3/22/24
to Harald Ueland, WildFly
I think that means your deployment needs a dependency on this jdk module via a jboss-deployment-strcuture or manifest
> <https://groups.google.com/d/msgid/wildfly/abcfade5-c9bf-4521-8bcd-c9be1f5c1616n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
> >
>
> --
> You received this message because you are subscribed to the Google Groups "WildFly" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/wildfly/5a1112eb-9f4c-4948-998a-b735b0da3a93n%40googlegroups.com
> <https://groups.google.com/d/msgid/wildfly/5a1112eb-9f4c-4948-998a-b735b0da3a93n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Harald Ueland

unread,
Mar 22, 2024, 8:47:51 AM3/22/24
to WildFly
Yes! Adding <path name="com/sun/jndi/url/rmi" /> to jboss-deployment-structure.xml fixed the issue!

Thank you so much!

Reply all
Reply to author
Forward
0 new messages