Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 676
Don Collett Avatar asked Nov 25 '25 17:11

Don Collett


1 Answers

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;
}
like image 172
Andy Guibert Avatar answered Nov 27 '25 09:11

Andy Guibert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!