12 Replies Latest reply on Oct 6, 2015 12:46 AM by hmohammedrajjaz

    javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]

    jashan07

      Hi,

       

      I am trying to run my application on 6.0.1 EAP and m getting the following error:

       

       

      javax.naming.NoInitialContextException

       

      Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException

       

       

      I found from some forums that i have to add jbossall-client.jar file but jboss 6.0.1 doesnt contain any jar like this.

      Can any one help me to get out of this problem?

      my BookClient code:

       

      public class BookClient {

       

      public static void main(String z[]) {

       

       

      try {

       

      int choice = 1;

      Properties p =

      new Properties();

      p.put(Context.

      INITIAL_CONTEXT_FACTORY,

       

      "org.jnp.interfaces.NamingContextFactory");

      p.put(Context.

      URL_PKG_PREFIXES,

       

      "org.jboss.naming:org.jnp.interfaces");

      p.put(Context.

      PROVIDER_URL, "localhost:4447");

      InitialContext ctx =

      new InitialContext(p);

       

      BookHome home = (BookHome) ctx.lookup(

      "BK");

       

      Book bean = home.create();

      Scanner sc =

      new Scanner(System.in);

       

      while (choice != 2) {

      String bname;

      System.

      out.println("Enter choice 1. Add 2. Over");

      choice = sc.nextInt();

       

      if (choice == 1) {

      System.

      out.println("Enter book name");

      bname = sc.next();

      bean.addBook(bname);

      }

      else if (choice == 2) {

       

      break;

      }

      }

       

      Vector v = bean.getBooks();

       

      System.

      out.println("Size of vector \t" + v.size());

       

      for (int i = 0; i < v.size(); ++i) {

      System.

      out.println((String) v.elementAt(i));

      }

       

      }

      catch (Exception e) {

      System.

      out.println(e);

      }

      }

       

       

       

      where is the error or which jar file i need to add or modification i need to do?

       

      Thanks,