2010-08-19 36 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