Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Could not initialize class org.opensearch.common.xcontent.json.JsonXContent after updating from 2.11.1 to 2.12.0 #12950

Closed
acnolan opened this issue Mar 27, 2024 · 5 comments
Labels
bug Something isn't working Other

Comments

@acnolan
Copy link

acnolan commented Mar 27, 2024

Describe the bug

After updating from OpenSearch version 2.11.1 to 2.12.0 my code now produces the following error:

java.lang.NoClassDefFoundError: Could not initialize class org.opensearch.common.xcontent.json.JsonXContent

This is in a Java Springboot app. I am using Maven for package management and updated no other dependencies besides this one.

I did not see any required dependency changes or deprecations in the release notes for this version.

Related component

Other

To Reproduce

The following is a simplified version of the code I am using. Additional parameters are set on the searchRequest and searchSource.

SearchRequest searchRequest = searchRequest();
SearchSourceBuilder searchSource = searchSource();
restHighLevelClient.search(searchRequest.source(searchSource), RequestOptions.DEFAULT)

Within the RestHighLevelClient search method the error is thrown

java.lang.NoClassDefFoundError: Could not initialize class org.opensearch.common.xcontent.json.JsonXContent

Expected behavior

The code should execute without throwing an error, as it does with 2.11.1.

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@acnolan acnolan added bug Something isn't working untriaged labels Mar 27, 2024
@github-actions github-actions bot added the Other label Mar 27, 2024
@cwperks
Copy link
Member

cwperks commented Apr 3, 2024

Do you have lib/opensearch-x-content-2.12.1-SNAPSHOT.jar on the classpath? I just pulled the latest on the 2.12 branch, created a local distribution and I can see this class in the jar.

➜  opensearch-2.12.1-SNAPSHOT git:(2.12) ✗ jar -tf lib/opensearch-x-content-2.12.1-SNAPSHOT.jar
...
org/opensearch/common/xcontent/json/JsonXContent.class
...

@peternied
Copy link
Member

[Triage - attendees 1 2 3 4 5 6]
@acnolan Thanks for creating this issue

@acnolan
Copy link
Author

acnolan commented Apr 12, 2024

Thanks for your help looking into this. I see the class in my classpath and in IntelliJ I can see it in the external library browser for my project. It is strange, if I downgrade to older versions of OpenSearch like 2.10.0 or 2.11.0 it works as expected. But 2.12.0 or the new 2.13.0 do not seem to be working for me.

I will look into it a little more to see if something is wrong in my project structure as well.

@acnolan
Copy link
Author

acnolan commented Apr 24, 2024

Hi! I can't believe I opened this a month ago, time flies. However, we can close this ticket now. I found a solution.

I needed to update the Liquibase dependency in my POM from 4.26.0 to 4.27.0. I am not sure why this fixed the issue but that was the only change needed to get it working again.

Closing with this comment so others with similar issues may see it.

@acnolan acnolan closed this as completed Apr 24, 2024
@pmioulet
Copy link

pmioulet commented Sep 3, 2024

I had the same issue with Springboot 2.2.X. Issue is in fact linked to the version of jackson. openseach above 2.12 has a minimal requirement of jackson 2.16. Springboot 2.2 ships with 2.14. I suspect the static initialisation in JsonXContent class fails silently due to a missing configuration parameter in older jackson versions. I did not investigate further to see which parameter is missing.

Hope this note helps anyone else facing the issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Other
Projects
None yet
Development

No branches or pull requests

4 participants