Accessing a EJB deployed in websphere 5.1


EJB programming & troubleshooting: Accessing a EJB deployed in websphere 5.1

  1. Accessing a EJB deployed in websphere 5.1 through remote client its an copnsole based application.

     i am writing an application by placing naming.jar and namingclient.jar files in my classpath and my application is

    public class SesClient1 {
       public static void main(String[] args) {
           try {
               Context initial = getInitialContext();
               Object obj= initial.lookup("ses");
               SesHome home =(SesHome)obj;
               SesRemote h = home.create();
    String res = h.BusinessMethod1(" Client1 ");;;
               System.out.println("name set by client 1");
            res= h.BusinessMethod2();
            System.out.println("name returned by BusinessMethod2" +res);
           }catch(Exception e){ System.out.println(e);}
      static public Context getInitialContext() throws Exception
          Hashtable h = new Hashtable();
          h.put(Context.PROVIDER_URL, "iiop://localhost:9080");
          Context ctxt=new InitialContext(h);

        }catch(Exception e){System.out.println(" "+e);}

     i am getting a exaception the exception is

    Exception in thread "main" java.lang.NoClassDefFoundError: com/ibm/CORBA/iiop/Ob
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(
            at javax.naming.spi.NamingManager.getInitialContext(
            at javax.naming.InitialContext.getDefaultInitCtx(
            at javax.naming.InitialContext.init(
            at javax.naming.InitialContext.<init>(
            at SesClient1.getInitialContext(
            at SesClient1.main(

    please help me its very urgent
  2. where is your cast???[ Go to top ]

    SesHome home =(SesHome)obj
    home = (SesHome)PortableRemoteObject.narrow(obj,SesHome.class);

    Try this dude!!!
  3. you need to use an IBM JRE