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

ClassNotFoundException com.fasterxml.jackson.core.StreamReadConstraints [BUG] #8219

Closed
bartweber opened this issue Jun 22, 2023 · 4 comments
Closed
Labels
bug Something isn't working Clients Clients within the Core repository such as High level Rest client and low level client

Comments

@bartweber
Copy link

Describe the bug
Class com.fasterxml.jackson.core.StreamReadConstraints seems to be missing for opensearch-x-content-2.8.0

To Reproduce
Steps to reproduce the behavior:
In my case I was using org.opensearch.client:opensearch-rest-high-level-client:2.8.0 and did the following method call:
org.opensearch.client.indices.PutIndexTemplateRequest#source which causes a ClassNotFoundException with the following stack trace:

Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/StreamReadConstraints
	at org.opensearch.common.xcontent.json.JsonXContent.<clinit>(JsonXContent.java:80)
	at org.opensearch.common.xcontent.XContentFactory.contentBuilder(XContentFactory.java:144)
	at org.opensearch.common.settings.Settings$Builder.loadFromMap(Settings.java:1083)
	at org.opensearch.client.indices.PutIndexTemplateRequest.settings(PutIndexTemplateRequest.java:207)
	at org.opensearch.client.indices.PutIndexTemplateRequest.source(PutIndexTemplateRequest.java:332)
	... [omitted for security reasons]
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.StreamReadConstraints
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 30 common frames omitted

Expected behavior
Should not throw ClassNotFoundException when calling org.opensearch.client.indices.PutIndexTemplateRequest#source.

Plugins
Not relevant I think.

Host/Environment (please complete the following information):
Not relevant I think.

Additional context
Using JDK 11

@bartweber bartweber added bug Something isn't working untriaged labels Jun 22, 2023
@Xtansia Xtansia added the Clients Clients within the Core repository such as High level Rest client and low level client label Jun 22, 2023
@Xtansia
Copy link
Contributor

Xtansia commented Jun 22, 2023

Hi @bartweber, Is it possible you are explicitly pulling in a version of Jackson that is lower than 2.15.x? As the StreamReadConstraints class was added in version 2.15 of jackson-core.

@bartweber
Copy link
Author

bartweber commented Jun 23, 2023

Yes that's it @Xtansia. Sorry for the hassle. I must have been distracted while looking in this issue. We use the OpenSearch Java client (org.opensearch.client:opensearch-rest-high-level-client:2.8.0) in a Spring Boot application (org.springframework.boot:spring-boot-starter-web:2.7.13) which determines that the version 2.13.5 of jackson-core should be on the classpath while - as you explained - opensearch-rest-high-level-client needs 2.15.x or higher.

The previous version org.opensearch.client:opensearch-rest-high-level-client:2.7.0 still works i.c.w. org.springframework.boot:spring-boot-starter-web:2.7.13 (without any further adjustments).

@Xtansia
Copy link
Contributor

Xtansia commented Jun 23, 2023

No worries, glad you were able to find a working combination for your use case.

@asbajwa5190
Copy link

asbajwa5190 commented Sep 21, 2024

Hi, I am facing similar issue while we are upgrading to spring boot 3.3.2. I have analysed the dependencies and found all the jackson-core dependencies as 2.15.0 or above.

Following exceptions are occurring while running test cases:
Exception java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/StreamWriteConstraints
java.lang.NoClassDefFoundError: Could not initialize class org.opensearch.common.xcontent.json.JsonXContent

When I search for the StreamWriteConstraints class in the IDE, it is not present.

Attaching the mvn dependency tree of the project also
mvn dependencies.txt

I would Appreciate Your Help!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Clients Clients within the Core repository such as High level Rest client and low level client
Projects
None yet
Development

No branches or pull requests

3 participants