3

I'm trying to access gcp secreetmanager from an appengine deployed Spring Boot applicationm, but I keep getting a org.springframework.core.convert.ConverterNotFoundException:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'com.example.email.EMailServiceApplication$HelloWorldController': Injection of autowired dependencies 
failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter 
found capable of converting from type [com.google.protobuf.ByteString$LiteralByteString] to type [java.lang.String]

The current pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>email-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>E-Mail Service</name>
    <description>E-Mail Service für arktum</description>
    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-gcp-dependencies</artifactId>
                <version>1.2.8.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>2.4.0</version>
                <configuration>
                    <version>1</version>
                    <projectId>GCLOUD_CONFIG</projectId>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

And the main class:

@SpringBootApplication
public class EMailServiceApplication {

  public static void main(String[] args) {
    SpringApplication.run(EMailServiceApplication.class, args);
  }

  @RestController
  class HelloWorldController {

    @Value("${sm://greeting-prod}")
    private String greeting;

    @GetMapping("/")
    public String hello() {
      return this.greeting;
    }
  }
}

There are no additional configuration properties, e.g. application.properties. Are there any dependencies missing?

3 Answers3

4

According to https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/490 Cloud GCP is not compatible with Spring Boot 2.5.x:

We have not upgraded Spring Cloud GCP to Spring Boot 2.5 compatibility (#472). I'll be looking at the upgrade blockers this week.

If you use Spring Initializr the combination of Spring Boote 2.5.x and GCP is blocked - you have to stick with 2.4.7 which is working just fine.

2

The bug is fixed. Update spring-cloud-gcp-dependencies to 2.0.5.

build.gradle demo:

buildscript {
    ext {
        springBootVersion = '2.5.6'
        googleCloudVersion = '2.0.5'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
        classpath "com.google.cloud:spring-cloud-gcp-dependencies:$googleCloudVersion"
    }
}

dependencies {
    implementation("com.google.cloud:spring-cloud-gcp-starter:$googleCloudVersion")
    implementation("com.google.cloud:spring-cloud-gcp-starter-secretmanager:$googleCloudVersion")
    // ...
}

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
0

This happens due to the bug https://github.com/GoogleCloudPlatform/spring-cloud-gcp/issues/490.

This defect is fixed now. Please upgrade your GCP dependency to 2.0.4.

        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>spring-cloud-gcp-dependencies</artifactId>
            <version>2.0.4</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>