1

openjpaでehcacheを設定しようとしています。次のエラーが表示されます。

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 を構成する他の方法はありますか?

4

1 に答える 1

1

はい、動作するはずです。ehcache-openjpa jar がクラスパスにあることを確認してください。コンテナー環境 (つまり、WAS) で実行している場合、これは少し複雑です。

[アップデート]

ある時点でこれが機能していたことは知っていますが、これを機能させるには WAS 共有ライブラリーで面白いことをしなければなりませんでしたが、メモが見つかりません。この問題は、起動時に OpenJPA が 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"/>

[/アップデート]

于 2010-08-19T18:52:31.480 に答える