[jboss-jira] [JBoss JIRA] (WFLY-5676) Wrong WildFly version when WildFly standalone is started

Stefan Lindner (JIRA) issues at jboss.org
Wed Nov 18 11:11:00 EST 2015


    [ https://issues.jboss.org/browse/WFLY-5676?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13130370#comment-13130370 ] 

Stefan Lindner commented on WFLY-5676:
--------------------------------------

Thank you for your hint! If someone else needs this: here is a portable solution independent of any jboss/wildfly jars during compile time

{code:java}
try {
	Class<?> wildflyModuleClass = Class.forName("org.jboss.modules.Module");
	Object moduleLoader = wildflyModuleClass.getMethod("getBootModuleLoader").invoke(null);

	String jbossHomeDir = System.getProperty("jboss.home.dir");
	if (jbossHomeDir != null && jbossHomeDir.length() > 0) {
		Class<?> wildflyProductConfigClass = Class.forName("org.jboss.as.version.ProductConfig");

		Object productconfig = null;

		for (Constructor<?> constr : wildflyProductConfigClass.getConstructors()) {
			try {
				productconfig = constr.newInstance(moduleLoader, jbossHomeDir, null);
				if (productconfig != null)
					break;
			} catch (Exception x) {
				// ignore it, try next Constructor
			}
		}

		if (productconfig != null) {
			Method method = productconfig.getClass().getMethod("getProductVersion");
			Object o = method.invoke(productconfig);

			if (o != null && o instanceof String) {
				String version = (String)o;

				jbossMajorVersion = Integer.parseInt(version.split("\\.")[0]);
				jbossMinorVersion = Integer.parseInt(version.split("\\.")[1]);
			}
		}				
	}
} catch (Throwable e) {
	// Not a Wildfly 9+
}
{code}



> Wrong WildFly version when WildFly standalone is started
> --------------------------------------------------------
>
>                 Key: WFLY-5676
>                 URL: https://issues.jboss.org/browse/WFLY-5676
>             Project: WildFly
>          Issue Type: Bug
>          Components: Server
>    Affects Versions: 9.0.2.Final
>            Reporter: Stefan Lindner
>            Assignee: Jason Greene
>
> See also Bug WFLY-2544
> Wildfly 9.2.0 final reports Version 1.0.2 if asked from within Java-application (consulting org.jboss.as.version.Version):
> 	AS_VERSION = 1.0.2.Final
> 	AS_RELEASE_CODENAME = Kenny
> Yes, we could test if it's "kenny" and the aha: 1.0.2 is 9.0.2 but this sounds strange



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list