Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native Image with Spring Boot 3.0.0 logging trouble

When I start native Image of Spring Boot 3.0.0 spring-boot-starter-web with Docker, it shows strange log messages like this:

:: Spring Boot :: (v3.0.0)
%PARSER_ERROR[d] %PARSER_ERROR[p] 1 --- [%PARSER_ERROR[t]] %PARSER_ERROR[logger] : %PARSER_ERROR[m]%PARSER_ERROR[n]%PARSER_ERROR[d] %PARSER_ERROR[p] 1 --- [%PARSER_ERROR[t]] %PARSER_ERROR[logger] : %PARSER_ERROR[m]%PARSER_ERROR[n]%PARSER_ERROR[d] %PARSER_ERROR[p] 1 ---

Before I tried dependency spring-boot-starter-webflux in this case the build of the native image failed with error:
com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of ch.qos.logback.classic.Logger are allowed in the image heap

With Spring Initializr I generated a new project:

  • Maven
  • Java 17
  • Spring Boot version 3.0.0
  • Jar
  • Dependencies: spring-boot-starter-web & lombok

Then I build native Image with Maven "mvn -p native spring-boot:build-image".

I had the expectation, that native Images just work with the new Spring release for simple configuration like the one I made here. Am I missing something or has Spring Boot 3.0.0 big issues in supporting native Images?

like image 819
Elmar Brauch Avatar asked Apr 29 '26 12:04

Elmar Brauch


2 Answers

At the time when I asked this question, Spring Initializr did not offer (plugin-)dependency "GraalVM Native Support" for Spring Boot 3.0.0.

Now this dependency is available. As confirmed at SpringOne event, it has to be used. After adding it the mentioned errors do not appear. The minimal required part in Maven config is this:

<plugin>
  <groupId>org.graalvm.buildtools</groupId>
  <artifactId>native-maven-plugin</artifactId>
</plugin>
like image 176
Elmar Brauch Avatar answered May 02 '26 01:05

Elmar Brauch


You need to make sure you add reachability of metadata goal in your build plugin see github issue

<plugin>
  <groupId>org.graalvm.buildtools</groupId>
  <artifactId>native-maven-plugin</artifactId>
  <configuration>
    <classesDirectory>${project.build.outputDirectory}</classesDirectory>
    <metadataRepository>
      <enabled>true</enabled>
    </metadataRepository>
    <requiredVersion>22.3</requiredVersion>
  </configuration>
  <executions>
    <execution>
      <id>add-reachability-metadata</id>
      <goals>
        <goal>add-reachability-metadata</goal>
      </goals>
    </execution>
  </executions>
</plugin>
like image 41
Tafadzwa L Nyamukapa Avatar answered May 02 '26 02:05

Tafadzwa L Nyamukapa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!