We used to query the active session count by using the following code up to JBoss 7:
ObjectName name = new ObjectName(jboss.web:type=Manager,path=/MyWebApp,host=default-host);
MBeanServer jboss = MBeanServerLocator.locateJBoss();
this.sessions = new Long((Integer) jboss.getAttribute(name, "activeSessions"));
That no longer works with JBoss Wildfly. I can't really find the proper documentation to access the same information with the current version of JBoss AS.
I've come across some links like http://blog.akquinet.de/2014/09/15/monitoring-the-jboss-eap-wildfly-application-server-with-the-command-line-interface-cli/ which imply a totally different location of that information – but I can't figure out how to access it via Java code.
/deployment=example.ear/subdeployment=example-web.war/subsystem=under
The old reference to -Dorg.apache.tomcat.util.ENABLE_MODELER=true
from JBoss 7 didn't help either. My older question via MBean "jboss.web:type=Manager,path=/,host=localhost" not found doesn't work anymore.
Assuming you are deploying a WAR file; the
ObjectName
should be something similar tojboss.as:deployment=YourWAR.war,subsystem=undertow
.Note that in case of WildFly - management native port is
9990
instead of9999
.If you are using maven, add the following dependency.
Sample example:
If your WAR file is bundled inside an EAR file; then the
ObjectName
shall be something similar tojboss.as:deployment=YourEAR.ear,subdeployment=YourWAR.war,subsystem=undertow"
For more details, see https://docs.jboss.org/author/display/WFLY8/JMX+subsystem+configuration