• 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

Problem looking up remote EJB's in JNDI

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are having difficulties looking up remote EJB's in JNDI. We are using Websphere 5.0. We created the following test scenario to demonstrate our problem:
We are using Websphere Studio Application Develor(WSAD). In WSAD, we setup up two different EARs and deployed them to two different servers. We changed the ports on both servers so that they don't conflict. Each EAR has a different EJB deployed to it.
We wrote the following standalone app to access the JNDI InitialContext on both servers and dump the initial context: (note: DumpNameSpace is a class in naming.jar)
///////////////////////////////////////////////////////
/// Lookup JNDI context for Server A
DumpNameSpace dumpNizzle = new DumpNameSpace();
Hashtable proj1 = new Hashtable();
proj1.put( Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
proj1.put(Context.PROVIDER_URL, "iiop://localhost:9809");
InitialContext proje1Context = new InitialContext(proj1);

dumpNizzle.generateDump(proje1Context);
/// Lookup JNDI context for Server B
Hashtable sheet = new Hashtable();
sheet.put( Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
sheet.put(Context.PROVIDER_URL, "iiop://localhost:5809");
InitialContext sheetContext = new InitialContext(sheet);
dumpNizzle.generateDump(sheetContext);
///////////////////////////////////////////////////////

When we run this code in a standalone client, it works as expected. We get two different JNDI contexts and they hold the EJB's from their respective servers.
However, when we run the same exact code from a servlet running in a separate Websphere web application, we do not get the same results. Instead of getting the JNDI context from the specified server and port, we get the JNDI context for the Web application that the servlet is running in. We get this same context for both of the above lookups. We are therefore unable to access these EJBs from our web app, because we can't look them up.

1) What is going on here?
2) How can we access remote EJBs from a web application running in a different server?
Thanks for any help.
-Mike
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have always used port 900. Try this maybe?
 
Mike Dee
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe port 900 is the default port for older versions of Websphere. We have explicitly set the ports to be as named above. Since the standalaone(non web) client is working, we are presuming that these ports have been correctly configured to the above ports and are working correctly.
The issue seems to be a difference between how InitialContext's are created for standalone clients versus clients accessing the remote EJB's via a servlet running in a web server. It appears that when creating the InitialContext while running in a server(i.e. servlet), the InitialContext will always default to the intial context for that web server, unless(we presume) that you setup the IntialContext with the proper initialialzation parameters. It appears that the proper parameters are different for standalone clients than for clients running in a servlet.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic