help needed for "java.io.NotSerializableException: java.util.Ve"

Discussions

EJB programming & troubleshooting: help needed for "java.io.NotSerializableException: java.util.Ve"

  1. hi to all,
    i am using a session less bean A to querry a Entity Bean B , which inturns calls another EntityBean C ,
    finally a ' find' method is invoked on the EntityBean C, In this a vector is created which holds 3 different vectors at different indexes, now the problem i am facing is that when Enity Bean B is returning the final vector to the A , it's firing out a errors that :-

    TRANSACTION COULD NOT BE COMPLETED: RemoteException occurred in server thread;
    ested exception is:
            java.rmi.RemoteException: null; nested exception is:
            java.rmi.ServerException: RemoteException occurred in server thread; ne
    ted exception is:
            java.rmi.RemoteException: null; nested exception is:
            java.io.NotSerializableException: java.util.Vector$1
    java.rmi.ServerException: RemoteException occurred in server thread; nested exc
    ption is:
            java.rmi.RemoteException: null; nested exception is:
            java.rmi.ServerException: RemoteException occurred in server thread; ne
    ted exception is:
            java.rmi.RemoteException: null; nested exception is:
            java.io.NotSerializableException: java.util.Vector$1
    java.rmi.RemoteException: null; nested exception is:
            java.rmi.ServerException: RemoteException occurred in server thread; ne
    ted exception is:
            java.rmi.RemoteException: null; nested exception is:
            java.io.NotSerializableException: java.util.Vector$1
    java.rmi.ServerException: RemoteException occurred in server thread; nested exc
    ption is:
            java.rmi.RemoteException: null; nested exception is:
            java.io.NotSerializableException: java.util.Vector$1
    java.rmi.RemoteException: null; nested exception is:
            java.io.NotSerializableException: java.util.Vector$1
    java.io.NotSerializableException: java.util.Vector$1
            <
    ur any help would be highly appricated to solve out this prob.

    If i try to iterate through this vector it's gives IOR:0232003x343242344asdsd................................................blabla....................

    thanxs in adavance
    Deepak
  2. We had a similar problem just recently. I am not sure if this applies to your problem but here is what we found.

    We had a Collection that we passed into a remote method of a session bean. As soon as we called the method on the session bean we would get the NotSerializableException. It turned out that the Collection was not really a Collection. The developer got the Collection by calling the method values() on a HashMap. This method somehow returns only a view to a collection that is backed by the HashMap. This caused the problem when the object was serialized.
  3. Helpful[ Go to top ]

    This information was extremely helpful.
    After applying it to the problem I was facing, I have this to say: In case the access is made from a servlet, an alternative could be to change the return type from Collection to SortedMap.
    Once you have the SortedMap data available on the servlet that is, one can use the SortMap.Values() function to obtain the Collection and work on it as needed(as far as its away from the Beans!!!).