wood burning stoves
The moose likes EJB and other Java EE Technologies and the fly likes Problem calling EJB deployed on websphere from Java Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problem calling EJB deployed on websphere from Java Client" Watch "Problem calling EJB deployed on websphere from Java Client" New topic

Problem calling EJB deployed on websphere from Java Client

venkat paruchuri

Joined: Aug 15, 2001
Posts: 28

I am using websphere studio 5.1.2 with fix pack 3. I have a sample Stateless Session Bean (EJB) deployed and running on websphere.

I wrote a small Java client program as below.

import java.util.Hashtable;

import HelloJavaHome;
import HelloJava;
import javax.naming.InitialContext;
import javax.naming.Context;

import javax.ejb.EJBHome;
import javax.ejb.EJBObject;

public class RemoteConn {

public static void main(String[] ar) throws Exception{
String greeting = "";


Hashtable env = new Hashtable();
//env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
//env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ejs.ns.jndi.CNInitialContextFactory");

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.ws.naming.util.WsnInitCtxFactory");

//env.put(Context.PROVIDER_URL, "corbaloc:iiop:myhost.mycompany.com:2809/NameServiceCellPersistentRoot");

env.put(Context.PROVIDER_URL, "iiop://localhost:2809");

System.out.println("Before creating context ");

InitialContext initContext = new InitialContext(env);

System.out.println("Before looking up HelloJavaHome.");

//Object obj = initContext.lookup("java:comp/env/ejb/HelloJavaHome");
Object obj = initContext.lookup("ejb/HelloJavaHome");

System.out.println("After lookup javahome.");

HelloJavaHome home = (HelloJavaHome) javax.rmi.PortableRemoteObject.narrow(obj, HelloJavaHome.class);
HelloJava remote = home.create();
greeting = remote.getGreeting("John");
catch(Exception e){

System.out.println("Greeting::"+ greeting);

I did not have any problem if I write and run this client from Websphere studio environment..

However its giving lot of compilation and runtime errors when I tried to run from command line.

I could eliminated compilation errors by setting the below jar files in the classpath.

testclient.jar; (client jar of my EJB)

Now it is throwing runtime error after the statement, "Before looking up HelloJavaHome.", has printed. Here is the stack trace of exception ..

Exception in thread "main" java.lang.NoClassDefFoundError: com.ibm.CORBA.iiop.GlobalORBFactory
at com.ibm.ejs.oa.EJSORBImpl.class$(EJSORBImpl.java:44)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:195)
at com.ibm.ejs.oa.EJSClientORBImpl.(EJSClientORBImpl.java:93)
at com.ibm.ejs.oa.EJSClientORBImpl.(EJSClientORBImpl.java:65)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:385)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:284)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:369)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:112)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:422)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:143)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at RemoteEJBConn.main(RemoteEJBConn.java:38)

I appreciate if sombody could help me ASAP fixing this problem.
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem calling EJB deployed on websphere from Java Client
It's not a secret anymore!