How to programmatically get version in JBoss AS 5.1?

Does anyone know how to programmatically get the server version number in JBossAS 5.1?

JBossAS 4.2 had org.jboss.Version, with getMajor()and methods getMinor(), but this does not seem to exist in 5.1.

+3
source share
2 answers

In the end, I decided to decompile the class Versionfrom JBoss 4.2 to see what it was doing and see if it was possible to modify the result in JBoss 5. The end result was to load the resource /org/jboss/version.propertiesinto Properties, and then read the version.majorand properties version.minor. Beats me why they couldn’t just leave the class Versionthere, but there you go.

0
source

. , JMX, Website, . MBean : jboss.system: type = server. :

%JBOSS_HOME%\bin>twiddle get jboss.system:type=Server VersionNumber
VersionNumber=5.1.0.GA

( jmx):

MBeanServerConnection server = (MBeanServerConnection)new InitialContext().lookup("jmx/rmi/RMIAdaptor");
ObjectName on = new ObjectName("jboss.system:type=Server");
Object ver = server.getAttribute(on, "VersionNumber");

. , org.jboss.Main, , JAR file spec. :

    org.jboss.Main m=new Main();   //at least a jboss class loaded. not needed in the container
    Package p=Package.getPackage("org.jboss");
    System.out.println("Major=" + p.getImplementationVersion().split("\\.")[0]);
    System.out.println("Minor=" + p.getImplementationVersion().split("\\.")[1]);

: .

+4

All Articles