Can you try calling getLoadedClassCount() directly like Lloyd suggested
and see what you get?
I suspect some class loading issues here because since all MXBeans
are interfaces, it is difficult to understand why it would throw
an IllegalArgumentException.
Can you post the entire stack trace?
-Kedar
Jennifer Chou wrote:
> Hi Lloyd,
>
> It's part of our monitoring design. All the stats are retrieved from a
> TreeNode structure. I'm creating a MethodInvoker TreeNode
> "loadedClassCount" so that getLoadedClassCount() will get invoked and
> return a value when a client asks for node.getValue().
> TreeNode tn = TreeNodeFactory.createMethodInvoker(nodeName, clBean,
> "jvm", method);
>
> public static TreeNode createMethodInvoker (String name, Object instance,
> String category, Method m){
>
> I don't want to store the clBean.getLoadedClassCount() on the treeNode
> as it is because that value is dynamic.
>
> Jennifer
>
> Lloyd Chambers wrote:
>> Jennifer,
>>
>> Why are you introspecting the method?
>>
>> java.lang.management.ClassLoadingMXBean clBean =
>> ManagementFactory.getClassLoadingMXBean();
>> int count = clBean.getLoadedClassCount();
>>
>> ?
>>
>> Lloyd
>>
>>
>>
>> On Sep 4, 2008, at 4:17 PM, Jennifer Chou wrote:
>>
>>> Hi,
>>>
>>> I'm trying use method.invoke(..) on the MXBeans but I'm getting
>>> IllegalAccessException on some but not all the MXBeans. Anybody know
>>> why? And how to get around this problem?
>>>
>>> java.lang.management.ClassLoadingMXBean clBean =
>>> ManagementFactory.getClassLoadingMXBean();
>>> java.lang.reflect.Method method =
>>> clBean.getClass().getMethod("getLoadedClassCount", (Class[]) null);
>>> method.invoke(clBean, (Object[]) null);
>>>
>>> These get IllegalAccessException:
>>> ClassLoadingMXBean
>>> CompilationMXBean
>>> GarbageCollectorMXBean
>>> MemoryMXBean
>>> MemoryMXBean
>>>
>>> These allow me to use method.invoke():
>>> OperatingSystemMXBean
>>> MemoryUsage
>>>
>>> Jennifer
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: admin-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: admin-help_at_glassfish.dev.java.net
>