Cloud foundry Geode/GemFire/PCC错误-未提供安全凭据

Cloud foundry Geode/GemFire/PCC错误-未提供安全凭据,cloud-foundry,gemfire,geode,spring-data-gemfire,spring-boot-data-geode,Cloud Foundry,Gemfire,Geode,Spring Data Gemfire,Spring Boot Data Geode,我有一个springboot应用程序托管在PCF上,试图连接到PCC(关键云缓存)。我已经启动了一个PCC实例,并将其绑定到我的应用程序,并将该应用程序推送到cloud foundry。我已经向springboot添加了所有必需的gemfire starter依赖项,它似乎能够从VCAP_服务读取定位器和服务器信息。但是,我在spring boot应用程序启动时看到以下错误 Error prefilling connections : org.apache.geode.security.Auth

我有一个springboot应用程序托管在PCF上,试图连接到PCC(关键云缓存)。我已经启动了一个PCC实例,并将其绑定到我的应用程序,并将该应用程序推送到cloud foundry。我已经向springboot添加了所有必需的gemfire starter依赖项,它似乎能够从VCAP_服务读取定位器和服务器信息。但是,我在spring boot应用程序启动时看到以下错误

Error prefilling connections : org.apache.geode.security.AuthenticationRequiredException: No security credentials are provided
org.apache.geode.security.AuthenticationRequiredException: No security credentials are provided
at org.apache.geode.internal.cache.tier.sockets.Handshake.readMessage(Handshake.java:320)


Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.geode.cache.Region]: Failed to create Region for cache [TestRegion]; nested exception is org.apache.geode.security.AuthenticationRequiredException: No security credentials are provided
这是我的依赖项列表

        <dependency>
            <groupId>org.springframework.geode</groupId>
            <artifactId>spring-gemfire-starter</artifactId>
            <version>1.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-gemfire</artifactId>
            <version>2.2.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.cache</groupId>
            <artifactId>cache-api</artifactId>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>io.pivotal.gemfire</groupId>
            <artifactId>geode-core</artifactId>
            <version>9.5.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.pivotal.gemfire</groupId>
            <artifactId>geode-common</artifactId>
            <version>9.5.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.pivotal.gemfire</groupId>
            <artifactId>geode-cq</artifactId>
            <version>9.5.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.pivotal.gemfire</groupId>
            <artifactId>geode-lucene</artifactId>
            <version>9.5.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.pivotal.gemfire</groupId>
            <artifactId>geode-wan</artifactId>
            <version>9.5.4</version>
            <scope>compile</scope>
        </dependency>
我相信,我拥有的Springboot gemfire starter依赖性足以自动读取VCAP_服务中的安全凭据,而无需任何手动操作。但是,我看到它并没有获得信任,不知道为什么在拥有了下面所有的依赖项之后。有人能帮忙吗?谢谢

好的

首先,请参阅我对上一篇有关应用程序依赖性的回答。正确声明应用程序依赖关系是我回答的中心主题

接下来,当使用PCC时,SpringDataGemfire(SDG)本身中的任何内容都不会在托管环境(如PCF)中“自动”处理身份验证。为此,对于Apache Geode或Pivotal GemFire(SBDG),您绝对需要Spring启动,在您的案例中,“…对于Pivotal GemFire”,从技术上讲,还需要
org.springframework.Geode:Spring GemFire starter
依赖项,这是您唯一需要的依赖项。确保按照我在上一节中的说明对齐版本

基于上述配置,您明确地“覆盖了”客户机安全配置,以及SBDG提供的自动配置,因为您明确地在
CloudConfiguration
类上声明了
@ClientCacheApplication
注释

为什么?

好的,再一次,这是GemFire/Geode的东西,不是Spring的东西,而是涉及GemFire/Geode(客户端/服务器、P2P、WAN等)的所有形式的“安全性”,在构建和初始化缓存对象之前,必须正确配置和设置

如果缓存对象已经由用户/应用程序配置提供,则SBDG的GemFire/Geode客户端安全自动配置将不应用。看到了吗

从技术上讲,这与GemFire/Geode“安全配置”几乎完全通过GemFire/Geode属性进行配置有关。这些属性必须在构造缓存之前声明/设置,因为它们在启动时传递给缓存创建。如果未提供,则安全配置将不适用。无论您稍后是否在运行时提供安全属性,无论是否使用Spring(例如,直接使用GemFire/geodeapi),结果都是一样的

GemFire/Geode有一个非常具体的初始化顺序:Auth、TLS/SSL、内存管理,这、那,这就是为什么SBDG自动配置经过精心设计,以确保遵循正确的初始化顺序

此外,无论是否使用SDG的配置注释(显式),而是使用JavaConfig在Spring上下文中声明显式bean,效果都是一样的,因为SDG配置注释隐式地为您声明这些bean,这将导致“覆盖”Spring Boot提供的自动配置,特别是SBDG

无论是否为GemFire/Geode,其工作原理相同。如果显式声明一个SQL
DataSource
bean,那么当您的应用程序类路径上有一个嵌入式数据库(H2或HSQL)时,您会告诉Boot重写提供的
DataSource

其概念是“约定优先于配置”(通过简单地声明应用程序类路径上的依赖项,以神奇地自动启用功能),但为了在应用程序需求偏离默认值时快速解决问题,必须显式声明特定类型的bean定义,以便根据应用程序需求更改配置,这必然会禁用Spring Boot提供的自动配置,否则,您可能会有不明确和/或冲突的配置(即它是哪个)。通常,Spring框架甚至不允许这样做

再次删除
@ClientCacheApplication
@EnablePdx
。SBDG不需要它们。但是,正是
@ClientCacheApplication
注释导致了这里的问题

综上所述,所有这些都已在参考文件中详细解释:

  • (见附录)
  • 特别注意第4章中的内容


    希望这有帮助

    您好,Madmax,您不应该在
    pom.mlx
    中同时依赖
    geode
    gemfire
    。PCC使用
    gemfire
    ,所以应该坚持使用。同样的情况也适用于
    spring数据gemfire
    spring数据geode
    。试试看,让我知道它是如何运行的。@JuanRamos我删除了geode依赖项,并尝试使用
    spring数据gemfire
    和pivotal gemfire
    geode core
    lirbraries,我发现
    现在无法连接到:localhost:40404
    问题。不知道为什么它试图连接到本地主机时,应用程序已经绑定到PCC。我是否缺少读取PCF上VCAP_SERVICES env变量的gemfire库?您能告诉我gemfire连接到PCC和自动创建带注释的区域所需的具体依赖项吗?谢谢您可以使用作为创建spring引导应用程序以连接到PCC的起点,您尝试过吗?。包含关于应用程序本身的详细描述,以及使用的配置选项和背后的原因。@JuanRamos嗨,是的,我确实看到了上面的示例。我在用gemfire图书馆
    @Configuration
    @ClientCacheApplication(name = "Test", logLevel = "info")
    @EnableCachingDefinedRegions(
        clientRegionShortcut = ClientRegionShortcut.PROXY,
        serverRegionShortcut = RegionShortcut.REPLICATE_HEAP_LRU)
    @EnableClusterAware
    @EnablePdx
    public class CloudConfiguration {}