Home > Back-end >  Spring Boot application failed to start on ECS Fargte
Spring Boot application failed to start on ECS Fargte

Time:02-26

Ive got a springboot application that when bundled into a docker image and published to Amazon ECS fails to start

The error message is:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|   timestamp   |                                                                                                                                        message                                                                                                                                        |
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1645724032287 |   .   ____          _            __ _ _                                                                                                                                                                                                                                               |
| 1645724032287 |  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \                                                                                                                                                                                                                                              |
| 1645724032287 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \                                                                                                                                                                                                                                             |
| 1645724032287 |  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )                                                                                                                                                                                                                                            |
| 1645724032287 |   '  |____| .__|_| |_|_| |_\__, | / / / /                                                                                                                                                                                                                                             |
| 1645724032287 |  =========|_|==============|___/=/_/_/_/                                                                                                                                                                                                                                              |
| 1645724032290 |  :: Spring Boot ::                                                                                                                                                                                                                                                                    |
| 1645724033092 | 17:33:53.090 [main] INFO com.jtmaxwell.Microservice.DocumentGenerator.Application - Starting Application using Java 11.0.14.1 on ip-172-31-20-189.eu-west-1.compute.internal with PID 1 (/app.jar started by root in /)                                                               |
| 1645724033093 | 17:33:53.093 [main] DEBUG com.jtmaxwell.Microservice.DocumentGenerator.Application - Running with Spring Boot, Spring                                                                                                                                                                 |
| 1645724033093 | 17:33:53.093 [main] INFO com.jtmaxwell.Microservice.DocumentGenerator.Application - No active profile set, falling back to default profiles: default                                                                                                                                  |
| 1645724033095 | 17:33:53.095 [main] DEBUG org.springframework.boot.SpringApplication - Loading source class com.jtmaxwell.Microservice.DocumentGenerator.Application                                                                                                                                  |
| 1645724033893 | 17:33:53.893 [main] DEBUG org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext - Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@13acb0d1                                       |
| 1645724034087 | 17:33:54.087 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'                                                         |
| 1645724034591 | 17:33:54.590 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: URL [jar:file:/app.jar!/com/jtmaxwell/Microservice/DocumentGenerator/config/MessagingConfig.class]                                            |
| 1645724034601 | 17:33:54.599 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: URL [jar:file:/app.jar!/com/jtmaxwell/Microservice/DocumentGenerator/consumer/User.class]                                                     |
| 1645724034697 | 17:33:54.693 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: URL [jar:file:/app.jar!/com/jtmaxwell/Microservice/DocumentGenerator/publisher/OrderPublisher.class]                                          |
| 1645724035094 | 17:33:55.094 [main] ERROR org.springframework.boot.SpringApplication - Application run failed                                                                                                                                                                                         |
| 1645724035094 | java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.                                                                                                            |
| 1645724035094 |  at org.springframework.util.Assert.notEmpty(Assert.java:470)                                                                                                                                                                                                                         |
| 1645724035094 |  at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:180)                                                                                                                                       |
| 1645724035094 |  at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getAutoConfigurationEntry(AutoConfigurationImportSelector.java:123)                                                                                                                                        |
| 1645724035094 |  at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:434)                                                                                                                                   |
| 1645724035094 |  at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:879)                                                                                                                                      |
| 1645724035094 |  at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:809)                                                                                                                      |
| 1645724035094 |  at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:780)                                                                                                                                          |
| 1645724035094 |  at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:193)                                                                                                                                                                          |
| 1645724035094 |  at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)                                                                                                                                     |
| 1645724035094 |  at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247)                                                                                                                                |
| 1645724035094 |  at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)                                                                                                                      |
| 1645724035094 |  at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)                                                                                                                                 |
| 1645724035094 |  at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)                                                                                                                                               |
| 1645724035094 |  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)                                                                                                                                                                       |
| 1645724035094 |  at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)                                                                                                                                              |
| 1645724035094 |  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)                                                                                                                                                                                                    |
| 1645724035094 |  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)                                                                                                                                                                                             |
| 1645724035094 |  at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)                                                                                                                                                                                                        |
| 1645724035094 |  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)                                                                                                                                                                                                       |
| 1645724035094 |  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)                                                                                                                                                                                                       |
| 1645724035094 |  at com.jtmaxwell.Microservice.DocumentGenerator.Application.main(Application.java:18)                                                                                                                                                                                                |
| 1645724035293 | 17:33:55.290 [main] DEBUG org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext - Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@13acb0d1, started on Thu Feb 24 17:33:53 UTC 2022 |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The pom.xml is

<?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.6.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.jtmaxwell</groupId>
    <artifactId>microservice.documentgenerator</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Microservice.DocumentGenerator</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>

    <repositories>
        <repository>
            <id>clojars.org</id>
            <url>https://repo.clojars.org</url>
          </repository>
    </repositories>

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

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>io.github.erdos</groupId>
            <artifactId>stencil-core</artifactId>
            <version>0.3.29</version>
          </dependency>

          <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.13.0</version>
        </dependency>
    </dependencies>

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

</project>

CodePudding user response:

Can you please check first the docker images run outside of ECS? Seem there are some libs not got bundled as part of the docker build.

Also i assume your spring boot app runs locally

CodePudding user response:

The answer here was as others highlighted. The image was missing dependencies due to the jar file from Visual Code being used for the docker build.

I ran the supplied

mvnw package

Then used the resulting jar file to build the docker image

  • Related