ClasscastException when the return type is ArrayList in MXbean

Hi,

I am new to JMX.

I am writing Config MX bean. I am getting ClassCastException when calling the getKeys() method of my Config mbean whose return type is java.util.ArrayList.

In my program I was trying to call the getKeys() method of my mbean which is throwing me the following exception.

java.lang.ClassCastException: [Ljava.lang.String;

at $Proxy0.getKeys(Unknown Source)

However if I specify return type as primitive data type or String then it gets executed successfully.

I have also tried to do the following things but it didn抰 worked still.

Changed the return type to java.util.Set.

Returned the empty java.util.ArrayList.

Tried to run the different mbean with same return type.

When I was debugging this, I have found that getKeys() method get executed successfully, but in my calling program it throws me the exception. In my calling program I have not even called any method after the call to getKeys() method.

I am using JDK 1.5 and deploying this bean on Standalone JMX server.

I have tried returning CompositeData, it is working fine. Does this means that I cannot return ArrayList from my mbean methods? If No then how can I achieve this?

Could you please help me to find out the problem?

Thanks & Regards,

Nitin Goel

[1347 byte] By [Nitin_Goela] at [2007-11-29]
# 1

Hi,

Could you provide a snipet of code of what you're doing?

Are you really creating your own MXBean with Java SE 5.0 ? Or are you

using plain MBeans?

JDK 1.5 doesn't have an out-of-the box support for MXBeans.

Out of the box support for MXBeans comes in Java 6.

See the reply I just made to this thread:

http://forum.java.sun.com/thread.jspa?messageID=4370846

-- daniel

JMX, SNMP, Java, etc...

http://blogs.sun.com/jmxetc

dfuchsa at 2007-7-14 > top of java,Core,Monitoring & Management...