5 Replies Latest reply on Apr 19, 2003 2:22 PM by cbwilliams

    naming exception-pls help!!

    ravishastri Newbie

      I am getting the following error when I run Client.java
      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
      aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
      rg.jnp.interfaces.NamingContextFactory]

      my client.java(bean deployed successfully)


      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import java.util.Properties;
      import com.javapro.ejb.StringProcessor;
      import com.javapro.ejb.StringProcessorHome;

      public class Client {

      public static void main(String[] args) {

      // first argument must be the input
      if (args.length==0) {
      System.out.println("Please specify the input to convert to upper case.");
      return;
      }
      String input = args[0];
      //Properties properties=System.getProperties();
      // preparing properties for constructing an InitialContext object
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.PROVIDER_URL, "165.197.127.98:8080");

      try {
      // Get an initial context
      InitialContext jndiContext = new InitialContext(properties);
      System.out.println("Got context");

      // Get a reference to the Bean
      Object ref = jndiContext.lookup("StringProcessor");
      System.out.println("Got reference");

      // Get a reference from this to the Bean's Home interface
      StringProcessorHome home = (StringProcessorHome)
      PortableRemoteObject.narrow (ref, StringProcessorHome.class);

      // Create an Adder object from the Home interface
      StringProcessor sp = home.create();
      System.out.println ("Uppercase of '" + input + "' is " +
      sp.toUpperCase(input));
      }
      catch(Exception e) {
      System.out.println(e.toString());
      }
      }
      }


      thanks