telalgroup - 2011-04-10

I have the problem with distributed ehcache and hibernate in the standalone applications. I have created two nodes which work on the different JVM for

testing destributed cache. I use RMI replication but it doesn't work.

The first application has following configuration:

Java class:

@Entity
@Table(name="SEX")
@Cache(region = "Cache1", usage= CacheConcurrencyStrategy.READ_WRITE)

public class Sex implements Serializable{

@Id
@Column(name="sex_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int sexId;

@Column(name="sex_name")
private String sexName;

public int getSexId() {
return sexId;
}

public void setSexId(int sexId) {
this.sexId = sexId;
}

public String getSexName() {
return sexName;
}

public void setSexName(String sexName) {
this.sexName = sexName;
}

}

ehcache.xml:

<ehcache>

<diskStore path="java.io.tmpdir"/>

<defaultCache
maxElementsInMemory="0"
eternal="false"
timeToIdleSeconds="1200"
timeToLiveSeconds="1200">
</defaultCache>

<!- For RMI replication (Setting the peer provider factory) ->
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual, rmiUrls=//127.0.0.1:40002/Cache1"
propertySeparator=","/>

<!- For RMI replication (Setting the peer listener factory) ->
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=localhost, port=40001, socketTimeoutMillis=120000"
propertySeparator=","/>

<cache name="Cache1" maxElementsInMemory="1000"
eternal="true"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToLiveSeconds="3000"
timeToIdleSeconds="3000"
memoryStoreEvictionPolicy="LFU">

<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true,
replicatePuts=true,
replicatePutsViaCopy=true,
replicateUpdates=true,
replicateUpdatesViaCopy=true,
replicateRemovals=true"/>

<!- RMI Cache bootstrap ->
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
propertySeparator=","/>
</cache>

</ehcache>

The second application has following configuration:

Java class:

@Entity
@Table(name="SEX")
@Cache(region = "Cache2", usage= CacheConcurrencyStrategy.READ_WRITE)

public class Sex implements Serializable {

@Id
@Column(name="sex_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int sexId;

@Column(name="sex_name")
private String sexName;

public int getSexId() {
return sexId;
}

public void setSexId(int sexId) {
this.sexId = sexId;
}

public String getSexName() {
return sexName;
}

public void setSexName(String sexName) {
this.sexName = sexName;
}

}

ehcache.xml:

<ehcache>

<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="0"
eternal="false"
timeToIdleSeconds="1200"
timeToLiveSeconds="1200">
</defaultCache>

<!- For RMI replication (Setting the peer provider factory) ->
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual, rmiUrls=//127.0.0.1:40001/Cache2"
propertySeparator="," />

<!- For RMI replication (Setting the peer listener factory) ->
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=localhost, port=40002, socketTimeoutMillis=120000"
propertySeparator=","/>

<cache name="Cache2" maxElementsInMemory="1000"
eternal="true"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToLiveSeconds="3000"
timeToIdleSeconds="3000"
memoryStoreEvictionPolicy="LFU">

<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true,
replicatePuts=true,
replicatePutsViaCopy=true,
replicateUpdates=true,
replicateUpdatesViaCopy=true,
replicateRemovals=true"/>

<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
propertySeparator=","/>

</cache>

</ehcache>

Could you please find the problem