Pivotal Knowledge Base

Follow

ClassCastException When Running Command from Gfsh

Applies To

Gemfire 8.1.x

Purpose

This document provides a way to resolve a ClassCastException issue that may occur when running a command from gfsh.

Symptom

When running a command, such as create gateway-receiver, gfsh throws the following exception:

[info 2015/04/30 17:13:27.501 CDT RMI TCP Connection(4)-127.0.0.1 tid=0x11a] (msgTID=282 msgSN=142) Executing create gateway-receiver
[info 2015/04/30 17:13:27.575 CDT RMI TCP Connection(4)-127.0.0.1 tid=0x11a] (msgTID=282 msgSN=143) Could not execute "create gateway-receiver".
java.lang.ClassCastException: java.lang.ClassNotFoundException cannot be cast to com.gemstone.gemfire.management.internal.cli.functions.CliFunctionResult
 at com.gemstone.gemfire.management.internal.cli.commands.WanCommands.createGatewayReceiver(WanCommands.java:686)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at com.gemstone.gemfire.management.internal.cli.util.spring.ReflectionUtils.invokeMethod(ReflectionUtils.java:51)
 at com.gemstone.gemfire.management.internal.cli.remote.RemoteExecutionStrategy.execute(RemoteExecutionStrategy.java:105)
 at com.gemstone.gemfire.management.internal.cli.remote.CommandProcessor.executeCommand(CommandProcessor.java:97)
 at com.gemstone.gemfire.management.internal.cli.remote.CommandStatementImpl.process(CommandStatementImpl.java:59)
 at com.gemstone.gemfire.management.internal.cli.remote.MemberCommandService.processCommand(MemberCommandService.java:47)
 at com.gemstone.gemfire.management.internal.beans.MemberMBeanBridge.processCommand(MemberMBeanBridge.java:1736)
 at com.gemstone.gemfire.management.internal.beans.MemberMBean.processCommand(MemberMBean.java:400)
 at com.gemstone.gemfire.management.internal.beans.MemberMBean.processCommand(MemberMBean.java:393)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:75)
 at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:279)
 at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:193)
 at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:175)
 at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:117)
 at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:54)
 at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:237)
 at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:138)
 at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:252)

Solution

The solution is simply to add $GEMFIRE/lib/server-dependencies.jar to the classpath when starting the Gemfire CacheServer process.

For example:

sh$ java -cp "$GEMFIRE/lib/server-dependencies.jar:/path/to/your/applications/classes.jar" com.gemstone.gemfire.distributed.ServerLauncher start server1 <server-launcher-options>

References

  1. CLASSPATH Settings for GemFire Processes.

Comments

Powered by Zendesk