2 Replies Latest reply on Apr 26, 2005 11:02 AM by Christian Percy

    Some problems with the optimistic locking strategy.

    Christian Percy Newbie

      I am trying to use "org.jboss.ejb.plugins.lock.JDBCOptimisticLock" in the "Standard CMP 2.x EntityBean" container configuration with commit option ?A? in conjunction with optimistic read or modified locking strategy tags of the entity beans in jbosscmp-jdbc.xml.
      If I do not define any strategy then all seems well, As soon as I define one of the optimistic read or modified strategies the I get exceptions.
      When specifying the read strategy:

      <optimistic-locking>
      <read-strategy/>
      </optimistic-locking>

      in the entity beans tags in jbosscmp-jdbc.xml
      I get an exception thrown:

      2005-04-24 11:39:21,546 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.ejb.EJBLocalObject.remove() throws javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
      java.sql.SQLException: ORA-00932: inconsistent datatypes: expected - got BLOB

      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
      at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
      at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
      at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
      at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
      at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
      at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
      at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeUpdate(CachedPreparedStatement.java:63)
      at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:335)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:136)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:651)
      at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:369)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:394)
      at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:693)
      at org.jboss.ejb.GlobalTxEntityMap$2.synchronize(GlobalTxEntityMap.java:134)
      at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:253)
      at org.jboss.ejb.GlobalTxEntityMap.synchronizeEntities(GlobalTxEntityMap.java:166)
      at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:119)
      at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:496)

      When specifying the modified strategy:

      <optimistic-locking>
      <modified-strategy/>
      </optimistic-locking>

      The error (at a totaly different location in the application changes to:

      2005-04-24 11:59:04,031 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract com.ascom.opentas.as.element.internal.entitybeans.Simpleattribute com.ascom.opentas.as.element.internal.entitybeans.SimpleattributeHome.findAttribute(java.lang.Long,java.lang.String) throws javax.ejb.FinderException, causedBy:
      javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0, id=7191
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:155)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:651)
      at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:369)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:394)
      at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:693)
      at org.jboss.ejb.GlobalTxEntityMap$2.synchronize(GlobalTxEntityMap.java:134)
      at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:253)
      at org.jboss.ejb.GlobalTxEntityMap.synchronizeEntities(GlobalTxEntityMap.java:166)
      at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:119)
      at org.jboss.ejb.EntityContainer.findSingleObject(EntityContainer.java:1040)
      at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:627)

      Could anyone help me out here.
      What am I doing wrong.

      We currently are using jboss-3.2.6RC2 (with JRE 1.4.2_07) together with Oracle9i as DB

      Thanks for any suggestion.

      Christian Percy

        • 1. Re: Some problems with the optimistic locking strategy.
          Alexey Loubyansky Master

          The BLOB issue looks like an inconsistent type mapping. Unless you can figure it out looking at the table and fields, you'll have to add trace logging for org.jboss.ejb.plugins.cmp and see what parameters of what types and values are set on prepared statements.
          Second exception shows that optimitic locking is working properly, i.e. it's an optimistic failure.

          • 2. Re: Some problems with the optimistic locking strategy.
            Christian Percy Newbie

             

            "alex.loubyansky@jboss.com" wrote:
            The BLOB issue looks like an inconsistent type mapping. Unless you can figure it out looking at the table and fields, you'll have to add trace logging for org.jboss.ejb.plugins.cmp and see what parameters of what types and values are set on prepared statements.
            Second exception shows that optimitic locking is working properly, i.e. it's an optimistic failure.


            Regarding the read strategy.

            Here is the field definition of the jbosscmp-jdbc.xml

            <cmp-field>
            <field-name>evaluator</field-name>
            <column-name>EVALUATOR</column-name>

            <jdbc-type>BLOB</jdbc-type>
            <sql-type>BLOB</sql-type>

            </cmp-field>


            What I do not understand is why the application then works perfectly well when I leaf the tags for the optimistic locking strategy out?

            To enable the tracing I added following category specs to the log4j.xml file





            It does not output anything below the DEBUG priority! (I also changed the Threshold of the appender to "TRACE" but that did not change anything
            So here is what I got. The first line is de end of the JBoss start.


            2005-04-26 16:48:03,390 INFO [org.jboss.system.server.Server] JBoss (MX MicroKernel) [3.2.6RC2 (build: CVSTag=Branch_3_2 date=200409270100)] Started in 32s:641ms
            2005-04-26 16:48:56,343 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.TraderEntity#findByPrimaryKey] Executing SQL: SELECT t0_TraderEntity.NAME FROM TRADERENTITY t0_TraderEntity WHERE t0_TraderEntity.NAME=?
            2005-04-26 16:48:56,375 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.TraderEntity] load relation SQL: SELECT ID FROM EVALUATOR WHERE (TRADERENTITY_NAME=?)
            2005-04-26 16:48:56,796 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Evaluator] Executing SQL: SELECT ID, EVALUATOR FROM EVALUATOR WHERE (ID=?) OR (ID=?) OR (ID=?) OR (ID=?) OR (ID=?) OR (ID=?) OR (ID=?) OR (ID=?) OR (ID=?) OR (ID=?)
            2005-04-26 16:48:57,609 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.Evaluator] Executing SQL: UPDATE EVALUATOR SET EVALUATOR=? WHERE ID=? AND EVALUATOR=?
            2005-04-26 16:48:57,625 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.ejb.EJBLocalObject.remove() throws javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
            java.sql.SQLException: ORA-00932: inconsistent datatypes: expected - got BLOB

            at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
            at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
            at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
            at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
            at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
            at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
            at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
            at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
            at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
            at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeUpdate(CachedPreparedStatement.java:63)
            at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:335)

            Regarding the modified strategy I can assure you that the error occus with only a single user having a single "Required" transaction running at any given time
            So how could the data be modified outside the trasaction if there is no other transaction?

            Can you give me an additional hint on how to investigate this problem more in depth?
            Your ever grateful JBoss user