Two Laptop Bag
The moose likes Websphere and the fly likes Newbie question(s) re: MBeans in WAS 6.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » Websphere
Reply Bookmark "Newbie question(s) re: MBeans in WAS 6.1" Watch "Newbie question(s) re: MBeans in WAS 6.1" New topic
Author

Newbie question(s) re: MBeans in WAS 6.1

Richard Olson
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Good afternoon,

I'm trying to modify an example WAS Java program named AdminClientExample.java so I can learn MBeans on WAS and complete a utility I'm working on. I've written a couple of utilities which call MBeans on Tomcat and understand some of the basics of MBeans, but I'm a bit lost in WAS at the moment.

My dilemma, when I run the sample code below I recieve the following message:
Connected to DeploymentManager
In getServerName
Exception in thread "P=595730:O=0:CT" java.lang.ClassCastException: java.util.HashSet incompatible with javax.management.ObjectName
at AdminClientExample.getServerName(AdminClientExample.java:111)
at AdminClientExample.main(AdminClientExample.java:37)

Here's the method generating the exception:
private void getServerName()
{
System.out.println("In getServerName");
// Query for the ObjectName of the NodeAgent MBean on the given node
try
{
String query = "WebSphere:*,type=Server";
ObjectName queryName = new ObjectName(query);
Set s = adminClient.queryNames(queryName, null);
ObjectName myObj = (ObjectName) s;
if (!s.isEmpty()) {
System.out.println((ObjectName)s.iterator().next());
try {
System.out.println("\nname = " + adminClient.getAttribute(myObj, "name"));
} catch (AttributeNotFoundException antfe) {
System.out.println(antfe);
} catch (MBeanException me) {
System.out.println(me);
} catch (ReflectionException re){
System.out.println(re);
} catch (InstanceNotFoundException inte) {
System.out.println(inte);
inte.printStackTrace();
}
}
else
{
System.out.println("\nServer MBean was not found");
System.exit(-1);
}
}
catch (MalformedObjectNameException e)
{
System.out.println(e);
System.exit(-1);
}
catch (ConnectorException e)
{
System.out.println(e);
System.exit(-1);
}

System.out.println("Found Server MBean ");
}


My question, how do I use the simple method to retrieve the server's name? The method successfully prints out several MBean entries for the iterator.

Also, nodeAgent fails to connect for it's own reasons, but not my main concern; just the above example.

Thanks for the help,
Rich
Richard Olson
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Just a quick update; I resolved my problem after overcoming my moment or moments of stupidity.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Newbie question(s) re: MBeans in WAS 6.1
 
Similar Threads
Alert mechanism when Message Listener is down on Websphere
WASv5.1.1.6: JMX NotificationListener not working for ListenerPort events?
Can not get MBean-JMX
JMX in JBoss
JMX: How to list all the application servers on the node regardless of their statuses