hi,
I used the following code:
protected void doPost( final HttpServletRequest request
, final HttpServletResponse response ) throws ServletException, IOException
{
InitialContext context = getInitialContext() ;
try
{
System.out.println("context : " + context.toString()) ;
// Get a reference to the Bean
Object reference = context.lookup("HELLOEJB") ;
System.out.println("object reference : " + reference.toString());
// Get a reference from this to the Bean's Home interface
HelloHome home = (HelloHome) PortableRemoteObject.narrow (reference, HelloHome.class);
System.out.println("home interface : " + home.toString());
// Create the EJBObject from the Home interface
HelloRemote hello = home.create();
System.out.println("remote interface : " + hello.toString());
// Get the result
String result = hello.helloWorld() ;
response.setContentType("text/html") ;
PrintWriter out = response.getWriter() ;
out.println("Output from HelloEJB : " + result) ;
}
catch(Exception e)
{
e.printStackTrace() ;
}
}
private InitialContext getInitialContext()
{
Hashtable props = null ;
InitialContext context = null ;
try
{
props = new Hashtable();
// For OC4J SERVER
props.put(Context.INITIAL_CONTEXT_FACTORY, "oracle.j2ee.rmi.RMIInitialContextFactory");
props.put(Context.PROVIDER_URL, "ormi://172.16.88.49:8888/Testhello") ;
context = new InitialContext(props) ;
}
catch(Exception e)
{
e.printStackTrace() ;
}
return context ;
}
The client servlet is at my machine on Tomcat. The ejb is at some other machine on OC4J. Using the above code there is no error but the ejb is not reached... It hangs, waiting for the ejb. The two machines are on a normal intranet.
Thanks and regards,
Amit.