Giving Invalid Class Cast Exception while lookin up for dep. EJB

Discussions

EJB programming & troubleshooting: Giving Invalid Class Cast Exception while lookin up for dep. EJB

  1. Hi,

    I have Developed a stateless session bean. I could successfully deploy it on Websphere Application Server version 3.5.

    I have Written a clent code to test this bean.

    while executing the client it gives me invalid class cast exception when the code looks up for the bean.

    viz intialcontext.lookup("Demo");

    Plz help

    Gaurav

  2. Have the home and the remote interfaces accessible to your client. If your client cannot find the interfaces runtime it seems to throw Class Cast Exception. Also cast the reference you get by doing the lookup into the remote interface type.
  3. Hi gautam,

    Have u done type casting when u do a JNDI lookup.Look at the below code.
    And import yr home and remote interfaces in yr client code..

    Context ctx = getInitialContext();
    AuthenticateHome home = (AuthenticateHome) ctx.lookup("AuthenticateHomeJndi");
    Authenticate the_ejb = home.create();

    I think this should help u.

    Rinku
  4. hi Rinku,

    Thanks for ur suggestions.
    I could finally get it right by including the ujc.jar file provided by websphere and running the client through IBM's JDK.

    regards

    Gaurav