spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

@JsonNaming strategy not supported in GraalVM native image

Open sarathchand09 opened this issue 3 years ago • 1 comments

Hello,

I am using Spring Boot 3.0 RC1 and GraalVM latest.

My native image works fine.

@JsonNaming(PropertyNamingStrategies.UpperSnakeCaseStrategy.class)

Using the above annotation for upper case JSON field names works fine with jar, but it doesn't work when running in the native image.

I am also using Lombok @Data on my POJO.

2022-10-26T14:42:15.875+02:00 WARN 1 --- [nio-8080-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Error creating bean with name 'com.fasterxml.jackson.databind.PropertyNamingStrategies$UpperSnakeCaseStrategy': Failed to instantiate [com.fasterxml.jackson.databind.PropertyNamingStrategies$UpperSnakeCaseStrategy]: No default constructor found] |

sarathchand09 avatar Oct 26 '22 12:10 sarathchand09

What happens if you manually add GraalVM native image reflection configuration for com.fasterxml.jackson.databind.PropertyNamingStrategies.UpperSnakeCaseStrategy?

sbrannen avatar Oct 26 '22 13:10 sbrannen

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Nov 02 '22 13:11 spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

spring-projects-issues avatar Nov 09 '22 13:11 spring-projects-issues

Note that we had a similar report in Spring Boot and we've just pushed something that would contribute those hints, see https://github.com/spring-projects/spring-boot/pull/33080

snicoll avatar Nov 09 '22 14:11 snicoll

@snicoll, it looks to me like the PR in Boot will only register those constant fields for reflection, not the constructors for the actual PropertyNamingStrategy implementations.

Or am I missing something?

sbrannen avatar Nov 09 '22 14:11 sbrannen

Should be handled by #29646 fix.

sdeleuze avatar Jan 20 '23 15:01 sdeleuze