0

我的 ehcache.xml 中有以下内容

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false" >

    <defaultCache
        maxElementsInMemory="500"
        eternal="false"
        overflowToDisk="false"
        overflowToOffHeap="false"
        memoryStoreEvictionPolicy="LRU" >
        <persistence strategy="none" />
    </defaultCache>

    <cache name="leadSourceCollectionsCache" 
        maxElementsInMemory="500" 
        eternal="false"
        overflowToDisk="false"
        overflowToOffHeap="false"
        memoryStoreEvictionPolicy="LRU" >

        <persistence strategy="none" />
    </cache>

</ehcache>

当我启动我的服务器时,我看到以下与 ehcache 相关的调试输出

07.08.2013 15:36:10 DEBUG-ConfigurationFactory: [Configuring ehcache from InputStream]
07.08.2013 15:36:10 DEBUG-BeanHandler: [Ignoring ehcache attribute xmlns:xsi]
07.08.2013 15:36:10 DEBUG-BeanHandler: [Ignoring ehcache attribute xsi:noNamespaceSchemaLocation]
07.08.2013 15:36:10 DEBUG-PropertyUtil: [propertiesString is null.]
07.08.2013 15:36:10 DEBUG-ConfigurationHelper: [No CacheManagerEventListenerFactory class specified. Skipping...]
07.08.2013 15:36:10 DEBUG-Cache: [No BootstrapCacheLoaderFactory class specified. Skipping...]
07.08.2013 15:36:10 DEBUG-Cache: [CacheWriter factory not configured. Skipping...]
07.08.2013 15:36:10 DEBUG-ConfigurationHelper: [No CacheExceptionHandlerFactory class specified. Skipping...]
07.08.2013 15:36:10 DEBUG-Cache: [No BootstrapCacheLoaderFactory class specified. Skipping...]
07.08.2013 15:36:10 DEBUG-Cache: [CacheWriter factory not configured. Skipping...]
07.08.2013 15:36:10 DEBUG-ConfigurationHelper: [No CacheExceptionHandlerFactory class specified. Skipping...]
07.08.2013 15:36:10 DEBUG-MemoryStore: [Initialized net.sf.ehcache.store.NotifyingMemoryStore for leadSourceCollectionsCache]
07.08.2013 15:36:10 DEBUG-Cache: [Initialised cache: leadSourceCollectionsCache]
07.08.2013 15:36:10 DEBUG-ConfigurationHelper: [CacheDecoratorFactory not configured. Skipping for 'leadSourceCollectionsCache'.]
07.08.2013 15:36:10 DEBUG-ConfigurationHelper: [CacheDecoratorFactory not configured for defaultCache. Skipping for 'leadSourceCollectionsCache'.]
07.08.2013 15:36:10 DEBUG-Cache: [No BootstrapCacheLoaderFactory class specified. Skipping...]
07.08.2013 15:36:10 DEBUG-Cache: [CacheWriter factory not configured. Skipping...]
07.08.2013 15:36:10 DEBUG-MemoryStore: [Initialized net.sf.ehcache.store.MemoryStore for leadSourceCollectionCache]
07.08.2013 15:36:10 DEBUG-DiskStorePathManager: [Using diskstore path /tmp]
07.08.2013 15:36:10 DEBUG-DiskStorePathManager: [Holding exclusive lock on /tmp/.ehcache-diskstore.lock]
07.08.2013 15:36:10 DEBUG-DiskStorageFactory: [Failed to delete file lead%0053ource%0043ollection%0043ache.index]
07.08.2013 15:36:10 DEBUG-DiskStorageFactory: [Matching data file missing (or empty) for index file. Deleting index file /tmp/lead%0053ource%0043ollection%0043ache.index]
07.08.2013 15:36:10 DEBUG-DiskStorageFactory: [Failed to delete file lead%0053ource%0043ollection%0043ache.index]
07.08.2013 15:36:10 DEBUG-Cache: [Initialised cache: leadSourceCollectionCache]

所以看起来它正在创建leadSourceCollectionCache 作为内存存储缓存,这就是我想要的。但是,当我调用leadSourceCollectionCache.put 时,我得到以下信息

07.08.2013 15:37:46 调试段:[在堆上添加 0] 07.08.2013 15:37:46 错误磁盘存储工厂:[磁盘写入 1-2 失败:]

java.io.NotSerializableException: intouch.connector.business.LeadSourceCollection
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1181)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1541)
    at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:439)
    at net.sf.ehcache.Element.writeObject(Element.java:835)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
    at net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream.serialize(MemoryEfficientByteArrayOutputStream.java:97)
    at net.sf.ehcache.store.disk.DiskStorageFactory.serializeElement(DiskStorageFactory.java:405)
    at net.sf.ehcache.store.disk.DiskStorageFactory.write(DiskStorageFactory.java:384)
    at net.sf.ehcache.store.disk.DiskStorageFactory$DiskWriteTask.call(DiskStorageFactory.java:485)
    at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1088)
    at net.sf.ehcache.store.disk.DiskStorageFactory$PersistentDiskWriteTask.call(DiskStorageFactory.java:1072)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

我一生都无法弄清楚为什么会这样。我不希望我的缓存以任何方式接触磁盘。我也不知道为什么当持久性设置为无时它会尝试向 /tmp 写入内容。

4

1 回答 1

1

掌心

好像名字有错别字。我有leadSourceCollectionCache,但它应该是没有's'的leadSourceCollectionCache。

我的同事得到了以下我没有得到的额外输出:

WARN-ConfigurationFactory: [No configuration found. Configuring ehcache from ehcache-failsafe.xml  found in the classpath: jar:file:/Users/foo/.m2/repository/net/sf/ehcache/ehcache-core/2.6.6/ehcache-core-2.6.6.jar!/ehcache-failsafe.xml]
于 2013-08-08T23:02:42.953 回答