4 Replies Latest reply on Jun 22, 2009 2:16 PM by vishwasoft

    JBosscache dirty read even though isolation is REPEATABLE_RE

    vishwasoft

      I'm trying to evaluate the JBossCache for our application
      I'm getting dirty read even though I rollback transaction. I tried this with EJB3 Stateless session bean BMT.

      Could you please anyone help me on this prolbem, Am I making anything wrong?

      Here is the code

      public class TestEntity {

      private int array[] = new int[100000];

      public void update(int value) {

      for (int i = 0; i < array.length; i++) {
      array [ i ]=value;
      }

      }

      public int[] getArray() {
      return array;
      }
      }


      Stateless Bean code to update cache

      Stateless Bean 1

      public void updateArray(int value) {
      TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      try {
      tm.begin();
      String key = node.getFqn().toString();
      TestEntity t = (TestEntity) node.get(key);
      if(t != null) {
      t.update(value);
      node.put(key, t);
      }
      tm.rollback();
      } catch (Exception e) {
      try {
      tm.rollback();
      }catch(Exception ex1) {
      ex1.printStackTrace();
      }
      e.printStackTrace();
      }
      }

      Stateless Bean 2 to read and validating array

      public boolean validateArray() {
      TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
      try {
      tm.begin();
      cache.getInvocationContext().getOptionOverrides().setForceWriteLock(true);
      int a[] = readArray();
      int value = a[0];
      for (int i = 0; i < a.length; i++) {
      if(a != value) {
      System.out.println(a
      +":"+value);
      sctx.getUserTransaction().rollback();
      return false;
      }
      }
      tm.commit();
      }catch(Exception ex) {
      try {
      tm.rollback();
      }catch(Exception ex1) {
      ex1.printStackTrace();
      }
      ex.printStackTrace();
      }
      return true;
      }

      Configuration file:
      I have used configuration file example for cache configuration