• 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

How to find all ejbs deployed for an ear on Websphere?

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to find out how many EJBs have been deployed as a part of ear through a program?
I have to list all the ejbs that have been deployed for an ear application in Websphere.


Regards,
Giriraj.
[ December 29, 2008: Message edited by: Giriraj Bhojak ]
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can find using an MBean, here is the sample code..

MBeanFactory mf = AdminServiceFactory.getMBeanFactory();
MBeanServer server = mf.getMBeanServer();

ObjectName obj = new ObjectName("WebSphere:type=StatelessSessionBean,*");
Set mbeans = server.queryMBeans(obj, null);

if(mbeans!=null ) {
Iterator itr = mbeans.iterator();
while(itr.hasNext()) {
ObjectInstance objInstance = (ObjectInstance) itr.next();

if(objInstance!=null && objInstance.getObjectName()!=null) {
String beanName = objInstance.getObjectName().getKeyProperty("name");

System.out.println(beanName);
}
}
}
 
Giriraj Bhojak
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Setty for your reply...
Can this code snippet work if I use it as a part of the servlet?

Regards,
Giriraj.
 
S Setty
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it works
 
Giriraj Bhojak
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Setty.
I have tried it the way you have mentioned.
And it works.
After trying this example I found out that I need to be aware of MBeans.
So I have read about MBeans.
Now that I have the names of all the ejbs deployed in websphere, how do I do a JNDI lookup to invoke ejb method.
Is there any JMX api that would help me to actually retrieve an ejb reference?

Regards,
Giriraj.

 
reply
    Bookmark Topic Watch Topic
  • New Topic