6 Replies Latest reply on Aug 7, 2002 10:24 AM by Todd Biske

    Session bean throws java.io.NotSerializableException

    Erden Newbie

      Accessing a remote session bean from another machine with trans-attribute Required throws a java.io.NotSerializableException

      I have client statefull session bean. From that bean I am trying to access from another server remotely another session bean.
      Defining the trans-attribute of the client session bean as

      <ejb-name>ClientSessionBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>Required</trans-attribute>

      throws a java.io.NotSerializableException
      It works fine when you define it

      <ejb-name>ClientSessionBean</ejb-name>
      <method-name>*</method-name>

      <trans-attribute>NotSupported</trans-attribute>
      also it works fine when you have them inside the same jar file and you accessing that remotely.

      Doesn't make any difference the <trans-attribute> of the server session bean. It works fine with both Required and NotSupported.

      I am using jboss-3.1.0alpha build as of 01/08/2002, jdk1.3.1_03, and win2000

      The error stack that I get is as follows.
      2002-08-02 09:09:29,071 ERROR [STDERR] java.rmi.MarshalException: error marshalling arguments; nested exception is:
      java.io.NotSerializableException: org.jboss.tm.TransactionImpl
      2002-08-02 09:09:29,071 ERROR [STDERR] java.io.NotSerializableException: org.jboss.tm.TransactionImpl
      2002-08-02 09:09:29,071 ERROR [STDERR] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1143)
      2002-08-02 09:09:29,071 ERROR [STDERR] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
      2002-08-02 09:09:29,071 ERROR [STDERR] at org.jboss.invocation.MarshalledInvocation.writeExternal(MarshalledInvocation.java:360)
      2002-08-02 09:09:29,071 ERROR [STDERR] at java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:1167)
      2002-08-02 09:09:29,071 ERROR [STDERR] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:361)
      2002-08-02 09:09:29,071 ERROR [STDERR] at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:263)
      2002-08-02 09:09:29,081 ERROR [STDERR] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:127)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:92)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:48)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:175)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:82)
      2002-08-02 09:09:29,081 ERROR [STDERR] at $Proxy260.create(Unknown Source)
      2002-08-02 09:09:29,081 ERROR [STDERR] at bluecycle.eclaims.server.ejb.request.RequestSessionBean.createAuction(RequestSessionBean.java:98)
      2002-08-02 09:09:29,081 ERROR [STDERR] at java.lang.reflect.Method.invoke(Native Method)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:606)
      2002-08-02 09:09:29,081 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:108)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:179)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:61)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:130)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:154)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:303)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:673)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
      2002-08-02 09:09:29,091 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:325)
      2002-08-02 09:09:29,091 ERROR [STDERR] at java.lang.reflect.Method.invoke(Native Method)
      2002-08-02 09:09:29,091 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:236)
      2002-08-02 09:09:29,091 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:147)
      2002-08-02 09:09:29,091 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
      2002-08-02 09:09:29,091 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:143)
      2002-08-02 09:09:29,091 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      2002-08-02 09:09:29,091 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      2002-08-02 09:09:29,091 ERROR [STDERR] at java.lang.Thread.run(Thread.java:479)

        • 1. Re: Session bean throws java.io.NotSerializableException
          dudoes Newbie

          You should return a Serializable value of the Method in session Bean.

          to Do it in XYZ.java:
          ------------------------------------------
          import java.io.*

          ............


          public class XYZ implements Serializable
          {
          ......
          }


          ---------------------------------


          • 2. Re: Session bean throws java.io.NotSerializableException
            Erden Newbie

            All my methods return serializable objects (At both servers). Moreover the method that I am actually trying to call is void.
            This exception is thrown before calling the bussiness method, it is actually when I am trying to create the session object.

            • 3. Re: Session bean throws java.io.NotSerializableException
              Joel Vogt Master

              You might want to check any exceptions you are throwing from your methods are okay as well

              • 4. Re: Session bean throws java.io.NotSerializableException
                Erden Newbie

                No there are no user defined exceptions thrown. Below is an example of the code that I am using
                This is my client session ejb on machine A
                public class ClientSessionBean implements SessionBean {
                private SessionContext ctx;
                public ClientSessionBean(){}
                public void setSessionContext(SessionContext context) {ctx = context;}
                public void ejbActivate(){}
                public void ejbPassivate(){}
                public void ejbRemove(){}
                public void ejbCreate() throws CreateException {}

                public void clientMethod() {
                try {
                ServerSessionHome serverSessionHome = (ServerSessionHome)PortableRemoteObject.narrow(namingContext.lookup("ServerSessionHome"),ServerSessionHome.class);
                // The next line throws the serializable exception
                ServerSession serverSession = serverSessionHome.create();
                // It doesn't reach here
                serverSession.remoteMethod();
                }
                catch (Exception exp) { exp.printStackTrace(); }
                }
                }

                This is my server session ejb on machine B
                public class ServerSessionBean implements SessionBean {
                private SessionContext ctx;
                public ServerSessionBean(){}
                public void setSessionContext(SessionContext context) {ctx = context;}
                public void ejbActivate(){}
                public void ejbPassivate(){}
                public void ejbRemove(){}
                public void ejbCreate() throws CreateException {}

                public void remoteMethod()
                {
                // Do nothing
                }
                }

                • 5. Re: Session bean throws java.io.NotSerializableException
                  Erden Newbie

                  No there are no user defined exceptions thrown. Below is an example of the code that I am using
                  This is my client session ejb on machine A
                  public class ClientSessionBean implements SessionBean {
                  private SessionContext ctx;
                  public ClientSessionBean(){}
                  public void setSessionContext(SessionContext context) {ctx = context;}
                  public void ejbActivate(){}
                  public void ejbPassivate(){}
                  public void ejbRemove(){}
                  public void ejbCreate() throws CreateException {}

                  public void clientMethod() {
                  try {
                  ServerSessionHome serverSessionHome = (ServerSessionHome)PortableRemoteObject.narrow(namingContext.lookup("ServerSessionHome"),ServerSessionHome.class);
                  // The next line throws the serializable exception
                  ServerSession serverSession = serverSessionHome.create();
                  // It doesn't reach here
                  serverSession.remoteMethod();
                  }
                  catch (Exception exp) { exp.printStackTrace(); }
                  }
                  }

                  This is my server session ejb on machine B
                  public class ServerSessionBean implements SessionBean {
                  private SessionContext ctx;
                  public ServerSessionBean(){}
                  public void setSessionContext(SessionContext context) {ctx = context;}
                  public void ejbActivate(){}
                  public void ejbPassivate(){}
                  public void ejbRemove(){}
                  public void ejbCreate() throws CreateException {}

                  public void remoteMethod()
                  {
                  // Do nothing
                  }
                  }

                  • 6. Re: Session bean throws java.io.NotSerializableException
                    Todd Biske Newbie

                    I've run into this as well, and the posted solution was to change the JBoss configuration to use Tyrex as the transaction manager. The out-of-the-box transaction manager doesn't support distributed transactions (hence, the TransactionImpl class is not serializable). Unfortunately, I haven't been able to get the 3.0.0 distribution to work with Tyrex. Evidently, there's a tyrex-patch.jar in the current nightly source, but merely dropping that into the pre-packaged 3.0.0 distribution causes all sorts of problems. Do a search on Tyrex in this forum, and you'll find the messages containing the details on all of this.