1 Reply Latest reply on Oct 4, 2003 9:21 AM by Juha Lindfors

    ClassCastException when calling EJB from java client

    alexp Newbie

      I am trying to call a stateless session bean from a java client. Very standard code:

      Properties props = new Properties();
      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      props.put(Context.PROVIDER_URL, "localhost");
      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );

      Context initial = new InitialContext(props);
      MyBeanHome objref = (MyBeanHome)initial.lookup("MyBean");
      Object o = PortableRemoteObject.narrow(objref,
      MyBeanHome.class);

      But I get ClassCastException on narrow call. I included ejb jar and all JBoss client jars in classpath. I think it has something to do with stubs, so I was looking for a way to get or generate stubs but then I read somewhere that JBoss does not need stubs, so I am not sure what the problem is. Please help

      THanks a lot