spring-cloud-commons: Maven Dependency spring-cloud-config-client causes issues with spring-boot-autoconfigure in Cloud Foundry

Summary

I was trying to get a spring-cloud-configuration-server running in our cloud environment. When extending an existing component with the maven dependency spring-cloud-configuration-client to make it consume the configuration from the configuration server, the application startup failed with the following error:

   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT ***************************
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT APPLICATION FAILED TO START
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT ***************************
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Description:
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Reason: Failed to determine a suitable driver class
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Action:
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Consider the following:
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT     If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT     If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
   2018-10-10T09:28:51.91+0200 [APP/PROC/WEB/0] OUT Exit status 1

I’ve created the minimal application to reproduce the error. See steps below.

Steps to reproduce

Step 1

Create a minimal spring-boot application using a database: 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>spring-config-demo</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.5.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

DemoApplication.java

package com.example.spring_config_demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class DemoApplication {

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

DemoController.java

package com.example.spring_config_demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/")
public class DemoController {

    @RequestMapping(method = RequestMethod.GET)
    public String helloWorld() {
        return "Hello World";
    }
}

Step 2

Build and deploy application to your cloud foundry environment. Create a MariaDB service and bind it to the application. Restart the application and check if the logs are fine.

Step 3

Add the dependency spring-cloud-configuration-client to the pom.xml, build and deploy the application

Dependency:

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-config-client</artifactId>
    <version>2.0.1.RELEASE</version>
</dependency>

Expected result

The application should start up without any change in behavior.

Actual result

The startup of the application fails with the following message:

   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT 2018-10-10 07:28:51.827 ERROR 8 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   :
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT ***************************
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT APPLICATION FAILED TO START
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT ***************************
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Description:
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Reason: Failed to determine a suitable driver class
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Action:
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT Consider the following:
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT     If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
   2018-10-10T09:28:51.82+0200 [APP/PROC/WEB/0] OUT     If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
   2018-10-10T09:28:51.91+0200 [APP/PROC/WEB/0] OUT Exit status 1

Actions taken

  • Aligned the versions of the dependencies (using spring-boot-starter-parent version 2.0.1.RELEASE)
  • Rebinding the service
  • Setting the driver with the property spring.datasource.driver-class-name

Additional Information

  • I attached the full log of the failed application startup startup.log
  • As far as I can tell we are using cloud foundry with these versions: Portal 4.10.6 - EXT API 4.10.1 - CF API 2.121.0
  • MariaDB version: 10.1.22

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 36 (17 by maintainers)

Most upvoted comments

Will do after christmas holidays.