Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JMX invoke() method

 
Esteban Cairol
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi... im having a problem when implementing the method invoke() on an MBeanServer.

Here's the code of that part in the JSP:

Object[] params = new Object[]{n};
String[] signature = new String[] {"java.lang.Integer"};
Object resp = mserver.invoke(objName,"doble",params,signature);

The error im getting is:

ERROR: javax.management.ReflectionException: The operation with name doble could not be found

But if I do a getOperations() to that MBean (the mbean defined in the mserver by the objName) I get that the operation "doble" exists!

Please help me... thank you!

Esteban.
 
Henry Wong
author
Marshal
Pie
Posts: 22119
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, what is this getOperations() method that you are referring to? I didn't know the mbeanserver had such a method.

Anyway, it should work. Unless you got the signature of the method call wrong. I would double check that next.

Henry



[EDIT: Never mind about the getOperations() method... Working with standard mbeans too much that I totally forgot about the MBean info.]
[ August 18, 2006: Message edited by: Henry Wong ]
 
Esteban Cairol
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!

It works now.. the problem was the signature...

Just to test I change the method I was trying to access ( int doble(int) ) and change it to receive a String. In the signature I wrote: "java.lang.String" and it worked fine.

Now the doubt I have is ... how to pass a parameter of type int to the method I want to call, without having problems with the Object[] params ?

Because it tells me that "Cannot convert from int to Object", when I put a int in the array "params" (of type Object)
 
Henry Wong
author
Marshal
Pie
Posts: 22119
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Esteban Cairol:

Now the doubt I have is ... how to pass a parameter of type int to the method I want to call, without having problems with the Object[] params ?

Because it tells me that "Cannot convert from int to Object", when I put a int in the array "params" (of type Object)


It has been a long while since I used primative parameters in MBeans -- don't know why. For some weird reason, the common convention seems to be to just avoid them.

Anyway, to pass an "int" parameter, you need to pass an "java.lang.Integer" object as the "int" variable. However, the signature is *not* "java.lang.Integer" for the parameter, it is "int".

Hope this helps,
Henry
 
Esteban Cairol
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Ok, thank you very much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic