Who can help me ? Ehcache 3.4.0 Custom Serializers get Error : Method threw 'org.ehcache.spi.serialization.SerializerException' exception. Cannot evaluate org.ehcache.impl.internal.store.offheap.LazyOffHeapValueHolder.toString()
See original GitHub issuehello , I see the document (http://www.ehcache.org/blog/2016/05/12/ehcache3-serializers.html#disqus_thread) and then write example, but invoke ‘cache.getAll()’ get null and debug get error : Method threw ‘org.ehcache.spi.serialization.SerializerException’ exception. Cannot evaluate org.ehcache.impl.internal.store.offheap.LazyOffHeapValueHolder.toString()
invoke “cache.get()” can get correct value .

public class SerializerTest {
CacheManager dataCacheManager = null;
Cache myCache = null;
@Test
public void test() {
try {
CacheConfiguration<String, TestVO> dataCacheConfig = CacheConfigurationBuilder
.newCacheConfigurationBuilder(
String.class,
TestVO.class,
ResourcePoolsBuilder.newResourcePoolsBuilder().heap(10)
.offheap(10, MemoryUnit.MB)).withExpiry(Expirations.noExpiration())
.withValueSerializer(new HessianSerializer()).build();
dataCacheManager = CacheManagerBuilder.newCacheManagerBuilder()
.withCache("Test", dataCacheConfig).build(true);
myCache = dataCacheManager.getCache("Test", String.class, TestVO.class);
for (int i = 0; i < 10; ++i) {
TestVO testVO = new TestVO("k" + i, "v" + i);
myCache.put("key" + i, testVO);
}
System.out.println("get key0=" + myCache.get("key0"));
System.out.println("get key1=" + myCache.get("key1"));
// get null , debug get error : Method threw 'org.ehcache.spi.serialization.SerializerException' exception. Cannot evaluate org.ehcache.impl.internal.store.offheap.LazyOffHeapValueHolder.toString()
System.out.println("getAll=" + myCache.getAll(Sets.newHashSet("key0", "key1")));
} catch (Throwable tr) {
System.out.println("ehcache error : " + tr);
Assert.assertTrue(false);
}
}
class HessianSerializer implements Serializer<TestVO> {
private final HessianSerUtils HESSIAN_SER_UTILS = new HessianSerUtils();
public HessianSerializer(ClassLoader loader) {
//no-op
}
public HessianSerializer() {
//no-op
}
@Override
public ByteBuffer serialize(TestVO object) throws SerializerException {
try {
return ByteBuffer.wrap(HESSIAN_SER_UTILS.serialize(object));
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public TestVO read(ByteBuffer binary) throws ClassNotFoundException, SerializerException {
try {
return (TestVO) HESSIAN_SER_UTILS.deserialize(binary.array());
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public boolean equals(TestVO object, ByteBuffer binary) throws ClassNotFoundException,
SerializerException {
return object.equals(read(binary));
}
}
}
debug find invoke “cache.put()” , the data in cache is :

I’m sorry , My English is very poor. but who can help me ? why ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Custom Serializers - Ehcache
The Ehcache 3 documentation at Serializers gives you an overview of how to use custom serializers with a cache. The section on Persistent ......
Read more >Error while starting EhCahce - Google Groups
I am getting below error. "org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'java.util.List'.".
Read more >EhCache, on-heap tier: No serializer found - Stack Overflow
EhcacheManager - Could not create serializers for myCache org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for ...
Read more >Serializers - Software AG Documentation
and CacheConfigurationBuilder.withValueSerializer(Serializer<V> valueSerializer),. which allow by instance or by class configuration. * at the cache manager ...
Read more >Index (ehcache 3.0.3 API) - javadoc.io
Builds a CacheManager or a subtype of it uninitialized. build() - Method in class org.ehcache.config.builders.PooledExecutionServiceConfigurationBuilder: Builds ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think I know whats going on here… will report back in a few minutes.
@henri-tremblay @chrisdennis Very thanks, I have solved this problem。
` @Override public TestVO read(ByteBuffer binary) throws ClassNotFoundException, SerializerException { try {