0

I have an apache geode setup where there is one locator and one Server. we have a region employee in that. we were trying to implement in-line cache where a cache miss will lookup into database and will fill apache geode, but after deployment of Jars when i am trying to alter the region . It shows exception


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$1.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$0(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) {
       }

Things tried

  1. I tried by not implementing Declarable but still no success.
  2. I have not done any change for serializer.
Jens D
  • 4,229
  • 3
  • 16
  • 19
user956021
  • 163
  • 1
  • 1
  • 12

1 Answers1

1

I've just tried the scenario using Apache Geode 1.13.2 and it works just fine, you can find the example here. Do you have multiple versions of the same jar within the server's class path?, that might be the reason for the exception.

Cheers.

Juan Ramos
  • 1,421
  • 1
  • 8
  • 13
  • While starting server i gave class path location and it worked. Earlier i was creating server and then deploying jars using deploy command. Not sure why that is not working. – user956021 Apr 13 '21 at 12:13
  • Glad to hear it's working!. Nevertheless, deploying the jar and altering the region after it's created should work as well... in fact, that's the approach I've used in the example I previously shared (see [here](https://github.com/jujoramos/stackoverflow/blob/main/cache-loader-gfsh-alter-region-67019639/reproducer.sh#L21-L26)). Cheers. – Juan Ramos Apr 13 '21 at 12:19
  • sorry Juan for going off topic but one question can i create materialized view in apache geode ? – user956021 Apr 15 '21 at 02:50
  • Just replied in your newly created stackoverflow question, long story short: no, you can't. – Juan Ramos Apr 15 '21 at 08:30