Solved

invoking Mbean operation with arguement?

Posted on 2014-03-31
3
452 Views
Last Modified: 2014-04-02
Hi,

I have MBean operations.
I am able to invoke getXXX operations without arguements.
But when I try to invoke operations (delete, update, and add) with arguement?
I am getting runtime error.

Do I need to do anything differently when I invoke those operations with arguement?
Can you help?

public List<Catalog> getAllCatalogs() {
try {

			MBeanServer server = ManagementFactory.getPlatformMBeanServer();
			ObjectName name = new ObjectName(
					"bean:name=CatalogMbean");

			String[] sig = {};
			Object[] arg = {};
			list = (List<Catalog>) server.invoke(name,
					"getAllCatalogs", arg, sig);

			Iterator<Catalog> it = list.iterator();
....
skipped rest

Open in new window


The above returns fine.

public void deleteCatalog(Catalog cat) {

      if (cat != null) {
                  try {

                        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
                        ObjectName name = new ObjectName("bean:name=CatalogMbean");                        
                        
                        String[] sig = { int.class.getName() };
                        Object[] arg = {cat.getId()};
                        rowNo = (int) server.invoke(name,"deleteCataglo", arg, sig);

                  } catch (Exception e) {
But I try to delete using id, it gives me a runtype error

)javax.management.RuntimeOperationsException: RuntimeException occurred in RequiredModelMBean while trying to invoke operation deleteCatalog(Catalog cat)
0
Comment
Question by:dkim18
  • 2
3 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 39968525
Two things...

- I hope that the method name in your invoke call above, "deleteCataglo" is just a typo and you are using the real method name?

- Can you post the full stack trace that you get?
0
 

Author Comment

by:dkim18
ID: 39968853
Yes it was a typo.

That is all i get for the error message. Not that helpful.
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 39968973
That is all i get for the error message.
I see in the code above that you are catching all exceptions thrown. What are you doing with the exception? ie. what is directly after the code that you posted above?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
javap bin 2 40
javap not working 8 58
Desingning Refactoring existing code 2 26
pagenation logic how it is working in my code 1 52
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question