Skip to content

Spring Cloud + Eureka Client + AOT-CACHE not build #1599

@marcoberri

Description

@marcoberri

Hello,
I have a sample project in Spring boot/cloud + Eureka Client.

spring-boot-dependencies : 3.5.0
spring-cloud-dependencies : 2025.0.0
jdk: 24

<?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>it.marcoberri</groupId>
        <artifactId>my-parent</artifactId>
        <version>2.2.0-release</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <artifactId>poc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>aot</name>
    <description>Aot</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>24</java.version>
    </properties>
    <dependencies>



 <!-- STARTED + JETTY  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <!-- Exclude the Tomcat dependency -->
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>



        <!-- Use Jetty instead -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>


        <!-- EUREKA CLIENT -->

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>


        <!-- Actuator -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

<!-- TEST  CLASS -->

        <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>
                <version>3.5.0</version>

                <executions>

                    <execution>
                        <id>repackage</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>process-aot</id>
                        <goals>
                            <goal>process-aot</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

my parent pom

<?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>it.marcoberri</groupId>
    <artifactId>my-parent</artifactId>
    <version>2.2.0-release</version>
    <packaging>pom</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Java -->
        <java.version>24</java.version>
        <maven.compiler.release>24</maven.compiler.release>
        <maven.compiler.source>24</maven.compiler.source>
        <maven.compiler.target>24</maven.compiler.target>


        <!-- Plugin -->
        <maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
        <maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
        <maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>
        <lombok.version>1.18.38</lombok.version>


    </properties>


    <dependencyManagement>
        <dependencies>

            <!-- Spring Boot dependencies -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>3.5.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>


            <!-- Spring Cloud dependencies -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>2025.0.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>33.4.8-jre</version>
            </dependency>

            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcutil-jdk18on</artifactId>
                <version>1.80</version>
            </dependency>

        </dependencies>
    </dependencyManagement>


</project>

Application is very simple

@SpringBootApplication
public class AotApplication {

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

}

application.properties


################################################
#              SERVER                          #
################################################
#override with desired HTTP port (remember to synch this value with docker port)
server.port=9069
#additional HTTP port (will open it in SpringConfiguration)
server.http.port=8069
#override with desired name
spring.application.name=aot
spring.main.banner-mode=off
server.shutdown=graceful
server.error.include-message=always
server.error.include-binding-errors=always



################################################
#              EUREKA                          #
################################################
eureka.client.serviceUrl.defaultZone=http://localhost:8061/eureka/
eureka.client.enabled=true
# send data health to Eureka
eureka.client.healthcheck.enabled=true
eureka.instance.instance-id=${spring.application.name}:${spring.application.instance_id:${random.value}}


############################################
#  ACTUATOR
############################################
# publish health indicator
management.endpoint.health.show-details=always
#including every endpoint for actuator
management.endpoints.web.exposure.include=*
#add management logs with actuator
management.endpoint.loggers.enabled=true
#http trace response header
management.httpexchanges.recording.include=RESPONSE_HEADERS
management.endpoint.httptrace.enabled=true
management.endpoint.env.show-values=ALWAYS
management.endpoint.configprops.show-values=ALWAYS
management.info.env.enabled=true
management.observations.key-values.application=${spring.application.name}



############################################
#  AOT
############################################
spring.cloud.refresh.enabled=false
spring.aot.enabled=true

Reference --> https://docs.spring.io/spring-boot/reference/packaging/class-data-sharing.html#packaging.class-data-sharing.aot-cache

mvn "-Dmaven.test.skip=true" clean package

is ok

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  40.370 s
[INFO] Finished at: 2025-06-09T12:15:45+02:00
[INFO] ------------------------------------------------------------------------

java -Djarmode=tools -jar target/poc-0.0.1-SNAPSHOT.jar extract --destination application

is ok

cd application
java "-Dspring.profiles.active=local" "-XX:AOTMode=record" "-XX:AOTConfiguration=app.aotconf" "-Dspring.context.exit=onRefresh" -jar .\poc-0.0.1-SNAPSHOT.jar

is ok, last log

06-09T12:23:07.146+02:00  INFO 53244 --- [aot] [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2025-06-09T12:23:07.149+02:00  INFO 53244 --- [aot] [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1749464587148 with initial instances count: 3
2025-06-09T12:23:07.720+02:00  WARN 53244 --- [aot] [           main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production.You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2025-06-09T12:23:07.733+02:00  INFO 53244 --- [aot] [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 15 endpoints beneath base path '/actuator'

java "-Dspring.profiles.active=local" "-XX:AOTMode=create" "-XX:AOTConfiguration=app.aotconf" "-XX:AOTCache=app.aot" -jar .\poc-0.0.1-SNAPSHOT.jar

Not Build!

[41.415s][error  ][cds,heap] Scanned 103932 objects. Found 105 case(s) where an object points to a static field that may hold a different value at runtime.
[41.415s][error  ][cds     ] An error has occurred while writing the shared archive file.

attach complete log.

error.log

Tnx Marco.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions