1 Reply Latest reply on May 26, 2006 3:24 PM by Philip Wu

    java.io.StreamCorruptedException: invalid stream header

    taiwuco Newbie

      I use postgresql 7.3 (UTF8)+ jboss3.2.2. I can persist image files as byte[] onto a field with the type of bytea on postgresql. When I tried to retrieve the field via CMP, I got the following errors:
      java.sql.SQLException: Unable to load to deserialize result: java.io.StreamCorruptedException: invalid stream header
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.convertToObject(JDBCUtil.java:854)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.convertToObject(JDBCUtil.java:803)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.getResult(JDBCUtil.java:455)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults(JDBCAbstractCMPFieldBridge.java:378)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:203)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:83)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:634)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:616)
      at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:395)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:353)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:232)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
      at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:82)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:174)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)

      ----------------
      I use ImageIO.write(image, "JPEG", baos) and baos.toByteArray() to get the byte[] and store in a POJO. my jbosscmp_jdbc is like
      <cmp-field>
      <field-name>photo</field-name>
      <column-name>Photo</column-name>
      <jdbc-type>VARBINARY</jdbc-type>
      <sql-type>BYTEA</sql-type>
      </cmp-field>
      Can anyone tell me what I should do?