Skip to content

Native image doesn't start and doesn't log anything if an environment post processor throws an exception #40429

@danparisi

Description

@danparisi

My spring boot 3.2.4 project doesn't start up when built native if my technical library contains an EnvironmentPostProcessor linked in spring.factories resource. If I get rid of both from the library and just copy paste the same processor in the main project repo and build it again, it works fine.

The application doesn't start either locally nor from a kubernetes POD. It just exits at startup, no logs at all are printed out:

docker --debug run --rm -p 8080 my-docker-repo:30501/repository/docker/my-service:latest
DEBU[0000] [hijack] End of stdout  

My POM looks like this:

    <parent>
        <groupId>com.xxx</groupId>
        <artifactId>my-parent</artifactId>
        <version>0.0.33</version>
    </parent>

    <artifactId>my-service<artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        ...
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.xxx</groupId>
            <artifactId>my-tech-starter</artifactId>
            <version>0.0.42-SNAPSHOT</version>
        </dependency>

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

        <dependency>
            <groupId>org.jeasy</groupId>
            <artifactId>easy-random-core</artifactId>
            <version>${easy-random.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

While my-tech-starter has a bunch of spring boot / cloud dependencies but what really makes the diff looks to be this EnvironmentPostProcessor linked in the spring.factories:

org.springframework.boot.env.EnvironmentPostProcessor=\
com.xxx.techstarter.processor.SpringConfigImportEnvironmentPostProcessor

If I removed those 2 files, it works. Even if I copy the SpringConfigImportEnvironmentPostProcessor in the main project. Note that the library is build with -Pnative flag and I can see the /META-INF/native-image/ inside the JAR.
If i do a standard, non native build, it works fine in any case.

Any idea? Thanks a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions