Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

calling ejb on another machine on OC4J hangs

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not duplicate post. This is also posted in your other thread and is related to that other thread. So I am going to close this thread and let you continue your progress in the other thread.

Thanks

Mark
 
    Bookmark Topic Watch Topic
  • New Topic