Class file for org.elasticsearch.common.xcontent.ToXContentObject not found

Hello,

I am trying to configure the Java High Level REST Client by using https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.6/java-rest-high-getting-started-maven.html document.

I am using gradle as a dependency manager.
I have added the followings to my configuration file :

'org.elasticsearch:elasticsearch:7.6.2'
'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.6.2',
'org.elasticsearch.client:elasticsearch-rest-client:7.6.2'

But unfortunately, It cannot find many classes in elastic search library.

Example classes are for org.elasticsearch.common.xcontent.ToXContentObject and org.elasticsearch.common.unit.TimeValue. There are so many others as well.

Could you help me to find why this is happening? Do i need more dependencies?

Thanks
Bengisu

Welcome!

Are you using Spring Boot by any chance?

Thank you!

No, I don't use Spring.

For one of my projects, here the maven dependency tree I have:

[INFO] fr.pilato.elasticsearch.crawler:fscrawler-elasticsearch-client-v7:jar:2.7-SNAPSHOT
[INFO] +- fr.pilato.elasticsearch.crawler:fscrawler-elasticsearch-client-base:jar:2.7-SNAPSHOT:compile
[INFO] +- org.elasticsearch.client:elasticsearch-rest-high-level-client:jar:7.6.2:compile
[INFO] |  +- org.elasticsearch:elasticsearch:jar:7.6.2:compile
[INFO] |  |  +- org.elasticsearch:elasticsearch-core:jar:7.6.2:compile
[INFO] |  |  +- org.elasticsearch:elasticsearch-secure-sm:jar:7.6.2:compile
[INFO] |  |  +- org.elasticsearch:elasticsearch-x-content:jar:7.6.2:compile
[INFO] |  |  |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.8.11:compile
[INFO] |  |  |  \- com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.8.11:compile
[INFO] |  |  +- org.elasticsearch:elasticsearch-geo:jar:7.6.2:compile
[INFO] |  |  +- org.apache.lucene:lucene-core:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-analyzers-common:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-backward-codecs:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-grouping:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-highlighter:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-join:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-memory:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-misc:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-queries:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-queryparser:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-sandbox:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-spatial:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-spatial-extras:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-spatial3d:jar:8.4.0:compile
[INFO] |  |  +- org.apache.lucene:lucene-suggest:jar:8.4.0:compile
[INFO] |  |  +- org.elasticsearch:elasticsearch-cli:jar:7.6.2:compile
[INFO] |  |  |  \- net.sf.jopt-simple:jopt-simple:jar:5.0.2:compile
[INFO] |  |  +- com.carrotsearch:hppc:jar:0.8.1:compile
[INFO] |  |  +- joda-time:joda-time:jar:2.10.4:compile
[INFO] |  |  +- com.tdunning:t-digest:jar:3.2:compile
[INFO] |  |  +- org.hdrhistogram:HdrHistogram:jar:2.1.9:compile
[INFO] |  |  +- org.apache.logging.log4j:log4j-api:jar:2.13.1:compile (optional) 
[INFO] |  |  \- org.elasticsearch:jna:jar:4.5.1:compile
[INFO] |  +- org.elasticsearch.client:elasticsearch-rest-client:jar:7.6.2:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.12:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.13:compile
[INFO] |  |  +- org.apache.httpcomponents:httpasyncclient:jar:4.1.4:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore-nio:jar:4.4.13:compile
[INFO] |  |  +- commons-codec:commons-codec:jar:1.14:compile
[INFO] |  |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  +- org.elasticsearch.plugin:mapper-extras-client:jar:7.6.2:compile
[INFO] |  +- org.elasticsearch.plugin:parent-join-client:jar:7.6.2:compile
[INFO] |  +- org.elasticsearch.plugin:aggs-matrix-stats-client:jar:7.6.2:compile
[INFO] |  +- org.elasticsearch.plugin:rank-eval-client:jar:7.6.2:compile
[INFO] |  \- org.elasticsearch.plugin:lang-mustache-client:jar:7.6.2:compile
[INFO] |     \- com.github.spullara.mustache.java:compiler:jar:0.9.6:compile
[INFO] +- fr.pilato.elasticsearch.crawler:fscrawler-framework:jar:2.7-SNAPSHOT:compile
[INFO] |  +- commons-io:commons-io:jar:2.6:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.10.3:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.10.3:compile
[INFO] |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.10.3:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-xml:jar:2.10.3:compile
[INFO] |  |  +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.10.3:compile
[INFO] |  |  |  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.2:compile
[INFO] |  |  |  \- jakarta.activation:jakarta.activation-api:jar:1.2.1:compile
[INFO] |  |  +- org.codehaus.woodstox:stax2-api:jar:4.2:compile
[INFO] |  |  \- com.fasterxml.woodstox:woodstox-core:jar:6.1.1:compile
[INFO] |  +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.10.3:compile
[INFO] |  |  \- org.yaml:snakeyaml:jar:1.26:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.3:compile
[INFO] |  +- org.apache.logging.log4j:log4j-core:jar:2.13.1:compile (optional) 
[INFO] |  +- org.apache.logging.log4j:log4j-1.2-api:jar:2.13.1:compile (optional) 
[INFO] |  +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.13.1:compile (optional) 
[INFO] |  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile (optional) 
[INFO] |  +- org.apache.logging.log4j:log4j-jcl:jar:2.13.1:compile (optional) 
[INFO] |  +- org.apache.logging.log4j:log4j-jul:jar:2.13.1:compile (optional) 
[INFO] |  \- org.fusesource.jansi:jansi:jar:1.18:compile (optional) 
[INFO] +- fr.pilato.elasticsearch.crawler:fscrawler-settings:jar:2.7-SNAPSHOT:compile

The class you're looking for is in org.elasticsearch:elasticsearch-x-content:jar:7.6.2:compile. Do you have it?

You're right. I don't have it.

I also needed to add all the transitive dependencies of elasticsearch.

This was useful, thank you!

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