EJB design: ClassCastException

  1. ClassCastException (3 messages)

    I am working in VisualAge for java. I am getting
    ClassCastException in the following line of code. The getTypesHome() is a method to lookup the Types' HomeInterface, so I can call its method, FindAll(), where FindAll () returns an Enumeration of "Types". I would appreciated it if you have any suggestion in this matter. Thank you in advance.

    Enumeration types = getTypesHome().findAll();

    while (types.hasMoreElements()) {

    out.println("Types : " + ((Types)types.nextElement()).getName () + "<br>");


    Threaded Messages (3)

  2. ClassCastException[ Go to top ]


    I don't know which Application Server you are using, but if it implements EJB 1.1 then in order to cast remote objects you have to use PortableRemoteObject. Here example:
    MyRemote myRemoteVar = (MyRemote) javax.rmi.PortableRemoteObject.narrow(enumeration.nextElement(), MyRemote.class);
    Try this code, it has to work in EJB 1.1 environment.

    Best regards,

  3. ClassCastException[ Go to top ]


    thank you for the solution.
  4. ClassCastException[ Go to top ]

    Read the weblogic documentation for this. this is to do with improper loading of classes with weblogic and JVM classloader.