-
1. Re: How to detect Wildfly version
ctomc Jul 1, 2014 9:46 AM (in response to lindner)1 of 1 people found this helpfulThat should probably still work.
but that is not proper way of detecting it.
you are looking for class org.jboss.as.version.Version that is part of module "org.jboss.as.version" which you should depend on if you want to access this.
that is the same also in AS7.
-
2. Re: How to detect Wildfly version
lindner Jul 3, 2014 2:36 AM (in response to ctomc)Thank you Tomaz,
and for all readers with the same question: you will need module "org.jboss.as.standalone" too
-
3. Re: How to detect Wildfly version
ehugonnet Nov 18, 2015 9:27 AM (in response to lindner)Here is what you can do in a servlet :
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ... ProductConfig config = new ProductConfig(ModuleLoader.forClassLoader(this.getClass().getClassLoader()), System.getProperty(ServerEnvironment.HOME_DIR, null), null); ... }
You also have to create a jboss-deployment-structure.xml file with dependencies on
- org.jboss.as.version
- org.jboss.as.server
- org.jboss.modules
Be careful as you are using internal API so they might break in the future.
I've attached a simple war example.
-
WildflyVersion.tar.gz 3.5 KB
-
4. Re: How to detect Wildfly version
rcd Nov 18, 2015 5:30 PM (in response to ehugonnet)Indeed, the module org.jboss.as.version is marked as private, and recent versions of WildFly will log warnings if your deployment uses it. Fortunately, there is another way to obtain the version using JMX that requires no additional dependencies.
Use java.lang.management.ManagementFactory#getPlatformMBeanServer() to obtain a MBeanServer, then perform a lookup on object name "jboss.as:management-root=server", attribute "productVersion". This will return the WildFly Full version. There is another attribute (can't remember the name of it) that returns the WildFly Core version, if you're interested in that. Our code does this and it works great, currently running on WildFly 10.0.0.CR2.
-
5. Re: How to detect Wildfly version
ehugonnet Nov 19, 2015 9:19 AM (in response to lindner)JMX may not be there as it is an extension. You could connect using the controller-client API (or the cli or just a REST call) to the management API and the version is available there too.
-
6. Re: How to detect Wildfly version
a-i-ks Jun 14, 2016 9:31 AM (in response to lindner)Is there a possibility to detect the WildFly version without starting the server? I need to detect the version as a prelaunch check before the server startup?
-
7. Re: How to detect Wildfly version
ctomc Jun 14, 2016 6:27 PM (in response to a-i-ks)Andre Iske wrote:
Is there a possibility to detect the WildFly version without starting the server? I need to detect the version as a prelaunch check before the server startup?
Look into org.jboss.as.version module.
open the wildfly-version.jar and look at its manifest.