2010-08-19 61 views
0

我试图用openjpa配置ehcache。我得到以下错误:使用EhCache配置OpenJPA 1.3.1:未找到插件/别名

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] 

,这里是我摘录的persistence.xml:

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

这里是我的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> 

这是我的pom.xml的插件依赖性: net.sf.ehcache ehcache-openjpa 0.2.0

是否有任何其他方式来配置openjpa + ehcache?

回答

0

是的,它应该工作。确保ehcache-openjpa jar包在您的类路径中。我知道如果你在一个容器环境中运行(例如:WAS),这会稍微复杂一些。

[更新]

我知道我必须在一个点这方面的工作,我不得不做一些有趣的那只共享库得到这个工作,但我无法找到任何我的笔记。我大概记得这个问题与OpenJPA在启动时没有检测到Ehcache有关,反过来我们没有注册'ehcache'别名。

尝试具有以下属性配置的OpenJPA:

<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"/>

[/更新]

+0

你能否提供关于容器environemnt其他详细信息?我正在运行WAS。 – 2010-08-20 09:40:23