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
-default package |- jndi.properties | |- cartClient |-Main.java
### 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
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); } } }