Solved

invoking Mbean operation with arguement?

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
factorial example challenge 10 62
return in catch statement 1 40
parentbit challenge 3 52
micro services vs rest web services 16 53
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 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

24 Experts available now in Live!

Get 1:1 Help Now