1 Reply Latest reply on Nov 20, 2002 11:16 AM by mlindhout

    Put ejb into JNDI



      I've instanced a EJB (SFSB) and put the Bean, not the Home, into JNDI (bind the bean class). Now, if I got the bean by look function, I always get an object which only implements Serializable.

      Here is my code:
      // Generate bean and put it into JNDI
      Object obj = ctx.lookup("SequenceLocal");
      SequenceLocalHome home = (SequenceLocalHome)obj;
      sequence = home.create();

      // Later, get the bean from JNDI
      Object obj = ctx.lookup(JNDI_ENV_CONTEXT+JNDI_SEQUENCE_CART_NAME);
      sequence = (SequenceLocal)obj; // ClassCastExecption -> obj only implements Serializable.

      Can somebody help me?

        • 1. Re: Put ejb into JNDI

          Hi there,

          I don't know if it is the solution, but acoording to me (and the spec) you must narrow the looked up object with PortableRemoteObject.narrow(java.lang.Object, java.lang.Class) before you may cast it to xxxHome. Don't ask me why... ;-)

          Try this:

          home = (SequenceLocalHome)PortableRemoteObject.narrow(obj, SequenceLocalHome.class);