aspose file tools*
The moose likes Websphere and the fly likes How to find all ejbs deployed for an ear on Websphere? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "How to find all ejbs deployed for an ear on Websphere?" Watch "How to find all ejbs deployed for an ear on Websphere?" New topic
Author

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

Giriraj Bhojak
Ranch Hand

Joined: Apr 03, 2008
Posts: 71
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 ]
S Setty
Greenhorn

Joined: Sep 08, 2008
Posts: 16
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

Joined: Apr 03, 2008
Posts: 71
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

Joined: Sep 08, 2008
Posts: 16
Yes it works
Giriraj Bhojak
Ranch Hand

Joined: Apr 03, 2008
Posts: 71
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find all ejbs deployed for an ear on Websphere?
 
Similar Threads
calling ejb from different ear files
Protecting EJBs for public use
EJB lookup problem on WebSphere
Isolation of EARs (and EJB3)
ear in a distributed setup