1 Reply Latest reply on Oct 9, 2002 5:39 AM by Julian Gosnell

    javax.rmi.MarshalException from servlet trying to store sess

    Pete Newbie

      Hi,
      Just realized this was probably the better forum in which to post this message.

      I am trying to store the handle to my stateful session ejb in the HttpSession, so each web session has its own stateful session EJB. Here is my code: (in doPost)
      --------------------------------------------
      Bobo bobo = null;
      // if this is a new session, create a bobo bean for it. If not,
      // restore this session's bobo bean
      if (request.getSession().isNew() == true) {
      try {
      InitialContext ic = new InitialContext();
      Object objRef = ic.lookup("ejb/bobo");
      BoboHome home = (BoboHome)PortableRemoteObject.narrow(objRef, BoboHome.class);
      bobo = home.create();
      } catch (NamingException ne) {
      ne.printStackTrace();
      } catch (CreateException ce) {
      ce.printStackTrace();
      }
      } else {
      Handle handle=(Handle)request.getSession().getAttribute("boboHandle");
      bobo =(Bobo) handle.getEJBObject();
      }

      ... servlet code executing the bean...

      // store the bean reference
      Handle handle = bobo.getHandle();
      request.getSession().setAttribute("boboHandle", handle);
      out.close();
      -------------------------------------------------

      I am getting this exception when I hit the page... seems to have trouble with the setAttribute.


      14:04:53,085 ERROR [MarshallingInterceptor] could not set Attribute: boboHandle:org.jboss.proxy.ejb.handle.Statefu
      lHandleImpl@9c6201
      java.rmi.MarshalException: Invalid remote object
      at java.rmi.server.RemoteObject.writeObject(RemoteObject.java:342)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:795)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1294)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.writeExternal(JRMPInvokerProxy.java:149)
      at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1265)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1243)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1330)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1302)
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1245)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
      at org.mortbay.j2ee.session.MarshallingInterceptor.marshal(MarshallingInterceptor.java:70)
      at org.mortbay.j2ee.session.MarshallingInterceptor.setAttribute(MarshallingInterceptor.java:117)
      at org.mortbay.j2ee.session.StateInterceptor.setAttribute(StateInterceptor.java:46)
      at org.mortbay.j2ee.session.BindingInterceptor.setAttribute(BindingInterceptor.java:111)
      at org.mortbay.j2ee.session.StateInterceptor.setAttribute(StateInterceptor.java:46)
      at org.mortbay.j2ee.session.TypeCheckingInterceptor.setAttribute(TypeCheckingInterceptor.java:68)
      at org.mortbay.j2ee.session.StateAdaptor.setAttribute(StateAdaptor.java:283)
      at com.quadfore.qserver.speechcode.servlet.SpeechCodeServlet.doPost(SpeechCodeServlet.java:161)
      at com.quadfore.qserver.speechcode.servlet.SpeechCodeServlet.doGet(SpeechCodeServlet.java:62)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:344)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:313)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:554)
      at org.mortbay.jetty.servlet.WebApplicationHandler.handle(WebApplicationHandler.java:199)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1572)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1522)
      at org.mortbay.http.HttpServer.service(HttpServer.java:795)
      at org.jboss.jetty.Jetty.service(Jetty.java:531)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:784)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:941)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:799)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:186)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:322)
      at org.mortbay.util.ThreadPool$JobRunner.run(ThreadPool.java:716)
      at java.lang.Thread.run(Thread.java:536)


      Any ideas? What am I doing wrong?

      Thanks-
      Pete

        • 1. Re: javax.rmi.MarshalException from servlet trying to store
          Julian Gosnell Expert


          You have specified that your app is - if this is not intentional, you are opening a can of worms that would be better left closed.

          If it is intentional, depending on your JBoss/Jetty version (what is it?) you should be able to drop the bean straight into the session. There is code in there which will be able to distribute it (using it's handle). I do this in my testsuite and have never had any trouble.

          I will add a handle test to the suite ASAP.

          Let me know how you get on,


          Jules