Skip to content
This repository was archived by the owner on Oct 3, 2022. It is now read-only.
This repository was archived by the owner on Oct 3, 2022. It is now read-only.

CacheLoaderException when reading from cache and no loader factory is specified #28

@dzlab

Description

@dzlab

I'm having the following exception when I read an entry that doesn't exist in the cache while I'm expecting a null. Do I have to provide a factory for the cache loader when I create the cache? currently I'm not.

javax.cache.integration.CacheLoaderException: java.lang.NullPointerException
    at org.ehcache.jcache.JCache.load(JCache.java:123)
    at org.ehcache.jcache.JCache.get(JCache.java:105)
        ...

Here is my configuration:

CompleteConfiguration<ComposedKey, Object> config1 = new MutableConfiguration<ComposedKey, Object>()
    // Configure the cache to be typesafe
        .setTypes(ComposedKey.class, Object.class)
        // Configure to expire entries 30 secs after creation in the cache
        .setExpiryPolicyFactory(FactoryBuilder.factoryOf(new AccessedExpiryPolicy(new Duration(TimeUnit.MINUTES, 30))))
        // Configure read-through of the underlying store
        .setReadThrough(true)
        // Configure write-through to the underlying store
        .setWriteThrough(true)
        // Configure the javax.cache.integration.CacheLoader
        // .setCacheLoaderFactory(FactoryBuilder.factoryOf(new UserCacheLoader(userDao)))
        // Configure the javax.cache.integration.CacheWriter
        // .setCacheWriterFactory(FactoryBuilder.factoryOf(new UserCacheWriter(userDao)))
        // Configure the javax.cache.event.CacheEntryListener with no
        // javax.cache.event.CacheEntryEventFilter, to include old value
        // and to be executed synchronously
        .addCacheEntryListenerConfiguration(
            new MutableCacheEntryListenerConfiguration<ComposedKey, Object>(new CacheListenerManagerJSR107Factory(), null, true,
                true));

It looks like when readTrough is set to true then a cache loader should be provided.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions