使用gfsh启动Gemfire:gfsh启动服务器中出现ClassNotFound错误

问题描述 投票:1回答:3

我具有以下环境:OS-Windows7

环境变量设置:

CLASSPATH = C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\gemfire.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\antlr.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\gfsh-dependencies.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\gfSecurityImpl.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\jackson-core-2.2.0.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\commons-logging-1.1.1.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\tomcat-embed-core.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\tomcat-embed-jasper.jar;C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows\lib\tomcat-embed-logging-juli.jar;%JAVA_HOME%\lib\tools.jar;C:\MyWorkspace\Repository\org\springframework\data\spring-data-gemfire\1.5.1.RELEASE\spring-data-gemfire-1.5.1.RELEASE.jar;%CLASSPATH%
GEMFIRE = C:\MyWorkspace\Pivotal_GemFire_800_b48398_Windows GF_JAVA = %JAVA_HOME%\bin\java.exe JAVA_HOME = C:\MyWorkspace\JDK8\jdk1.8.0_31 MAVEN_HOME = C:\MyWorkspace\Maven\apache-maven-3.3.1 PATH = %JAVA_HOME%\bin;%ERACOM_HOME%;%Cryptoki%;%WAS_HOME%\bin;%MAVEN_HOME%\bin;C:\Windows\System32;C:\Windows;C:\OtherProgramFiles\nodejs\;%GEMFIRE%\bin;

我的简单项目文件:cache-xml-file:cache.xml

<cache>
    <region name="Apps">
        <region-attributes>
            <cache-listener>
                <class-name>mypackage.listener.TestListener</class-name>
            </cache-listener>
        </region-attributes>
    </region>
    <initializer>
        <class-name>org.springframework.data.gemfire.support.SpringContextBootstrappingInitializer</class-name>
        <parameter name="contextConfigLocations">
            <string>spring-application-context.xml</string>
            </parameter>
    </initializer>
</cache>

mypackage.listener.TestListener

public class TestListener implements CacheListener, Declarable {
  @
  Override
  public void init(Properties arg0) {
    System.out.println("Inside TestListener.init()");
  }

  ... //Other Overridden methods . . .
}

spring-application-context.xml:包含一个bean:

<?xml version="1.0" encoding="utf-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:gfe="http://www.springframework.org/schema/gemfire" xmlns:util="http://www.springframework.org/schema/util" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

  <bean id="myTestCacheLoader" class="mypackage.loader.MyTestCacheLoader">
  </bean>

</beans>

** mypackage.loader.MyTestCacheLoader:

public class MyTestCacheLoader implements
CacheLoader, Declarable {

  @
  Override
  public void close() {

  }

  @
  Override
  public Object load(LoaderHelper arg0) throws CacheLoaderException {
    System.out.println("Inside MyTestCacheLoader.load()");
    return null;
  }

  @
  Override
  public void init(Properties arg0) {

  }

}

步骤:1.从目录-C:\ MyWorkspace \ Pivotal_GemFire_800_b48398_Windows]启动gfsh

  1. 起始位置:起始位置--name = locator1 --port = 10334

  2. 启动服务器:

  3. start server --name=server1 --server-port=40411 --cache-xml-file=C:\MyWorkspace\Codebase\ContentServices\content-loaderwriter\src\test\resources\cache-loader-writer.xml --classpath=C:\MyWorkspace\Codebase\ContentServices\content-loaderwriter\target\content-loaderwriter-0.0.1-SNAPSHOT.jar
    

但是它抛出:java.lang.ClassNotFoundException:org.springframework.data.gemfire.support.SpringContextBootstrappingInitializer

我什至在CLASSPATH变量中添加了gemfire罐子以及上述的spring-data-gemfire罐子(来自我的仓库)。仍然有例外。似乎无法解决Maven依赖关系/类路径。

  1. 如果我尝试在gfsh启动服务器命令的classpath中提供多个jar:
  2. start server --name=server1 --server-port=40411 --cache-xml-file="C:\MyWorkspace\Codebase\ContentServices\content-loaderwriter\src\test\resources\cache-loader-writer.xml" --classpath="C:\MyWorkspace\Repository\org\springframework\data\spring-data-gemfire\1.5.1.RELEASE\spring-data-gemfire-1.5.1.RELEASE.jar:C:\MyWorkspace\Codebase\ContentServices\content-loaderwriter\target\content-loaderwriter-0.0.1-SNAPSHOT.jar"
    

我仍然收到ClassNotFoundException。它无法解析类路径中提供的jar。

任何人都可以帮忙吗?

我具有以下环境:OS-Windows7环境变量集:CLASSPATH = C:\ MyWorkspace \ Pivotal_GemFire_800_b48398_Windows \ lib \ gemfire.jar; C:\ MyWorkspace \ ...

java bootstrapping gemfire
3个回答
1
投票

我认为问题很简单,您在类路径中使用':'作为分隔符。 Windows想要一个';'这里。在这种情况下,您不需要设置CLASSPATH环境变量。


0
投票

@@ Suparno Karmakar-不知道您是否能够解决此问题,但是在检查CLASSPATH到“启动服务器”命令(即--classpath选项的值)时,假设路径正确,则选择一个要记住的是,当--classpath选项值作为参数传递给“启动服务器”时,该值将读入String。


0
投票

请替换分隔符:至\

© www.soinside.com 2019 - 2024. All rights reserved.