6 Replies Latest reply on Jul 15, 2005 8:48 AM by Ken Hoffman

    ClassCastException on EJB Remote Lookup/Narrow

    Ken Hoffman Newbie

      HI - I'm new to JBoss and just trying a simple servlet to remote session bean lookup. I keep getting a ClasscastExcepion on the narrow().

      I have a simple EJB - MyBean.class, the remote is My.class, the home is MyHome.class. Here is the servlet lookup code (I try it with and w/o EJB referneces, the result is the same):
      InitialContext context = new InitialContext();
      Object ref = context.lookup("java:comp/env/ejb/My"); // w/ ref
      //Object ref = context.lookup("ejb/My"); // w/o ref
      home = (MyHome) PortableRemoteObject.narrow(ref, MyHome.class);
      my = home.create();

      The lookup returns a object named $Proxy51. The JMX-Console JNDI-view looks like this:

      +- ejb (class: org.jnp.interfaces.NamingContext)
      | +- My (proxy: $Proxy51 implements interface com.blackdog.interfaces.MyHome,interface javax.ejb.Handle)

      There is no other MyHome class in the app that it could be confused with.

      This looks like it should work to me. Can anyone suggest what may be going wrong? Thx.