views:

29

answers:

1

I'm trying to configure ehcache with openjpa. I get the following error:

org.apache.openjpa.lib.util.ParseException: 
Instantiation of plugin "DataCacheManager" with value "ehcache" caused an error 
"java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: ehcache". 
The alias or class name may have been misspelled, or the class may not have be available in the class path. 
Valid aliases for this plugin are: [default]

here's my excerpt from persistence.xml:

        <property name="openjpa.QueryCache" value="ehcache"  />
        <property name="openjpa.DataCacheManager" value="ehcache" />

here's my ehcache.xml:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true">

  <!--  -->
  <cache name="openjpa" maxElementsInMemory="10000"
    maxElementsOnDisk="1000" eternal="false" overflowToDisk="true"
    diskSpoolBufferSizeMB="20" timeToIdleSeconds="300"
    timeToLiveSeconds="600" memoryStoreEvictionPolicy="LFU"
    transactionalMode="on" />
</ehcache>

And here's my pom.xml plugin dependency: net.sf.ehcache ehcache-openjpa 0.2.0

Is there any other way to configure openjpa+ehcache?

A: 

Yes it should work. Make sure that the ehcache-openjpa jar is on your classpath. I know this is slightly more complicated if you are running in a container environment(ie: WAS).

[update]

I know I had this working at one point and I had to do something funny with WAS shared libraries to get this to work, but I can't find any of my notes. I vaugely recollect that the problem had to do with OpenJPA not detecting Ehcache at start up, in turn we didn't register the 'ehcache' aliases.

Try configuring OpenJPA with the following properties :

<property name="openjpa.QueryCache" value="net.sf.ehcache.openjpa.datacache.EhCacheQueryCache"/> <property name="openjpa.DataCacheManager" value="net.sf.ehcache.openjpa.datacache.EhCacheDataCacheManager"/> <property name="openjpa.DataCache" value="net.sf.ehcache.openjpa.datacache.EhCacheDataCache"/> <property name="openjpa.RemoteCommitProvider" value="net.sf.ehcache.openjpa.datacache.NoOpRemoteCommitProvider"/>

[/update]

Rick
Can you provide additional details about the container environemnt? I'm running WAS.
Miguel Ping