2 Replies Latest reply on Aug 27, 2003 3:11 AM by fredatwork

    Serialization Error with a CMP entity bean

    fredatwork Newbie

      Hello,

      i'm really stuck with a serialization error.

      I have a CMP entity bean named SignalBean that works fine until it only includes field of basic data types (Integer, String). For instance two fields (Code and Type that are String and Integer):
      /**
      * Returns the code
      * @return the code
      *
      * @ejb.persistent-field
      * @ejb.persistence
      * column-name="code"
      * sql-type="VARCHAR"
      *
      * @ejb.interface-method
      */
      public abstract java.lang.String getCode();

      /**
      * Sets the code
      *
      * @param java.lang.String the new code value
      *
      * @ejb.interface-method
      */
      public abstract void setCode(java.lang.String code);

      /**
      * Returns the type of signal
      * @return the type of the signal
      *
      * @ejb.persistent-field
      * @ejb.persistence
      * column-name="nsq_t01"
      * sql-type="INTEGER"
      *
      * @ejb.interface-method
      */
      public abstract java.lang.Integer getType();

      But, whenever I add a "complex" field refering another entity bean (owner refers to a Userbean in the example), I get a serailization error when a sessionbean or a client tries to use the entity bean.

      /**
      * Returns the owner
      * @return the owner
      *
      * @ejb.persistent-field
      * @ejb.persistence
      * column-name="nsq_usr"
      * sql-type="INTEGER"
      *
      * @ejb.interface-method
      *
      * @ejb.relation
      * name="Signal-User"
      * role-name="Signal as a proprietary user"
      * target-ejb="User"
      * target-role-name="User owns several Signals"
      * target-multiple="yes"
      *
      * @jboss.relation
      * fk-column="nsq_usr"
      * related-pk-field="ID"
      *
      */
      public abstract UserLocal getOwner();

      /**
      * Sets the userID
      *
      * @param java.lang.Integer the owner ID
      *
      * @ejb.interface-method
      */
      public abstract void setOwner(UserLocal owner);


      My client uses the SignalBean through the remote home and several EJB finder :

      * @ejb.finder
      * query="SELECT OBJECT(a) FROM Signal as a"
      * signature="java.util.Collection findAll()"
      *
      * @ejb.finder
      * query="SELECT OBJECT(a) FROM Signal as a WHERE a.owner.ID = ?1"
      * signature="java.util.Collection findByOwner(java.lang.Integer id)"
      *
      * @jboss.query
      * signature="java.util.Collection findByOwner(java.lang.Integer id)"
      * query="SELECT OBJECT(a) FROM Signal as a WHERE a.owner.ID = ?1 ORDER BY a.code"
      *

      The finders find the data (a full Collection) but I cannot check its content, let's say with a session bean (see the extract):

      Iterator it=result.iterator();
      while (it.hasNext()) {
      SignalLocal sig = (SignalLocal) it.next();
      logger.info("Found signal " + sig.getCode());

      I get a exception when setCode is Executed is executed. See below.

      When I remove the owner field, the code works and I do not get the exception.

      2003-08-27 09:47:44,774 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Signal] Executing SQL: SELECT code, nsq_t01, counter, timestamp, nsq_usr, nsq_usr FROM sig_signal WHERE (nsq_sig=?)
      2003-08-27 09:47:44,777 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.lang.String com.rubis.app.system.interfaces.SignalLocal.getCode(), causedBy:
      java.sql.SQLException: Unable to load to deserialize result: java.io.EOFException
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.convertToObject(JDBCUtil.java:854)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.getResult(JDBCUtil.java:479)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults(JDBCAbstractCMPFieldBridge.java:378)


      Any clue ??

      Thanks in advance.

      Fred

      PS: I'm using JBOSS 3.0.7 and upgraded to JBOSS 3.2.2 RC2. The same problem happens whatever the version of the app server is used.