0 Replies Latest reply on Oct 2, 2006 8:55 AM by aggarwalanil2004

    EJB3.0 Client code

    aggarwalanil2004

      Hi
      I am using EJB3.0 in my project
      I wrote code of remote interface and bean
      I am using JBoss as application server.
      I am not able to run the client code successfully
      It is throwing followingexception :
      PLZ help me ...

      setting IC Propsjavax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
      at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
      at javax.naming.InitialContext.lookup(InitialContext.java:351)
      at com.client.EJB3Client.main(EJB3Client.java:41)




      Below is client code
      package com.client;

      import java.util.Properties;

      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      //import javax.ejb.EJB;

      import com.ejb3.HelloEJB;

      public class EJB3Client {

      public static void main(String[] args) {

      try {
      Context context =new InitialContext();
      HelloEJB helloejb = (HelloEJB)context.
      lookup("com.ejb3.HelloEJB");

      String st = helloejb.sayHello();

      System.out.print("client :" + st);

      } catch (NamingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }

      }

      }