Issue Description

When creating a Spring JDBC application with GraalVM native support it seems that the Converters that normally are available by default, are not registered automatically.

If I run my application using ./mvnw spring-boot:run, everything executes fine. When running the application using ./mvnw -Pnative native:compile && ./target/native-jdbc-converters, I get the following error: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.sql.Timestamp] to type [java.time.Instant].

I would expect this to work the same for a basic application. Does the native image build require extra configuration to register the JSR310 converters?

A repository with reproduction code can be found here: https://github.com/SanderKnauff/reproduction-spring-native-jdbc-converters

Reproduction steps

  1. Clone the repository above.
  2. Start the PostgreSQL database using docker-compose up.
  3. Run the application once with ./mvnw spring-boot:run. This time it should work fine.
  4. Run the native application by running ./mvnw native:compile && ./target/native-jdbc-converters. This will result in the aforementioned exception.

Environment

  • Spring Boot 3.5.4
  • OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)
  • Linux Mint

Comment From: wilkinsona

Thanks for the easy-to-use sample.

You're relying on ObjectToObjectConverter which can convert a Timestamp to an Instant by calling Timestamp#toInstant. This doesn't work in a native image as the toInstant method is not available for reflection.

Registering all possible methods that can be used by ObjectToObjectConverter would have a prohibitively large impact on the native image size so the Framework team chose not to do so. They do have a few selected hints for Object-to-Object conversion. We'll transfer this issue to the Framework team to see if they want to add Timestamp's toInstant method to those.

Comment From: SanderKnauff

Thank you, for now I will check if I can get the reflection hints in my own project, but I think this would be a really nice one to have by default.