2 Replies Latest reply: May 3, 2010 11:07 AM by 770456 RSS

    BDB JE HA: ClassCastException while initializing ReplicatedEnvironment

    770456
      JDK: Sun 1.6.0
      BDB JE: je-4.0.92
      Platform: Fedora 12 Linux

      Taking heavily from the example StockQoute application included in the je-4.0.92 distribution, I've written some simple testing code to bring up a ReplicatedEnvironment. During the initialization phase, I get the following stack trace:

      java.lang.ClassCastException: com.sleepycat.je.dbi.EnvironmentImpl cannot be cast to com.sleepycat.je.rep.impl.RepImpl
      at com.sleepycat.je.rep.ReplicatedEnvironment.<init>(ReplicatedEnvironment.java:431)
      at com.sleepycat.je.rep.ReplicatedEnvironment.<init>(ReplicatedEnvironment.java:316)
      at com.sleepycat.je.rep.ReplicatedEnvironment.<init>(ReplicatedEnvironment.java:377)


      Here is the code I'm using to start the environment:


      .
      .
      .
      envHome = new File(StorageConfig.envHomeDirName);
      //create the target dir if it doesn't already exist
      if(!envHome.exists())
      envHome.mkdirs();

      envConfig = new EnvironmentConfig();
      envConfig.setTransactional(true);
      envConfig.setAllowCreate(true);
      Durability durability = new Durability(Durability.SyncPolicy.WRITE_NO_SYNC,
      Durability.SyncPolicy.WRITE_NO_SYNC,
      Durability.ReplicaAckPolicy.SIMPLE_MAJORITY);

      envConfig.setDurability(durability);
      env = new Environment(envHome, envConfig);

      repConfig = new ReplicationConfig();
      /* Set consistency policy for replica. */
      TimeConsistencyPolicy consistencyPolicy = new TimeConsistencyPolicy
      (1, TimeUnit.SECONDS, /* 1 sec of lag */
      3, TimeUnit.SECONDS /* Wait up to 3 sec */);
      repConfig.setConsistencyPolicy(consistencyPolicy);

      /* Wait up to two seconds for commit acknowledgments. */
      repConfig.setReplicaAckTimeout(2, TimeUnit.SECONDS);

      repConfig.setNodeName(StorageConfig.nodeName);
      repConfig.setNodeHostPort(StorageConfig.hostPort);
      repConfig.setHelperHosts(StorageConfig.helperHost);
      repConfig.setGroupName(StorageConfig.groupName);

      repEnv = new ReplicatedEnvironment(envHome, repConfig, envConfig);



      The last line in the code above is where the Exception is thrown.