Error while starting EhCahce

2,388 views
Skip to first unread message

vaibhav srivastava

unread,
Jun 19, 2017, 7:58:49 PM6/19/17
to ehcache-users
  1. What version of Ehcache you are currently using;3.3
  2. Paste the configuration for the Cache/CacheManager you have an issue with;
  3. Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate);NA
  4. Providing JDK and OS versions maybe useful as well. .18
Hi guys ,

I am getting below error 

"org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'java.util.List'."

This is how i am initializing my cache .

cacheManager = CacheManagerBuilder.newCacheManagerBuilder().

                    withCache(CACHE_NAME

                                  CacheConfigurationBuilder.newCacheConfigurationBuilder

                                    (String.class,List.class,ResourcePoolsBuilder.heap(10))

                                      .withExpiry(Expirations.timeToLiveExpiration(Duration.of(2, TimeUnit.HOURS)))

                                      ).build();


But cache put and get are happening . Do i need to worry about above error . Please let me know



I

Henri Tremblay

unread,
Jun 19, 2017, 11:33:59 PM6/19/17
to ehcach...@googlegroups.com
This is a debug log that you can indeed ignore.

When caching on heap you don't need serializers. The message is only notifying that you need to  watch out because as soon as you try to cache anywhere else that isn't on heap, you will need to give a serializer for List since the List interface isn't serializable.

Henri

--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-users+unsubscribe@googlegroups.com.
To post to this group, send email to ehcach...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ehcache-users/27bc49f3-dc60-4997-b16c-984095ce8518%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Srinu Anumaneni

unread,
May 28, 2018, 1:08:16 PM5/28/18
to ehcache-users
Hi,

       I am getting no serialize for List error while creating and putting cache with List as value. How can I put List into clustered cache. Please let me know. Thanks



On Tuesday, 20 June 2017 09:03:59 UTC+5:30, Henri Tremblay wrote:
This is a debug log that you can indeed ignore.

When caching on heap you don't need serializers. The message is only notifying that you need to  watch out because as soon as you try to cache anywhere else that isn't on heap, you will need to give a serializer for List since the List interface isn't serializable.

Henri
On 19 June 2017 at 19:58, vaibhav srivastava <coolvi...@gmail.com> wrote:
  1. What version of Ehcache you are currently using;3.3
  2. Paste the configuration for the Cache/CacheManager you have an issue with;
  3. Add any name and version of other library or framework you use Ehcache with (e.g. Hibernate);NA
  4. Providing JDK and OS versions maybe useful as well. .18
Hi guys ,

I am getting below error 

"org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'java.util.List'."

This is how i am initializing my cache .

cacheManager = CacheManagerBuilder.newCacheManagerBuilder().

                    withCache(CACHE_NAME

                                  CacheConfigurationBuilder.newCacheConfigurationBuilder

                                    (String.class,List.class,ResourcePoolsBuilder.heap(10))

                                      .withExpiry(Expirations.timeToLiveExpiration(Duration.of(2, TimeUnit.HOURS)))

                                      ).build();


But cache put and get are happening . Do i need to worry about above error . Please let me know



I

--
You received this message because you are subscribed to the Google Groups "ehcache-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-user...@googlegroups.com.

Henri Tremblay

unread,
May 28, 2018, 1:17:43 PM5/28/18
to ehcach...@googlegroups.com
Please show us the code and the error.

To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-users+unsubscribe@googlegroups.com.

To post to this group, send email to ehcach...@googlegroups.com.

Srinu Anumaneni

unread,
May 28, 2018, 1:32:35 PM5/28/18
to ehcache-users
tc-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
           xmlns:persistence="http://www.terracottatech.com/config/platform-persistence">

  <plugins>
    <config>
      <ohr:offheap-resources>
        <ohr:resource name="default-resource" unit="MB">512</ohr:resource>
      </ohr:offheap-resources>
    </config>
  </plugins>

  <servers>
    <server host="localhost" name="clustered">
      <tsa-port>9410</tsa-port>
      <logs>terracotta/server-logs</logs>
    </server>
  </servers>

  <failover-priority>
    <availability/>
  </failover-priority>
</tc-config>

ehcache.xml

<?xml version="1.0" encoding="UTF-8"?>

<ehcache:config
  xmlns:ehcache='http://www.ehcache.org/v3'

  <ehcache:service>
    <terracotta:cluster>
      <terracotta:connection url="terracotta://localhost:9410/clustered"/>
      <terracotta:server-side-config auto-create="true">
        <terracotta:default-resource from="default-resource"/>
      </terracotta:server-side-config>
    </terracotta:cluster>
 </ehcache:service>

  <ehcache:cache alias="basicCache">
    <ehcache:key-type>java.lang.Long</ehcache:key-type>
    <ehcache:value-type>java.util.List</ehcache:value-type>
    <ehcache:resources>
      <ehcache:heap unit="entries">10000</ehcache:heap>
      <ehcache:offheap unit="MB">100</ehcache:offheap>
      <terracotta:clustered-dedicated unit="MB">500</terracotta:clustered-dedicated>
    </ehcache:resources>
    <terracotta:clustered-store consistency="strong" />
  </ehcache:cache>
</ehcache:config>



TestCacheManager.java


package org.ehcache.sample;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.ehcache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.config.Configuration;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.xml.XmlConfiguration;

public class TestTerracottaCacheManager
{

   private static TestTerracottaCacheManager cacheManager = null;

   private CacheManager cm;

   private Cache<Long, List> cache;

   private static final String DEFAULT_CACHE_NAME = "basicCache";

   private String cacheName;

   public static TestTerracottaCacheManager getInstance()
   {
      if (cacheManager == null)
      {
         cacheManager = new TestTerracottaCacheManager();
      }
      return cacheManager;
   }

   private TestTerracottaCacheManager()
   {
      // 1. Create a cache manager
      final URL url =
         TestTerracottaCacheManager.class.getResource("/ehcache.xml");
      System.out.println(url);
      Configuration xmlConfig = new XmlConfiguration(url);
      cm = CacheManagerBuilder.newCacheManager(xmlConfig);
      System.out.println("created sm");
      cm.init();
      intializeCache();
   }

   private void intializeCache()
   {
      // 2. Get a cache called "cache1", declared in ehcache.xml
      cache = cm.getCache(cacheName == null ? DEFAULT_CACHE_NAME : cacheName,
            Long.class, List.class);
      if (cache == null)
      {
         throw new NullPointerException();
      }
   }

   public void put(Long key, List<TestBean> value)
   {
      cache.put(key, value);
   }

   public List<TestBean> get(Long key)
   {
      // 5. Print out the element
      List<TestBean> ele = (List<TestBean>) cache.get(key);
      return ele;
   }

   public boolean isKeyInCache(Long key)
   {
      return cache.containsKey(key);
   }

   public void closeCache()
   {
      // 7. shut down the cache manager
      cm.close();
   }

   public static void main(String[] args)
   {
      TestTerracottaCacheManager testCache = TestTerracottaCacheManager.getInstance();
      ArrayList<TestBean> all = new ArrayList<TestBean>();
      //all.add("hello");
      TestBean tb = new TestBean();
      tb.setEmpNo(1);
      tb.setName("srinu");
      all.add(tb);
      testCache.put(1L, all);
      System.out.println(testCache.get(1L).get(0).getName());
      testCache.closeCache();
   }

   public String getCacheName()
   {
      return cacheName;
   }

   public void setCacheName(String cacheName)
   {
      this.cacheName = cacheName;
   }
}

TestBean.java

package org.ehcache.sample;

import java.io.Serializable;

public class TestBean implements Serializable {

/**
*/
private static final long serialVersionUID = 1L;

private int empNo;
private String name;
public int getEmpNo() {
return empNo;
}
public void setEmpNo(int empNo) {
this.empNo = empNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

I am getting below error

Exception in thread "main" org.ehcache.StateTransitionException: Cache 'basicCache' creation in EhcacheManager failed.
at org.ehcache.core.StatusTransitioner$Transition.failed(StatusTransitioner.java:235)
at org.ehcache.core.EhcacheManager.init(EhcacheManager.java:600)
at org.ehcache.sample.TestTerracottaCacheManager.<init>(TestTerracottaCacheManager.java:43)
at org.ehcache.sample.TestTerracottaCacheManager.getInstance(TestTerracottaCacheManager.java:29)
at org.ehcache.sample.TestTerracottaCacheManager.main(TestTerracottaCacheManager.java:83)
Caused by: java.lang.IllegalStateException: Cache 'basicCache' creation in EhcacheManager failed.
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:293)
at org.ehcache.core.EhcacheManager.init(EhcacheManager.java:579)
... 3 more
Caused by: java.lang.RuntimeException: org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'java.util.List'
at org.ehcache.core.EhcacheManager.getStore(EhcacheManager.java:488)
at org.ehcache.core.EhcacheManager.createNewEhcache(EhcacheManager.java:316)
at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:265)
... 4 more
Caused by: org.ehcache.spi.serialization.UnsupportedTypeException: No serializer found for type 'java.util.List'
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.getSerializerClassFor(DefaultSerializationProvider.java:136)
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.createSerializer(DefaultSerializationProvider.java:98)
at org.ehcache.impl.internal.spi.serialization.DefaultSerializationProvider.createValueSerializer(DefaultSerializationProvider.java:90)
at org.ehcache.core.EhcacheManager.getStore(EhcacheManager.java:477)
... 6 more

Srinu Anumaneni

unread,
May 28, 2018, 1:40:01 PM5/28/18
to ehcache-users
It got resolved by using ArrayList.
Thanks

Henri Tremblay

unread,
May 28, 2018, 1:45:43 PM5/28/18
to ehcach...@googlegroups.com
Yes. ArrayList is serializable so no question asked. List is not. So you need to specify a serializer.


Specifying a PlainJavaSerializer as the value serializer should also solve the problem if I am not mistaken.

To unsubscribe from this group and stop receiving emails from it, send an email to ehcache-users+unsubscribe@googlegroups.com.

To post to this group, send email to ehcach...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages