title: Ignite and Spring with multiple Class Loaders
body: <p>I have a system with Spring Cache, in it there are multiple Class Loaders.  Actually I use ehcache and it works fine:</p>
  
  <pre><code>@Component
  public class ObjectRepository extends MongoRepository&lt;Object&gt; {
  // -------------------------- OTHER METHODS --------------------------
  
      @Override
      @Cacheable(value = "object", key = "#p0+#p1.name")
      public Object get(String id, Class&lt;? extends Object&gt; clazz) {
          return super.get(id, clazz);
      }
  
      @Override
      @CacheEvict(value = "object", key = "#p0+#p1.name")
      public void remove(String id, Class&lt;? extends Object&gt; clazz) {
          super.remove(id, clazz);
      }
  
      @Override
      @CacheEvict(value = "object", key = "#p0+#p0.class.name")
      public void save(Object object) {
          super.save(object);
      }
  }
  </code></pre>
  
  <p>I'm trying to change to ignite:</p>
  
  <pre><code>@Bean
  @SuppressWarnings("unchecked")
  public CacheManager cacheManager() {
      SpringCacheManager springCacheManager = new SpringCacheManager();
      IgniteConfiguration igniteConfiguration = new IgniteConfiguration();
      igniteConfiguration.setPeerClassLoadingEnabled(true);
      igniteConfiguration.setIncludeEventTypes(org.apache.ignite.events.EventType.EVTS_TASK_EXECUTION);
      springCacheManager.setConfiguration(igniteConfiguration);
      return springCacheManager;
  }   
  </code></pre>
  
  <p>Because of multiple Class Loaders I'm getting error, when i do <code>objectRepository.get("1", com.test.ClassInClassLoader1.class)</code> works ok but after i do <code>objectRepository.get("2", com.test.ClassInClassLoader2.class)</code> and i get the error:</p>
  
  <pre><code>Caused by: class org.apache.ignite.IgniteCheckedException: Encountered incompatible class loaders for cache [class1=com.test.ClassInClassLoader2, class2=com.test.ClassInClassLoader1]
          at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClass(GridCacheDeploymentManager.java:656)
          at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClass(GridCacheDeploymentManager.java:601)
          at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClass(GridCacheDeploymentManager.java:590)
          at org.apache.ignite.internal.processors.cache.GridCacheDeploymentManager.registerClasses(GridCacheDeploymentManager.java:573)
          at org.apache.ignite.internal.processors.cache.GridCacheUtils.marshal(GridCacheUtils.java:950)
          at org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl.marshal(IgniteCacheObjectProcessorImpl.java:94)
          at org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl.marshal(CacheObjectPortableProcessorImpl.java:727)
          at org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$UserCacheObjectImpl.prepareForCache(IgniteCacheObjectProcessorImpl.java:343)
          ... 186 more
  </code></pre>
  
  <p>I tryied to use <code>DeploymentMode.ISOLATED</code> and <code>DeploymentMode.PRIVATE</code> but they do not work with <code>igniteConfiguration.setPeerClassLoadingEnabled(true)</code>, so I have to register manually all classes and i didn't find how to do it with LocalDeploymentSpi, I tried to use <code>igniteConfiguration.getDeploymentSpi()</code> but it's null and when I create it is like the Ignite ignores the classes in there.</p>