Pivotal Knowledge Base

关注

在Gfsh中运行命令产生的ClassCastException

适用于

Gemfire 8.1.x

目的

本文提供一种解决ClassCastException问题的方法,该问题可能发生在从gfsh上运行命令时。

问题现象

当运行命令时,如create gateway-receiver,gfsh会抛出如下异常信息:

[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)

解决方案

解决方案非常简单,即在启动Gemfire CacheServer时将$GEMFIRE/lib/server-dependencies.jar添加到classpath中。

比如:

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

参考:

  1. CLASSPATH Settings for GemFire Processes.

评论

由 Zendesk 提供技术支持