无法实例化 Class,同时更改区域添加加载到该区域的缓存

Unable to Instantiate Class while Alter Region adding cache loaded to that region

我有一个 apache geode 设置,其中有一个定位器和一个服务器。我们有一名地区员工。我们试图实现内联缓存,其中缓存未命中将查找数据库并填充 apache geode,但是在我尝试更改区域时部署 Jars 之后。它显示异常


Stack Trace:
[error 2021/04/09 15:18:30.513 IST <Function Execution Processor2> tid=0x3a] Error instantiating class: <com.abc.geode.ApacheGeode.EmployeeCacheLoader>
java.lang.RuntimeException: Error instantiating class: <com.abc.geode.ApacheGeode.EmployeeCacheLoader>
    at org.apache.geode.management.internal.configuration.domain.DeclarableTypeInstantiator.newInstance(DeclarableTypeInstantiator.java:43)
    at org.apache.geode.management.internal.cli.functions.RegionAlterFunction.alterRegion(RegionAlterFunction.java:202)
    at org.apache.geode.management.internal.cli.functions.RegionAlterFunction.executeFunction(RegionAlterFunction.java:67)
    at org.apache.geode.management.cli.CliFunction.execute(CliFunction.java:37)
    at org.apache.geode.internal.cache.MemberFunctionStreamingMessage.process(MemberFunctionStreamingMessage.java:201)
    at org.apache.geode.distributed.internal.DistributionMessage.scheduleAction(DistributionMessage.java:372)
    at org.apache.geode.distributed.internal.DistributionMessage.run(DistributionMessage.java:436)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.geode.distributed.internal.ClusterOperationExecutors.runUntilShutdown(ClusterOperationExecutors.java:475)
    at org.apache.geode.distributed.internal.ClusterOperationExecutors.doFunctionExecutionThread(ClusterOperationExecutors.java:393)
    at org.apache.geode.logging.internal.executors.LoggingThreadFactory.lambda$newThread[=11=](LoggingThreadFactory.java:119)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.abc.geode.ApacheGeode.EmployeeCacheLoader cannot be cast to org.apache.geode.cache.Declarable
    at org.apache.geode.management.internal.configuration.domain.DeclarableTypeInstantiator.newInstance(DeclarableTypeInstantiator.java:34)
public class EmployeeCacheLoader implements CacheLoader<Long,Employee>, Declarable {

    @Override
    public Employee load(LoaderHelper<Long, Employee> helper) throws CacheLoaderException {
       Employee e=new Employee();
       e.setEmail("a@b.com");
       e.setIdemployee(2L);
        return e;
    }

    @Override
    public void close() {
    }

    @Override
    public void init(Properties props) {
       }

尝试过的东西

  1. 我试过不实现 Declarable 但仍然没有成功。
  2. 我没有对序列化程序做任何更改。

我刚刚使用 Apache Geode 1.13.2 尝试了这个场景,它工作得很好,你可以找到示例 here。服务器的 class 路径中是否有同一个 jar 的多个版本?这可能是异常的原因。

干杯。