0 Replies Latest reply on Sep 12, 2005 5:34 AM by Sebastian Rohde

    EJB3RC1 - serialization problem

    Sebastian Rohde Newbie


      I have a problem that appeared recently after i changed the version of EJB from Preview 5 to RC1.

      An object, for example an ArrayList is serialized to a binary large object (java.sql.blob) with the help of the ObjectOutputStream method and the org.hibernate.Hibernate method.
      This blob is stored within MySQL by using an EntityBean as a data access object. The Entity has a private member variable containing this blob.

      Up to this point everything works fine.

      But when the blob should be read and deserialized an exception appears.
      "java.lang.IllegalStateException: Blobs may not be accessed after serialization"

      It appears since i migrated from JBoss4.0.2final with EJB3Preview5
      to JBoss4.0.3RC2 with EJB3RC1 (this configuration is the latest).
      This migration also enforced me to update our MySQL server version from 4.0.21 to the new 4.1.14

      I noticed the same problem when compiling and executing the official example:
      (which formerly worked without any problem)

      Within the source code the exception is thrown here when trying to read the object from the ois input stream object:

      public ArrayList<Long> createLongArrayListFromBlob(Blob blob) throws MosesPersistencyException {
       ArrayList <Long> alist = null;
       try {
       // create an input stream from the blob
       ObjectInputStream ois = new ObjectInputStream(blob.getBinaryStream());
       // extract the ArrayList and return it
       alist = (ArrayList <Long>) ois.readObject();
       } catch (Exception exc) {
       throw new MosesPersistencyException(exc.toString());
       return alist;

      I don't know what might be the problem. Maybe it is a bug and shall be reported? Because the fact that even the official example doesn't seem to work...

      As written above, i am using the following:
      - JBoss-4.0.3RC2 together with EJB3RC1
      - MySQL server version 4.1.14
      - MySQL-Connector-Java-3.1.10