• 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

A query concerning getting Attributes of a MBean using the getAttribute() method

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to fetch the Attribute with name "TargetedTrapDestinations" from the SNMPAgentConfig MBean.
If I print the type of the "TargetedTrapDestinations" I get
"[Lweblogic.management.configuration.SNMPTrapDestinationMBean;"
What I deduce from this is that It must be an array of "SNMPTrapDestinationMBean"
So I did the following
*************************
RemoteMBeanServer rmbServer
= home.getMBeanServer();
ObjectName beanName =
new ObjectName("mydomain:Location=myserver,Name=mydomain,Type=SNMPAgentConfig"
);
Object recvdObj = rmbServer.getAttribute(beanName,"TargetedTrapDestinations");

SNMPTrapDestinationMBean [] arr =
(SNMPTrapDestinationMBean [])recvdObj ;
*************************
I get a Class Cast Exception.....
Whereas If I get a Attribute "CommunityPrefix"
which Is of Type "String"
I am successful
ie
*******************
Object recvdObj = rmbServer.getAttribute(beanName,"CommunityPrefix");
String strVal = (String)recvdObj
*********************
So my question is What class should I typecast
for the Parameter "TargetedTrapDestinations" and
or how to find the correct class to typecast to
reply
    Bookmark Topic Watch Topic
  • New Topic