aspose file tools*
The moose likes Other Application Frameworks and the fly likes JMX invoke() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "JMX invoke() method" Watch "JMX invoke() method" New topic
Author

JMX invoke() method

Esteban Cairol
Greenhorn

Joined: Aug 18, 2006
Posts: 6
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
Sheriff

Joined: Sep 28, 2004
Posts: 19068
    
  40

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 ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Esteban Cairol
Greenhorn

Joined: Aug 18, 2006
Posts: 6
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
Sheriff

Joined: Sep 28, 2004
Posts: 19068
    
  40

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

Joined: Aug 18, 2006
Posts: 6


Ok, thank you very much!
 
Consider Paul's rocket mass heater.
 
subject: JMX invoke() method