File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes How to Get Active Servers Detailed Information Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to Get Active Servers Detailed Information" Watch "How to Get Active Servers Detailed Information" New topic

How to Get Active Servers Detailed Information

Amy Howard
Ranch Hand

Joined: Jul 11, 2002
Posts: 86
My application servlet connects multiple ejb servers. I created the following method called getActiveServerList() without throws NamingException error.
* * Inputs : Detailed information stored in XML file for each connection
* * Outputs : Active server detailed information
Does someone know a better solution? Thanks in advance!
private TreeMap getActiveServerList(){
TreeMap serverList = new TreeMap();
ServerConfigMapper srvCfgMap = ServerConfigMapper.getInstance().
TreeMap serverDetailsFromXml = srvCfgMap.getServers();
Set servers = serverDetailsFromXml.entrySet();
Iterator it = servers.iterator();
while (it.hasNext()){
Map.Entry serverEntryFromXML = (Map.Entry);
ServerMapObject server = (ServerMapObject) serverEntryFromXml.getValue ();
/* find the JNDI Name*/
String serviceName = server.getEjbJNDI();

//Get the initial context
Hashtable env= new Hashtable();

//Get the server iiop from XML
env.put(Context.PROVIDER_URL, server.getIiopUrl());
//To clear a cache
env.put ("", "none");
//Get a naming context
InitialContext initCtx = new InitialContext (env);
Object jndiRef = initCtx.lookup(serviceName);
if (jndiRef != null) {
serverList.put(server.getServer(), server);
}catch(NamingException ne){
}catch(Exception e){
return serverList;
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Moving this to the EJB forum.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: How to Get Active Servers Detailed Information
It's not a secret anymore!