• Post Reply Bookmark Topic Watch Topic
  • New Topic

jmxbean classcast exception  RSS feed

 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create a class


This works fine if I used jconsole to invoke the stop method. however, if i ran with my own client, it throws the following classcast exception:


these are the fragments of the code of my client to connect to the mxbean. can someone shed some lights? thanks.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, what does newMBeanProxy(.....) return? What's the object you're trying to assign it to?
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JMX.newMBeanProxy is from JDK 1.6 to create a proxy object to the mxbean. can someone who have expereince with this help out on this? thanks.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you debug to see exactly which line throws:

java.lang.ClassCAstException:javax.management.openmbean.CompositeDataSuport cannot be cast to ValidationResult
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Martijn Verburg. thanks for your question for my question. if there is any concrete suggestion, please share. otherwises, i would like to get some feedback from someone else.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, let me try this again. Which line in your code example that you've posted above is throwing that Exception? It'll help us narrow it down for you.
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
classcast exception is thrown when you do the following in the code:
umbean.stop ("abc");

but if you do it through jconsole, it is fine.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume umbean is declared in your code as ?
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

no. it has to be.
UsersMXBean umbean

i skip some details as this is an intermediate room. have you coded mxbean before? if not, please don't waste my time....
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
luri ron wrote:
i skip some details as this is an intermediate room. have you coded mxbean before? if not, please don't waste my time....



Unfortunately, if you consider "helping you debug the problem" instead of "giving you the exact answer" as a waste of your time, it may be better off to just stop this discussion.

Believe it or not, JMX is not a commonly used interface. In fact, I am probably one of the few people on these forums who did heads-down hands-on JMX work -- and did it for many years. And even I, have not encountered this exact error condition. You may have no choice, but to debug this issue yourself, using the help of the people on the ranch.

Henry
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, completely different track here. What exact version of the JDK/JRE are you:

1.) Compiling your code in
2.) Running your client in
3.) Running Jconsole with

Another thing to try. Is the code for JConsole Open source, can you read it? If so see how they stop the UsersMXBean, you might see something that you're missing.
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Unfortunately, if you consider "helping you debug the problem" instead of "giving you the exact answer" as a waste of your time, it may be better off to just stop this discussion.


henry please read through the message thread. i saw your replies on the performance topics so i respect your input.

however, if you read carefully the thread, if one person doesn't know what JMX.newMBeanProxy(.....) return, and declare "User mbean", IMHO, the guy doesn't know much about the topic.

this is intermediate room so i expect something more in depth. this type of common instructions on how to debug your program is for beginners...
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
luri,

The point of Javaranch is to help people help themselves, so yes people will try to guide you through the common steps of debugging first before going into more complex research. The Intermediate forum is all about the level of the question (it's not simple Java) and not necessarily anything to do with the expertise of any volunteers trying to help with a particular question (in my case I'm trying to make sure you've covered the basic steps).

Anyhow, best of luck with your problem.
 
luri ron
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks anyway
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!