Java 关键的GemFire 9.3.0:GemFire集群中的Spring数据GemFire XML配置

Java 关键的GemFire 9.3.0:GemFire集群中的Spring数据GemFire XML配置,java,gemfire,spring-data-gemfire,geode,Java,Gemfire,Spring Data Gemfire,Geode,我正在将带有Spring数据GemFire 1.6.0.RELEASE的GemFire群集从8.2.7迁移到关键的GemFire 9.3.0 SDG 2.0.7.RELEASE。在启动每个节点上的缓存服务器时,我使用cache.xml中的initializer标记下声明的spring-context.xml来初始化区域 当我尝试在GemFire 9.3.0中重用相同的spring-context.xml时,gfsh命令未识别我的spring beans标记,我遇到以下异常: Caused by:

我正在将带有Spring数据GemFire 1.6.0.RELEASE的GemFire群集从8.2.7迁移到关键的GemFire 9.3.0 SDG 2.0.7.RELEASE。在启动每个节点上的缓存服务器时,我使用cache.xml中的initializer标记下声明的spring-context.xml来初始化区域

当我尝试在GemFire 9.3.0中重用相同的spring-context.xml时,gfsh命令未识别我的spring beans标记,我遇到以下异常:

Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 107; cvc-elt.1: Cannot find the declaration of element 'beans'.

        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)

        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
spring-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:gfe="http://www.springframework.org/schema/geode"
       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/geode http://www.springframework.org/schema/gemfire/spring-geode.xsd
                http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <util:properties id="gemfireProperties">
        <prop key="log-level">config</prop>
        <prop key="locators">hostA[10334],hostB[10334]</prop>
    </util:properties>

    <bean id="mappingPdxSerializer" class="org.springframework.data.gemfire.mapping.MappingPdxSerializer"/>

    <gfe:cache properties-ref="gemfireProperties" pdx-serializer-ref="mappingPdxSerializer"/>

    <gfe:replicated-region id="Product">
    </gfe:replicated-region>

    <gfe:replicated-region id="ProductCustomer">
    </gfe:replicated-region>

</beans>
更新:

引发FileNotFoundException:

我已授予所有文件的权限,并且脚本中的-e/也正在打印文件

更新:

cache.xml

<?xml version="1.0" encoding="UTF-8"?>
<cache xmlns="http://geode.apache.org/schema/cache"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd"
       version="1.0">

  <region name="Parent" refid="REPLICATE">
    <region name="Child" refid="REPLICATE"/>
  </region>

</cache>
gemfire-config.xml

<?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">

    <util:properties id="gemfireProperties">
        <prop key="locators">xyz[10334],xyx[10334]</prop>
        <prop key="mcast-port">0</prop>
    </util:properties>

    <bean id="autoSerializer" class="org.apache.geode.pdx.ReflectionBasedAutoSerializer"/>

    <gfe:cache properties-ref="gemfireProperties" cache-xml-location="cache.xml" pdx-serializer-ref="autoSerializer" pdx-read-serialized="true"/>   

</beans>

Pivotal GemFire从9.x发行版系列开始停止在$GemFire_HOME/lib目录中提供Spring数据GemFire。这有两个主要原因

1首先,Pivotal GemFire依赖于SDG有点棘手,SDG完全依赖于gfsh>start server-name=SpringConfiguredServer-SpringXML location-/path/to/spring/context.xml,而SDG依赖于Pivotal GemFire,这显然形成了循环依赖

2当涉及版本时,GemFire明显落后于Spring生态系统的当前状态。即使是最新版本9.3.0,也附带了过时的Spring jar,例如core Spring Framework 4.3.13.release,此时core Spring Framework 4.3.17.release已经可用,而5.0.6.release即将推出

尽管如此,当使用start server命令,-Spring xml location选项从Gfsh启动时,仍然可以使用Spring配置和引导关键的GemFire服务器。您只需根据正在使用的关键GemFire版本(例如9.3.0)下载SDG的版本,并在启动服务器时将SDG放在类路径上

注:目前,SDG 2.1.0.M3 SD Lovelace是基于GemFire 9.3及更高版本的唯一版本;当前设置为9.5.0

注意:也不是,我不记得在从9.3逐步升级SDG Lovelace,然后升级到9.4,最后升级到9.5之间,我是否遇到了任何API破坏性的变化。如果您在使用spring数据gemfire:2.1.0.M3时遇到问题,您也可以使用spring数据gemfire:2.1.0.M2,这在当时是gemfire 9.3的关键

按照上面的食谱,你会做以下的

gfsh> start server --name=SpringConfiguredServer --classpath=/file/system/path/to/spring-data-gemfire22.1.0.M3.jar --spring-xml-location=/classpath/to/your/spring-context.xml
这应该管用

此外,您不需要将模式从gemfire切换到geode。使用Spring数据GemFire时,请使用Spring GemFire模式。使用Spring数据大地测量时,请使用Spring大地测量模式。两者都可能有效,但是

希望这有帮助


-j

谢谢你的回复,约翰。现在我正在尝试使用Gemfire9.1.1和SDGF-2.0.7。我得到的文件不存在IO异常。请检查更新的post.Hi Sudharsan-因此,正如您从堆栈跟踪中看到的,Spring上下文在使用Spring XML时,默认情况下一个ClassPathXmlApplicationContext实例会在类路径中搜索与ApplicationContext类型匹配的Spring-context.XML。这就是为什么您会在堆栈跟踪中看到o.s.core.io.ClassPathResource。我怀疑您的spring-context.xml来自文件系统,因此。。。var/tmp/sn17180/gemfire/9.1.1/config/spring-context.xml?在这种情况下,您需要通过在Spring-context.xml的路径前面加上file:///. ...这有效地覆盖了ApplicationContext类型的默认资源搜索位置,而不是默认位置,对于ClassPathXmlApplicationContext来说,默认位置是在类路径中搜索XML配置。如果ApplicationContext是一个FileSystemXmlApplicationContext,那么Spring将在文件系统中搜索XML配置。但是,即使ApplicationContext默认基于类型的资源路径,您也可以使用资源说明符覆盖它,如表10-此链接的资源字符串中所述…因此,我认为在您的情况下,spring-context.xml的URL应该是。。。file:///var/tmp/sn17180/gemfire/9.1.1/config/spring-context.xml. 注意,仍将使用ClassPathXmlApplicationContext实例,但file://资源说明符会告诉上下文搜索文件系统,而不是默认的类路径。希望这有帮助。
<?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">

    <util:properties id="gemfireProperties">
        <prop key="locators">xyz[10334],xyx[10334]</prop>
        <prop key="mcast-port">0</prop>
    </util:properties>

    <bean id="autoSerializer" class="org.apache.geode.pdx.ReflectionBasedAutoSerializer"/>

    <gfe:cache properties-ref="gemfireProperties" cache-xml-location="cache.xml" pdx-serializer-ref="autoSerializer" pdx-read-serialized="true"/>   

</beans>
gfsh> start server --name=SpringConfiguredServer --classpath=/file/system/path/to/spring-data-gemfire22.1.0.M3.jar --spring-xml-location=/classpath/to/your/spring-context.xml