• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Newbie question(s) re: MBeans in WAS 6.1

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just a quick update; I resolved my problem after overcoming my moment or moments of stupidity.
reply
    Bookmark Topic Watch Topic
  • New Topic