JBoss Community

Can not load com.sun.management.UnixOperatingSystemMXBean in JBoss 7 AS

created by Leon Rosenberg in Beginner's Corner - View the full discussion

Hello,

 

I need to access the OperatingSystem MBean to read some values out of it, like open files. This works by

ManagementFactory.getOperatingSystemMXBean();

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):

OperatingSystemMXBean mxBean = ManagementFactory.getOperatingSystemMXBean();

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?

 

regards

Leon

Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community