EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException - Websphere

This is a discussion on EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException - Websphere ; Hi I have deployed an ejb Application in websphere 6.1. I am trying to get and EJB Locla Home using the lookup... Code written in web module to lookup: gwEjbLocalHome = (GWEJBLocalHome)l_ic.lookup ("java:comp/env/" +"ejbName"); and corresponding web.xml configuration is: GW_EJB_Bean ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

  1. EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    Hi
    I have deployed an ejb Application in websphere 6.1.
    I am trying to get and EJB Locla Home using the lookup...
    Code written in web module to lookup:

    gwEjbLocalHome = (GWEJBLocalHome)l_ic.lookup ("java:comp/env/" +"ejbName");

    and corresponding web.xml configuration is:


    GW_EJB_Bean
    Session
    com.gw.ejb.GWEJBLocalHome
    com.gw.ejb.GWEJBLocal
    GW_EJB_Bean
    then chose the Class loader policy: single)

    web applicaion is working fine. ita able get the localHome and able to do the rest of the process

    2. if we sent the Class Loader Policy : Multiple

    when i send request to the servlet its raising the exception:


    java.lang.ClassCastException: com.gw.ejb.EJSLocalStatelessGW_EJB_BeanHome_e9ede7 0f incompatible with com.gw.ejb.GWEJBLocalHome
    at com.gwservices.ejb.GWEJBClient.getLocalEJB(GWEJBCl ient.java:189)
    at com.gwservices.ejb.GWEJBClient.callLocalEJB(GWEJBC lient.java:261)


    Note:
    to resolve this exception i have tried these two options.
    1.
    I have added the EJB application jar as Shared library and added to the web application's share library.
    Still, its same error.

    2.
    I also tried one more option:
    i have selected the _War Classloader policy_ : "Single classloader for applicaion",
    still its same case.


    please advice me what the changes i need to do to make it working without any exceptions when the ClassLoader policy is: Multiple
    Thanks.

  2. Re: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    Hi, your web configuration needs to point to the EJB configuration. Since you did not provide your web configuration, I am providing a code snippet and web.xml snippet:

    Servlet code:
    {code}
    Context context = new InitialContext();
    ShiftFacadeLocalHome shiftFacadeHome = (ShiftFacadeLocalHome) context.lookup("java:comp/env/ShiftFacade");
    {code}

    web.xml
    {code}



    ShiftFacade
    Session
    com.ibm.test.ejb.session.ShiftFacadeLocalHome
    com.ibm.test.ejb.session.ShiftFacadeLocal
    EJBQuery.jar#ShiftFacade

    {code}

    ibm-web-bnd.xmi (generated)
    {code}










    {code}

    Regards,
    Brian

  3. Re: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    Thanks for replying.

    First i like to tell u one thing ....

    I am using web service.
    Internally web services makes call to an Servlet and servlets try to access Local EJB, thats why i said, i am trying to access Local EJB in a web module. If there is difference technically, excuse me.


    I did the Changes whatever u said.
    But I am getting the same Exception:

    java.lang.ClassCastException: com.gw.ejb.EJSLocalStatelessGW_EJB_BeanHome_e9ede7 0f incompatible with com.gw.ejb.GWEJBLocalHome
    at com.gwservices.ejb.GWEJBClient.getLocalEJB(GWEJBCl ient.java:189)
    at com.gwservices.ejb.GWEJBClient.callLocalEJB(GWEJBC lient.java:261)

    Servlet Code :

    {code}
    gwEjbLocalHome = (GWEJBLocalHome)l_ic.lookup ("java:comp/env/" +"ejbName");
    {code}

    web.xml configuration for the same:

    {code}

    GW_EJB_Bean
    Session
    com.gw.ejb.GWEJBLocalHome
    com.gw.ejb.GWEJBLocal
    GW_EJB_Bean.jar#GW_EJB_Bean

    {code}

    generated ibm-application-bnd.xmi

    {code}








    {code}

  4. Re: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    Hi, remove the quotes ("") around the ejbname. Is this a variable?

    Regards,
    Brian

  5. Re: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    "ejbName" is fine. with that there is no problem.
    in actually its different method call i just replaced with constant string.

    The lookup is allways getting success.

    {code}
    gwEjbLocalHome = (GWEJBLocalHome)l_ic.lookup ("java:comp/env/" +"ejbName");

    // if the code is like this...
    Object obj = l_ic.lookup ("java:comp/env/" +"ejbName"); // this line will be executed normally.

    gwEjbLocalHome = (GWEJBLocalHome)obj; //throws the Runtime Exception;
    {code}

    once after the getting the object from JNDI, when the movement it tries to convert it raises the exception.
    That is the issue.

    please advice me to resolve this issue.

    Thanks & Regards

  6. Re: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    Hi, could you please put "GW_EJB_Bean" instead of ejbname in the lookup?

    Regards,
    Brian

  7. Re: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    Hi
    I have done the changes and tested.


    Servlet Code to lookup the local ejb :
    {code}
    // if the code is like this...
    Object obj = l_ic.lookup ("java:comp/env/" +"GW_EJB_Bean"); // this line will be executed normally.
    gwEjbLocalHome = (GWEJBLocalHome)obj; //throws the Runtime Exception;
    {code}

    The lookup is allways getting success.

    once after the getting the object from JNDI. the movement it tries to cast the object, it raises the exception.

    exception:

    java.lang.ClassCastException: com.gw.ejb.EJSLocalStatelessGW_EJB_BeanHome_e9ede7 0f incompatible with com.gw.ejb.GWEJBLocalHome
    at com.gwservices.ejb.GWEJBClient.getLocalEJB(GWEJBCl ient.java:189)


    please advice me to resolve this issue.

    Thanks & Regards

  8. Re: EJBLocalHome lookup - ClassLoader Polict is: Multiple -ClassCastException

    Hi, could you please include your entire servlet code. Also, you may want to regenerate your EJB code.

    Regards,
    Brian

+ Reply to Thread