Solved

invoking Mbean operation with arguement?

Posted on 2014-03-31
3
501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 36

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 36

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

622 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