How to programmatically obtain the release version from WildFly

140 views
Skip to first unread message

Rainer Hochreiter

unread,
Jun 22, 2023, 3:57:12 AM6/22/23
to WildFly
I want to show release version of WildFly in my web application.

Descriptions found do not work, because they are outdated for current WildFly versions.
I tried to get the list of WildFly MBeans but there is no "jboss.as" bean as show in jconsole:
So how can I retrieve productName and productVersion as shown in jconsole?

Thanks in advance,
Rainer

Tomaž Cerar

unread,
Jun 22, 2023, 4:42:17 AM6/22/23
to Rainer Hochreiter, WildFly

--
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/f500be46-21a0-49a3-8075-6bb9f570f3a5n%40googlegroups.com.

Alexey Makhmutov

unread,
Jun 22, 2023, 7:03:49 AM6/22/23
to WildFly
If you don't use the 'rbac' security model for the server, then you could also use the JMX to obtain it from inside the server like in a following example:

import javax.management.*;

private String getVersion() throws Exception {
  ObjectName rootNameObjectName = new ObjectName("jboss.as:management-root=server");
  for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) {
     if (server.isRegistered(rootNameObjectName)) {
       return (String)server.getAttribute(rootNameObjectName, "product-version");
     }
  }
  return null;
}

Thanks,
Alexey

четверг, 22 июня 2023 г. в 10:57:12 UTC+3, Rainer Hochreiter:

Rainer Hochreiter

unread,
Jun 22, 2023, 10:24:12 AM6/22/23
to WildFly
Thanks for this hint - it works perfectly!
Regards,
Rainer
Reply all
Reply to author
Forward
0 new messages