• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Problem calling EJB deployed on websphere from Java Client

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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 = "";

try{

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){
e.printStackTrace();
}

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)
j2ee.jar;
naming.jar;ras.jar;
wsexception.jar;
bootstrap.jar;
namingclient.jar;
websphere.jar;server.jar;
ejbcontainer.jar;
ecutils.jar;

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.
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic