0 Replies Latest reply on Mar 19, 2013 5:22 AM by dvayanu

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

    dvayanu

      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