Solved

invoking Mbean operation with arguement?

Posted on 2014-03-31
3
439 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now