Don Collett
Don Collett

Reputation: 29

How can an application tell if its running on IBM WebSphere Application Server or IBM WebSphere Liberty Profile?

I'm working with an application that needs to know if its running on WAS or its running on Liberty Profile.

On WAS, it has to make a call to an Admin API but on Liberty Profile it has to use JNDI to do the same thing.

Upvotes: 3

Views: 685

Answers (1)

Andy Guibert
Andy Guibert

Reputation: 42926

One way that an application can tell if it's running on Liberty is to search for the following MBean: WebSphere:name=com.ibm.ws.config.mbeans.FeatureListMBean

Here is a list of all MBeans provided in Liberty

Here is a code example of how you might query for the MBean:

private boolean isLiberty() throws Exception {
    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    ObjectName obn = new ObjectName("WebSphere:name=com.ibm.websphere.config.mbeans.FeatureListMBean");
    Set<ObjectInstance> s = mbs.queryMBeans(obn, null);
    return s.size() > 0;
}

Upvotes: 1

Related Questions