4 Replies Latest reply on Dec 5, 2014 6:13 AM by chrkoelle

    Retrieve Wildfly version number from application code

    chrkoelle

      Hi

       

      Is it somehow possible to retrieve version information of the application server at runtime in the code of an application deployed in the server?

       

      Thanks

      Christian

        • 1. Re: Retrieve Wildfly version number from application code
          jaysensharma

          May be you can try using the MBean approach to get that information:

           

          For WildFly 8.1 try the following kind of MBean code from inside the WildFly container, You can use the same MBean to get this information remotely as well.:

           

           

           

          <%@ page import="javax.management.*,javax.management.remote.*" %>
          <%
                         try{  
                               MBeanServer mbeanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer();
                               ObjectName objectName=new ObjectName("jboss.as:management-root=server");
          
                               String releaseCodename = (String) mbeanServer.getAttribute(objectName, "releaseCodename");
                               String releaseVersion = (String) mbeanServer.getAttribute(objectName, "releaseVersion");
          
                               out.println("<center><h1>"+ releaseCodename + " - "+ releaseVersion+"</h1></center>");
                            }
                         catch(Exception e)
                            {
                               e.printStackTrace();
                            }
          %>
          
          
          • 2. Re: Retrieve Wildfly version number from application code
            chrkoelle

            Thank you very much. That works for me.

            • 3. Re: Retrieve Wildfly version number from application code
              ctomc

              Other option would be to directly ask for it.

               

              add dependency to module org.jboss.as.version to your deployments jboss-deployment-structure.xml or manifest.mf

               

              and than you can get version info by simply looking up constants on class org.jboss.as.version.Version

              1 of 1 people found this helpful
              • 4. Re: Retrieve Wildfly version number from application code
                chrkoelle

                Yes, thank you. That works also.