0 Replies Latest reply on Feb 12, 2007 4:52 AM by sandrocchio_0.1

    Cannot instantiate class: org.jnp.interfaces.NamingContextFa

    sandrocchio_0.1

      Hi there,
      I'm trying to call an session Bean (EJB3 - jboss 4.0.5) methods from a simple client. But it returns me the following error:

      Caught an unexpected exception: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory


      in the classpath:
      jboss-j2ee.jar
      Cart - dist/Cart.jar (the ejb module)
      jdk 1.5

      -default package
       |- jndi.properties
       |
       |- cartClient
       |-Main.java


      the jndi.properties
      ### JBossNS client properties for connection from the localhost
      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=jnp://localhost:1099/
      
      # The jnp protocol socket factory class
      jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory


      and the Main.java
      public class Main {
      
       /** Creates a new instance of Main */
       public Main() {
       }
      
       /**
       * @param args the command line arguments
       */
       public static void main(String[] args) {
       // TODO code application logic here
       try{
       Context ctx = new InitialContext();
       Object objRef = ctx.lookup("ejb/CartBean");
       CartRemoteHome home =
       (CartRemoteHome)PortableRemoteObject.narrow(objRef, CartRemoteHome.class);
      
       CartRemote shoppingCart = home.create("Duke DeEarl", "123");
      
       shoppingCart.addBook("The Martian Chronicles");
       shoppingCart.addBook("2001 A Space Odyssey");
       shoppingCart.addBook("The Left Hand of Darkness");
      
       Vector bookList = new Vector();
      
       bookList = shoppingCart.getContents();
      
       Enumeration enumer = bookList.elements();
      
       while (enumer.hasMoreElements()) {
       String title = (String) enumer.nextElement();
      
       System.out.println(title);
       }
      
       shoppingCart.removeBook("Alice in Wonderland");
       shoppingCart.remove();
      
       System.exit(0);
      
       }catch(BookException ex){
       System.err.println("Caught a BookException " + ex.getMessage());
       System.exit(0);
       }catch(Exception ex){
       System.err.println("Caught an unexpected exception: " + ex.getMessage());
       System.exit(1);
       }
       }
      
      }

      Any help? Thanks in advance.