5 Replies Latest reply on Aug 4, 2017 7:25 AM by mayerw01

    Detecting Server Type

    mithel

      I've got a routine that detects and reports if my application is running on GlassFish, Tomcat or WebSphere but I'm having trouble detecting if the application is running on Wildfly.  If I'm running local (launched from Eclipse) I can check the system property "program.name" and detect "Wildfly 10" but if Wildfly is running as a service on a server this property doesn't seem to exist.

       

      Also, where is it documented on how to set a property somewhere in one of the configuration files? (this would be a work around to set our own property that we could query)

       

      Does anyone have a good solution?

        • 1. Re: Detecting Server Type
          claudio4j

          You can try using a system property or detect a loaded class

          1) detect a system property, example: jboss.home.dir

          2) detect a loaded class, example: org.jboss.logmanager.Logger

          • 2. Re: Detecting Server Type
            mithel

            I've already tried jboss.bind.address but that's not working on the server that is running Wildfly as a service.  I could try jboss.home.dir but would that be any more reliable?

            • 3. Re: Detecting Server Type
              ctomc

              do you need to know only if you are on WildFly or more details like exact version, etc

              as testing if you are on WildFly itself should be simple by checking presence of few system properties, but for exact version you would need to look into jars, or load "Version" class from org.jboss.as.version module.

              • 4. Re: Detecting Server Type
                mithel

                Most important is to know that it is Wildfly.  Bonus points for knowing which version (at least major version).  This is handy for apps to report this when running in an environment with thousands of servers.

                • 5. Re: Detecting Server Type
                  mayerw01

                  You can get these details via cli like:

                   

                  /jboss-cli.sh  --connect --controller={hostname} --user={username} --command='version'

                   

                  If you need to catch this information in your program you may use the Advanced CLI scripting (Advanced CLI scripting with Groovy, Rhino, Jython, etc. )