Discussions

EJB programming & troubleshooting: Unable to communicate with deployed component

  1. Hello Friends
     I am facing a problem in coding a jsp which has to contact a deployed ejb bean.
    The bean has a JNDI Name as "authentication"

    In the JSP Code , I have written the following lines:
    *****************************************************
            Context ct = new InitialContext(h);
            Object obj = ct.lookup("authentication");
         System.out.println("After the JNDI Lookup");

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

    *****************************************************
    Code is executed till the statement mentioned above
    "After the JNDI Lookup"
    After that line of code, when I am trying to type cast the object in to a HomeInterface , the message thrown on the server console is:
    ******************************
    java.lang.ClassCastException
    ******************************
    Is this a wrong way of communicating with the ejb bean?
    Please help me out regarding this aspect.

    Regards
    RadhaKrishna

  2. Try this out

    VinayHome home = (VinayHome) ctx.lookup("authentication");
    VinayRemote VRemote = home.create(..);

    VinayRemote is your remote interface.

    This works for me.





  3. Radha,
    Please visit
    http://www.geocities.com/lawrence143/jsp.html
    You have answer to your question:)
    Thanks
    Lawrence
  4. Thanx a lot
    I will follow the example cited at http://www.geocities.com/lawrence143/jsp.html in my program

    Regards
    RadhaKrishna