This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
Similar Threads
WASv5.1.1.6: JMX NotificationListener not working for ListenerPort events?
JMX: How to list all the application servers on the node regardless of their statuses
Can not get MBean-JMX
JMX in JBoss
Alert mechanism when Message Listener is down on Websphere