• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie question(s) re: MBeans in WAS 6.1

 
Richard Olson
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a quick update; I resolved my problem after overcoming my moment or moments of stupidity.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic