FieldNotFoundError on update to Elasticsearch 7.16.2

since the update to Elasticsearch 7.16. I'm getting a java.lang.NoSuchFieldError: INDEX_CONTENT_TYPE when running a Unit Test that executes a save/saveAll() statement with Test containers.
On 7.15 everything works just fine. Unfortunately I'm now forced to use 7.16 and can't just switch to any other version.

Here is an example project of the setup:

It seems that the class for which the field could not be found is all right. It's the "Requests" class from Elasticsearch and the INDEX_CONTENT_TYPE field is public, static.
I ran the test with -verbose:class and the Requests-class is loaded only one time, so it shouldn't be overshadowed by another dependency.
It however works when I just normally run the application. Does that mean the container test setup is somehow influencing the class loading process?

Does anyone have an idea what the issue is, or how I could further debug that error?


Spring Data probably uses a different Elasticsearch dependency than the one you specified and this results in such compilation errors.

In general I would not change the version of Elasticsearch used by Spring Data, but keep upgrading spring data Elasticsearch and thus its version.

Edit: The statement that it works when I run the application normally was wrong. It also doesn't work outside Tests.

Ah I reread your post and now I'm getting it. You might be right with this. However during the debug session I only had one Elasticssearch dependency in my class path which was the 7.16 one. Also the -verbose:class logs only indicated that only one Elasticsearch version was loaded.

Also it's kind of strange that downgrading it to 7.15 worked again. If my current elastic-search-data would have overshadow the maven defined version, I would expect 7.15 to break as well.

Aside from that I unfortunately am forced to use the 7.16 version, there is however no spring-data version out there yet that uses org.Elasticsearch.client:7.16.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.