aspose file tools*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
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://aspose.com/file-tools
 
subject: Newbie question(s) re: MBeans in WAS 6.1