0 Replies Latest reply on May 2, 2003 1:00 AM by milowe

    getEJBObject() ClassCastException

    milowe

      Hi

      I am storing a Handle in a HttpSession for session management.
      The EJB is a CMP stateful session bean (remote interface is MySession).

      static private class SessionHandle implements HttpSessionActivationListener, HttpSessionBindingListener {
      /** The handle for the EJB serving this session
      */
      private Handle ejbHandle = null;

      SessionHandle(Handle handle) {
      this.ejbHandle = handle;
      }
      .
      .
      .
      }

      Storing bean handle :

      protected void setMySession(MySession mySession, HttpSession httpSession) throws RemoteException{
      httpSession.setAttribute(MY_SESSION, new SessionHandle(mySession.getHandle()));
      }


      Getting bean handle :

      protected MySession getMySession(HttpSession httpSession){
      SessionHandle sessionHandle = (SessionHandle)httpSession.getAttribute(MY_SESSION);
      if (null == sessionHandle) {
      return null;
      }
      try {
      // This line throws ClassCastException in 3.2.0
      return (MySession)sessionHandle.ejbHandle.getEJBObject();
      } catch (Exception e) {
      logger.warn("getMySession, failed to retreive session : " + e.getMessage());

      }
      return null;
      }

      This scheme works on JBoss3.0.6 but I get ClassCastException when executing the same ear on 3.2.0. Anyone got a clue why this wont work using 3.2.0?