13 Replies Latest reply on Jun 13, 2005 10:17 AM by Fairoz Sharif

    ClassCastException with LocalHome casting

    Fang Yidong Newbie

      I have a CommandEJB,which local interface and home is CommandLocal and CommandLocalHome.I use this CommandEJB to execute classes that implements the Command interface:

      interface Command{
      void execute() throws CommandExecuteException;

      here is the CommandEJB:

      public class CommandEJB implements SessionBean {
      public void execute(Command command) throws CommandException{

      I put CommandEJB.class,Command.class,CommandException.class,CommandLocal.class and CommandLocalHome.class into my-ejb.jar and deploy it as an EJB.

      And I put Command.class,CommandException.class,CommandLocal.class and CommandLocalHome.class into my-client.jar and place it into web module's WEB-INF/lib.

      Now I test it from my test.jsp:

      1 Context ctx=new InitialContext();
      2 Object home1=ctx.lookup(CommandLocalHome.JNDI_NAME);
      3 out.println(home1.getClass().getInterfaces()[0]);
      4 CommandLocalHome home2=(CommandLocalHome)home1;

      If line 4 is deleted, the jsp runs successfully,but if line 4 exists,ClassCastException will be raised.

      Is it a bug of JBoss' class loader?
      How to resolve it?