ClassCastException when Running Command from gfsh
search cancel

ClassCastException when Running Command from gfsh

book

Article ID: 294009

calendar_today

Updated On:

Products

VMware Tanzu Gemfire

Issue/Introduction

Environment: Gemfire Version 8.1.x

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


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)


Resolution

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

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>