1 Reply Latest reply on Apr 1, 2008 10:54 AM by jaikiran pai

    WebApplication fails to lookup SessionBean

    Masoodah Ahmed Newbie


      I have an ear application that runs under jboss 4.2.0.GA version. I have implemented EJB3 session bean.
      The AdSetSchedule Session Bean is bound as shown below in jndi view

      +- DPDS-Enterprise (class: org.jnp.interfaces.NamingContext)
      | +- AdSetScheduleBean (class: org.jnp.interfaces.NamingContext)
      | | +- local (proxy: $Proxy99 implements interface com.dreamplay.dpds.ejb.AdSetScheduleLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
      | | +- remote (proxy: $Proxy98 implements interface com.dreamplay.dpds.ejb.AdSetScheduleRemote

      The war application that uses JavaServer Faces calls the session bean like so.

      try {
      InitialContext ctx = new InitialContext();

      System.out.println("Lookup AdSetScheduleBean");
      Object o = ctx.lookup("DPDS-Enterprise/AdSetScheduleBean/local");
      System.out.println("Done Lookup");
      System.out.println("class name " + o.toString());

      com.dreamplay.dpds.ejb.AdSetScheduleLocal ad = (com.dreamplay.dpds.ejb.AdSetScheduleLocal) o;
      System.out.println("-----Done Lookup");
      System.out.println("class name " + ad.toString());

      } catch (NamingException e) {
      System.out.println("Naming Error occurred: " + e.toString());
      } catch (ClassCastException e) {
      System.out.println("ClassCast Error occurred: " + e.toString());

      In my log I get the following error.
      09:47:38,181 INFO [STDOUT] Lookup AdSetScheduleBean
      09:47:38,181 INFO [STDOUT] Done Lookup
      09:47:38,181 INFO [STDOUT] class name AdSetScheduleBean
      09:47:38,181 INFO [STDOUT] -----------
      09:47:38,181 INFO [STDOUT] ClassCast Error occurred: java.lang.ClassCastException: $Proxy247 cannot be cast to com.dreamplay.dpds.ejb.AdSetScheduleLocal

      I tried casting the object like
      com.dreamplay.dpds.ejb.AdSetScheduleLocal ad = (com.dreamplay.dpds.ejb.AdSetScheduleBean)o;

      Even this gives me the error
      10:04:21,506 INFO [STDOUT] ClassCast Error occurred: java.lang.ClassCastException: $Proxy247 cannot be cast to com.dreamplay.dpds.ejb.AdSetScheduleBean

      What am I doing wrong.
      Can anybody help.