Ignite 胖客户端提供了一种设置类加载器的方法。从 Ignite Caches 中删除值时,我已经成功地使用它来避免类未找到异常。否则,我会与我的 tomcat 应用程序中的类加载器发生冲突。请参见下面的示例:
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setClassLoader(MyClass.class.getClassLoader());
Ignite ig = Ignition.start(cfg);
IgniteCache<Integer,MyClass> myCache = ig.getOrCreateCache("MyClass");
MyClass mc = myCache.get( 0 ); //throws java.lang.ClassNotFoundException without line 2
我现在正在尝试使用不提供此方法的瘦客户端。有没有办法为瘦客户端配置类加载器?或者在尝试从 Ignite ClientCache 中删除对象时尝试反序列化对象时,是否有其他方法可以避免类未找到异常?
ClientConfiguration cfg = new ClientConfiguration();
ClientIgnite ig = Ignition.startClient(cfg);
ClientCache<Integer,MyClass> myCache = ig.getOrCreateCache("MyClass");
MyClass mc = myCache.get( 0 ); //throws java.lang.ClassNotFoundException