I need to access the OperatingSystem MBean to read some values out of it, like open files. This works by
However this method returns OperatingSystemMXBean which has limited functionality comparing to UnixOperatingSystemMXBean. So, when on Unix, I'm trying to load the class directly, and call its methods on the returned objects, like this (simplified):
Class clazz = Class.forName("com.sun.management.UnixOperatingSystemMXBean");
long openFiles = clazz.getMethod("getOpenFileDescriptorCount").invoke(mxBean);
This works in tomcat and other containers as well as in a standalone java application. However, it produces a ClassNotFound Exception in JBoss. I assue this is because UnixOperatingSystemMXBean is in customiz sun packages. Is there any workaround to get this class loaded?