com.gemstone.gemfire.cache.execute.FunctionException: java.lang.NullPointerException

Spring JIRA | John Blum | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Encountered a {{NullPointerException}} in the {{DefaultFunctionArgumentResolver}} class when executing a GemFire Function declared without arguments and not explicitly passing any arguments (as any dev would expect). {code:java} com.gemstone.gemfire.cache.execute.FunctionException: java.lang.NullPointerException at com.gemstone.gemfire.internal.cache.execute.LocalResultCollectorImpl.setException(LocalResultCollectorImpl.java:189) at com.gemstone.gemfire.internal.cache.execute.DistributedRegionFunctionResultSender.setException(DistributedRegionFunctionResultSender.java:228) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.handleException(AbstractExecution.java:607) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:378) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution$2.run(AbstractExecution.java:316) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at com.gemstone.gemfire.distributed.internal.DistributionManager.runUntilShutdown(DistributionManager.java:692) at com.gemstone.gemfire.distributed.internal.DistributionManager$8$1.run(DistributionManager.java:1116) at java.lang.Thread.run(Thread.java:695) Caused by: java.lang.NullPointerException at org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver.resolveFunctionArguments(DefaultFunctionArgumentResolver.java:30) at org.springframework.data.gemfire.function.FunctionContextInjectingArgumentResolver.resolveFunctionArguments(FunctionContextInjectingArgumentResolver.java:86) at org.springframework.data.gemfire.function.PojoFunctionWrapper.execute(PojoFunctionWrapper.java:107) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:352) ... 6 more {code} The workaround to avoiding this NPE is simple, a developer just needs to pass an empty Object array to the Execution.withArgs(..) method like so... {code:java} FunctionService.onRegion(appData).withArgs(new Object[0]); {code} Unfortunately, GemFire's FunctionContext implementing class returns NULL instead of an empty Object array (as it should) when no arguments were specified, or rather when the Function takes no arguments.

    Spring JIRA | 3 years ago | John Blum
    com.gemstone.gemfire.cache.execute.FunctionException: java.lang.NullPointerException
  2. 0

    Encountered a {{NullPointerException}} in the {{DefaultFunctionArgumentResolver}} class when executing a GemFire Function declared without arguments and not explicitly passing any arguments (as any dev would expect). {code:java} com.gemstone.gemfire.cache.execute.FunctionException: java.lang.NullPointerException at com.gemstone.gemfire.internal.cache.execute.LocalResultCollectorImpl.setException(LocalResultCollectorImpl.java:189) at com.gemstone.gemfire.internal.cache.execute.DistributedRegionFunctionResultSender.setException(DistributedRegionFunctionResultSender.java:228) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.handleException(AbstractExecution.java:607) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:378) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution$2.run(AbstractExecution.java:316) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at com.gemstone.gemfire.distributed.internal.DistributionManager.runUntilShutdown(DistributionManager.java:692) at com.gemstone.gemfire.distributed.internal.DistributionManager$8$1.run(DistributionManager.java:1116) at java.lang.Thread.run(Thread.java:695) Caused by: java.lang.NullPointerException at org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver.resolveFunctionArguments(DefaultFunctionArgumentResolver.java:30) at org.springframework.data.gemfire.function.FunctionContextInjectingArgumentResolver.resolveFunctionArguments(FunctionContextInjectingArgumentResolver.java:86) at org.springframework.data.gemfire.function.PojoFunctionWrapper.execute(PojoFunctionWrapper.java:107) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:352) ... 6 more {code} The workaround to avoiding this NPE is simple, a developer just needs to pass an empty Object array to the Execution.withArgs(..) method like so... {code:java} FunctionService.onRegion(appData).withArgs(new Object[0]); {code} Unfortunately, GemFire's FunctionContext implementing class returns NULL instead of an empty Object array (as it should) when no arguments were specified, or rather when the Function takes no arguments.

    Spring JIRA | 3 years ago | John Blum
    com.gemstone.gemfire.cache.execute.FunctionException: java.lang.NullPointerException
  3. 0

    I have a case that my gemfire function should not have any arguments. Although according to the gemfire API it is perfectly fine to define functions without arguments, when I tried my function I got a NPE back. To reproduce it you can define a simple function like: @GemfireFunction(hasResult=true) public void test(){ logger.info("test() is called!"); } And call it from gfsh : gfsh>execute function --id=test And you would see the following Exception in the server log: [severe 2014/01/06 13:30:02.683 EST server1 <Function Execution Processor2> tid=0x40] UnExpected exception during function execution local member java.lang.NullPointerException at org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver.resolveFunctionArguments(DefaultFunctionArgumentResolver.java:30) at org.springframework.data.gemfire.function.FunctionContextInjectingArgumentResolver.resolveFunctionArguments(FunctionContextInjectingArgumentResolver.java:86) at org.springframework.data.gemfire.function.PojoFunctionWrapper.execute(PojoFunctionWrapper.java:107) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:352) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution$2.run(AbstractExecution.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at com.gemstone.gemfire.distributed.internal.DistributionManager.runUntilShutdown(DistributionManager.java:692) at com.gemstone.gemfire.distributed.internal.DistributionManager$8$1.run(DistributionManager.java:1116) at java.lang.Thread.run(Thread.java:744)

    Spring JIRA | 3 years ago | Abtin Afshar
    java.lang.NullPointerException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    I have a case that my gemfire function should not have any arguments. Although according to the gemfire API it is perfectly fine to define functions without arguments, when I tried my function I got a NPE back. To reproduce it you can define a simple function like: @GemfireFunction(hasResult=true) public void test(){ logger.info("test() is called!"); } And call it from gfsh : gfsh>execute function --id=test And you would see the following Exception in the server log: [severe 2014/01/06 13:30:02.683 EST server1 <Function Execution Processor2> tid=0x40] UnExpected exception during function execution local member java.lang.NullPointerException at org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver.resolveFunctionArguments(DefaultFunctionArgumentResolver.java:30) at org.springframework.data.gemfire.function.FunctionContextInjectingArgumentResolver.resolveFunctionArguments(FunctionContextInjectingArgumentResolver.java:86) at org.springframework.data.gemfire.function.PojoFunctionWrapper.execute(PojoFunctionWrapper.java:107) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:352) at com.gemstone.gemfire.internal.cache.execute.AbstractExecution$2.run(AbstractExecution.java:316) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at com.gemstone.gemfire.distributed.internal.DistributionManager.runUntilShutdown(DistributionManager.java:692) at com.gemstone.gemfire.distributed.internal.DistributionManager$8$1.run(DistributionManager.java:1116) at java.lang.Thread.run(Thread.java:744)

    Spring JIRA | 3 years ago | Abtin Afshar
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver.resolveFunctionArguments()
    2. Spring Data GemFire
      PojoFunctionWrapper.execute
      1. org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver.resolveFunctionArguments(DefaultFunctionArgumentResolver.java:30)
      2. org.springframework.data.gemfire.function.FunctionContextInjectingArgumentResolver.resolveFunctionArguments(FunctionContextInjectingArgumentResolver.java:86)
      3. org.springframework.data.gemfire.function.PojoFunctionWrapper.execute(PojoFunctionWrapper.java:107)
      3 frames
    3. com.gemstone.gemfire
      AbstractExecution$2.run
      1. com.gemstone.gemfire.internal.cache.execute.AbstractExecution.executeFunctionLocally(AbstractExecution.java:352)
      2. com.gemstone.gemfire.internal.cache.execute.AbstractExecution$2.run(AbstractExecution.java:316)
      2 frames
    4. Java RT
      ThreadPoolExecutor$Worker.run
      1. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
      2 frames
    5. com.gemstone.gemfire
      DistributionManager$8$1.run
      1. com.gemstone.gemfire.distributed.internal.DistributionManager.runUntilShutdown(DistributionManager.java:692)
      2. com.gemstone.gemfire.distributed.internal.DistributionManager$8$1.run(DistributionManager.java:1116)
      2 frames
    6. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:695)
      1 frame