# Can I safely use Solr and Elasticsearch dependencies in the same Java project?

**URL:** <https://discuss.elastic.co/t/can-i-safely-use-solr-and-elasticsearch-dependencies-in-the-same-java-project/230029>\
**Category:** Elasticsearch\
**Created:** [April 27, 2020, 8:54pm UTC](https://discuss.elastic.co/t/can-i-safely-use-solr-and-elasticsearch-dependencies-in-the-same-java-project/230029 "2020-04-27T20:54:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmavilia\_w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rmavilia_w/32/67222_2.png) [@rmavilia\_w](https://discuss.elastic.co/u/rmavilia_w)\
**Post date:** [April 27, 2020, 8:54pm UTC](https://discuss.elastic.co/t/can-i-safely-use-solr-and-elasticsearch-dependencies-in-the-same-java-project/230029/1 "2020-04-27T20:54:44Z")

</div>

**Intro**  
Hi so I have a Java project which started as a way to get data from a database and transport it into Solr. This project uses Maven and relies on the `solr-core` and `solr-solrj` artifacts as dependencies. For the Solr dependencies it uses version 6.6.2 of those libraries. Now I am trying to expand this app to also write data into Elasticsearch. I am using the `elasticsearch`, `elasticsearch-rest-high-level-client`, and `elasticsearch-rest-client` all on version 7.6.0

I ran into issues where my unit tests weren't working because of an error  
`java.lang.NoClassDefFoundError: org/apache/lucene/document/LegacyIntField`

This was due to a lucene-core conflict under the `elasticsearch` dependency. ES was using lucene-core version 8.4.0 and Solr was using 6.6.2. I excluded lucene-core from elasticsearch and now my unit tests work and my data seems to be flowing fine as well but now I can't publish with ES. Need to figure out how to have Solr and ElasticSearch use their own lucene-core libraries if that is even possible. I have been trying to shade by following [https://github.com/elastic/elasticsearch/issues/29184#issuecomment-475052904](https://github.com/elastic/elasticsearch/issues/29184#issuecomment-475052904) but I have not found much luck.

**Question**  
How can I allow ES and Solr to play nicely and use their own Lucene versions? Cheers!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 25, 2020, 8:54pm UTC](https://discuss.elastic.co/t/can-i-safely-use-solr-and-elasticsearch-dependencies-in-the-same-java-project/230029/2 "2020-05-25T20:54:48Z")

</div>

Closed on May 25, 2020, 8:54pm UTC

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