Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-1235

TimedObject id persistence fails on restart

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Major
    • JBossAS-4.0.2 Final
    • JBossAS-4.0.0 Final
    • CMP service
    • None

    Description

      SourceForge Submitter: cstach .
      Upon restarting JBoss, persisted timers throw this SQL
      exception because it seems that the entity bean that
      implements the TimedObject had its primary key (Long)
      converted into a byte array.

      java.sql.SQLException: Cannot convert class [B to SQL
      type requested due to java.lang.ClassCastException -
      null
      at
      com.mysql.jdbc.PreparedStatement.setObject
      (PreparedStatement.java:922)
      at
      com.mysql.jdbc.PreparedStatement.setObject
      (PreparedStatement.java:944)
      at
      org.jboss.resource.adapter.jdbc.WrappedPreparedStatem
      ent.setObject(WrappedPreparedStatement.java:615)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCParameterSetter$5.se
      tNotNull(JDBCParameterSetter.java:130)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCParameterSetter$JDB
      CAbstractParameterSetter.set
      (JDBCParameterSetter.java:56)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFi
      eldBridge.setArgumentParameters
      (JDBCAbstractCMPFieldBridge.java:354)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFi
      eldBridge.setPrimaryKeyParameters
      (JDBCAbstractCMPFieldBridge.java:343)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.se
      tPrimaryKeyParameters(JDBCEntityBridge.java:770)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.e
      xecute(JDBCLoadEntityCommand.java:157)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.e
      xecute(JDBCLoadEntityCommand.java:72)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEnt
      ity(JDBCStoreManager.java:631)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEnt
      ity(JDBCStoreManager.java:613)
      at
      org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity
      (CMPPersistenceManager.java:391)
      at
      org.jboss.resource.connectionmanager.CachedConnection
      Interceptor.loadEntity
      (CachedConnectionInterceptor.java:351)
      at
      org.jboss.ejb.plugins.EntitySynchronizationInterceptor.inv
      oke(EntitySynchronizationInterceptor.java:232)
      at
      org.jboss.resource.connectionmanager.CachedConnection
      Interceptor.invoke
      (CachedConnectionInterceptor.java:185)
      at
      org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke
      (EntityReentranceInterceptor.java:111)
      at
      org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke
      (EntityInstanceInterceptor.java:211)
      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.CallValidationInterceptor.invoke
      (CallValidationInterceptor.java:48)
      at
      org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
      (AbstractTxInterceptor.java:105)
      at
      org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransacti
      ons(TxInterceptorCMT.java:283)
      at
      org.jboss.ejb.plugins.TxInterceptorCMT.invoke
      (TxInterceptorCMT.java:149)
      at
      org.jboss.ejb.plugins.SecurityInterceptor.invoke
      (SecurityInterceptor.java:128)
      at org.jboss.ejb.plugins.LogInterceptor.invoke
      (LogInterceptor.java:191)
      at
      org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invok
      e(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke
      (EntityContainer.java:514)
      at org.jboss.ejb.Container.invoke
      (Container.java:854)
      at
      org.jboss.ejb.txtimer.TimedObjectInvokerImpl.callTimeout
      (TimedObjectInvokerImpl.java:63)
      at
      org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run
      (TimerImpl.java:472)
      at java.util.TimerThread.mainLoop
      (Timer.java:432)
      at java.util.TimerThread.run(Timer.java:382)

      11:44:21,750 ERROR [TimerImpl] Error invoking
      ejbTimeout: javax.ejb.EJBException: Internal error
      setting parameters for field id; CausedByException is:
      Cannot convert class [B to SQL type requested
      due to java.lang.ClassCastException - null

      11:44:21,750 WARN [TimerImpl] Timer was not
      registered with Tx, reseting state: [id=1target=
      [target=jboss.j2ee:jndiName=ejb/mdf/Campaign,service=E
      JB,pk=[B@5c0f8f],remaining=-
      59694750,periode=0,in_timeout]

      11:44:21,859 ERROR [LogInterceptor] EJBException in
      method: public abstract void
      javax.ejb.TimedObject.ejbTimeout(javax.ejb.Timer),
      causedBy:
      java.sql.SQLException: Cannot convert class [B to SQL
      type requested due to java.lang.ClassCastException -
      null
      at
      com.mysql.jdbc.PreparedStatement.setObject
      (PreparedStatement.java:922)
      at
      com.mysql.jdbc.PreparedStatement.setObject
      (PreparedStatement.java:944)
      at
      org.jboss.resource.adapter.jdbc.WrappedPreparedStatem
      ent.setObject(WrappedPreparedStatement.java:615)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCParameterSetter$5.se
      tNotNull(JDBCParameterSetter.java:130)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCParameterSetter$JDB
      CAbstractParameterSetter.set
      (JDBCParameterSetter.java:56)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFi
      eldBridge.setArgumentParameters
      (JDBCAbstractCMPFieldBridge.java:354)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFi
      eldBridge.setPrimaryKeyParameters
      (JDBCAbstractCMPFieldBridge.java:343)
      at
      org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.se
      tPrimaryKeyParameters(JDBCEntityBridge.java:770)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.e
      xecute(JDBCLoadEntityCommand.java:157)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.e
      xecute(JDBCLoadEntityCommand.java:72)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEnt
      ity(JDBCStoreManager.java:631)
      at
      org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEnt
      ity(JDBCStoreManager.java:613)
      at
      org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity
      (CMPPersistenceManager.java:391)
      at
      org.jboss.resource.connectionmanager.CachedConnection
      Interceptor.loadEntity
      (CachedConnectionInterceptor.java:351)
      at
      org.jboss.ejb.plugins.EntitySynchronizationInterceptor.inv
      oke(EntitySynchronizationInterceptor.java:232)
      at
      org.jboss.resource.connectionmanager.CachedConnection
      Interceptor.invoke
      (CachedConnectionInterceptor.java:185)
      at
      org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke
      (EntityReentranceInterceptor.java:111)
      at
      org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke
      (EntityInstanceInterceptor.java:211)
      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.CallValidationInterceptor.invoke
      (CallValidationInterceptor.java:48)
      at
      org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext
      (AbstractTxInterceptor.java:105)
      at
      org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransacti
      ons(TxInterceptorCMT.java:283)
      at
      org.jboss.ejb.plugins.TxInterceptorCMT.invoke
      (TxInterceptorCMT.java:149)
      at
      org.jboss.ejb.plugins.SecurityInterceptor.invoke
      (SecurityInterceptor.java:128)
      at org.jboss.ejb.plugins.LogInterceptor.invoke
      (LogInterceptor.java:191)
      at
      org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invok
      e(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.EntityContainer.internalInvoke
      (EntityContainer.java:514)
      at org.jboss.ejb.Container.invoke
      (Container.java:854)
      at
      org.jboss.ejb.txtimer.TimedObjectInvokerImpl.callTimeout
      (TimedObjectInvokerImpl.java:63)
      at
      org.jboss.ejb.txtimer.TimerImpl$TimerTaskImpl.run
      (TimerImpl.java:472)
      at java.util.TimerThread.mainLoop
      (Timer.java:432)
      at java.util.TimerThread.run(Timer.java:382)

      11:44:21,859 ERROR [TimerImpl] Error invoking
      ejbTimeout: javax.ejb.EJBException: Internal error
      setting parameters for field id; CausedByException is:
      Cannot convert class [B to SQL type requested
      due to java.lang.ClassCastException - null

      11:44:21,859 WARN [TimerImpl] Timer was not
      registered with Tx, reseting state: [id=2target=
      [target=jboss.j2ee:jndiName=ejb/mdf/Campaign,service=E
      JB,pk=[B@a826f5],remaining=-
      59688859,periode=0,in_timeout]

      I don't know if this is the exact same problem (I haven't
      checked the JBoss source yet), but I ran into something
      very similar before with JBoss CMP. I used
      org.jboss.invocation.MarshalledValue.get() on the
      column.

      switch (resultSetMetaData.getColumnType(column)) {
      case Types.BINARY:
      case Types.VARBINARY: {
      byte[] bytes = resultSet.getBytes(column);

      InputStream inputStream =
      new ByteArrayInputStream(bytes);

      ObjectInputStream ois =
      new ObjectInputStream(inputStream);

      Object obj = ois.readObject();

      if (obj instanceof MarshalledValue)

      { return ((MarshalledValue) obj).get(); } else { return obj; }
      }

      break;

      case Types.BLOB:
      case Types.LONGVARBINARY: {
      InputStream inputStream =
      resultSet.getBinaryStream(column);

      ObjectInputStream ois =
      new ObjectInputStream(inputStream);

      Object obj = ois.readObject();

      if (obj instanceof MarshalledValue) { return ((MarshalledValue) obj).get(); }

      else

      { return obj; }

      }

      break;

      [...]

      }

      Attachments

        Activity

          People

            tdiesler@redhat.com Thomas Diesler
            sourceforge-user SourceForge legacy user (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: