Skip to content

NullPointerException from ValueInstantiationCustomizer in native images #2213

@mathieupedreropro

Description

@mathieupedreropro

Hi,

First of all, I apologize for having allready submitted this issue in the spring boot project (My initial guess) and into the Hateaos project (following mhalbritter advice). Bu today, I tried to debug this issue by myself, and I realized some Spring-data-rest classes are at stake (ResourceSupportHttpMessageConverter, RepositoryRestMvcConfiguration, or PersistentEntityResource for example). So I think here should finally be the right place...

I'm working with Spring-boot 3.0.0, that (through spring dependecy-management) pulls spring-data-rest 4.0.0 in my project. I work in a native context (builder paketobuildpacks/builder:tiny, 'BP_NATIVE_IMAGE': 'true' in my gradle bootBuildImage task)

In a very simple context, when compiling with spring boot native, I can't perform a patch 'for example) update of my entity reffering a child entity with its url identifier.

When I perform a PATH request with a body like this one:

{
  "shouldBeChecked": true,
  "name": "Amical6",
  "parent": null,
  "authority": "https://myurl/api/authorities/e52cdfb6-6f3c-4552-8ea4-e1357b5d052c"
}

I get the following errors :

in the web navigator (running the client app):

{"cause":{"cause":null,"message":"Cannot construct instance of `org.[xxx].Authority` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('https://myurl/api/authorities/e52cdfb6-6f3c-4552-8ea4-e1357b5d052c')\n at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: org.[xxx].MyObject[\"authority\"])"},"message":"Could not read payload"}

And, in my application logs :

Failed to evaluate Jackson deserialization for type [[simple type, class org.springframework.data.rest.webmvc.PersistentEntityResource]]: java.lang.NullPointerException

While, in the meantime, when run my project in a non native context (for example in my IDE), I've got no problem at all.

Please find below:

Thanks a lot !

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions