# 0.90.0 RC2 Java API Compilation Error: "org.apache.lucene.util.ByteRef cannot be resolved"

**URL:** https://discuss.elastic.co/t/0-90-0-rc2-java-api-compilation-error-org-apache-lucene-util-byteref-cannot-be-resolved/11663
**Category:** Elasticsearch
**Created:** [April 23, 2013, 2:36am UTC](https://discuss.elastic.co/t/0-90-0-rc2-java-api-compilation-error-org-apache-lucene-util-byteref-cannot-be-resolved/11663 "2013-04-23T02:36:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Harkirat\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harkirat_singh/32/2367_2.png) [@Harkirat\_Singh](https://discuss.elastic.co/u/Harkirat_Singh)
#### Post date: [April 23, 2013, 2:36am UTC](https://discuss.elastic.co/t/0-90-0-rc2-java-api-compilation-error-org-apache-lucene-util-byteref-cannot-be-resolved/11663/1 "2013-04-23T02:36:29Z")

</div>

ES 0.90.0.RC2

I recently upgraded to ES 0.90.0.RC2 from 0.20.6, and I noticed that my  
JAVA client doesn't compile anymore. I used to only have  
elasticsearch-0.20.6.jar in my project classpath, and I replaced it with  
elasticsearch-0.90.0.rc2.jar. The offending class is \*  
org.apache.lucene.util.BytesRef\*, but this is used at quite a number of  
places. I found out from the source that this class is packaged in  
lucene-core-4.2.1.jar, grabbed that class (and some more like  
BytesRefComparator, UnicodeUtil after subsequent runtime errors),  
unpackaged elasticsearch-0.90.0.rc2.jar, and copied the class in the  
appropriate places. This gets rid of the compilation and runtime errors,  
however, performing a JAR surgery like this makes me a bit uncomfortable.

I was under the impression that elasticsearch-0.90.0.rc2.jar is all you  
need while creating a client for ES. So shouldn't it run standalone without  
depending on any other libraries in the lib/ directory? Am I missing  
something? Here is the error I see in Eclipse:

XContentBuilder o = XContentFactory.jsonBuilder().startObject();  
o.field("line", "this is a test line"); // Error: "Type  
org.apache.lucene.util.ByteRef cannot be resolved. It is indirectly  
referenced from required .class files"

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 23, 2013, 5:48am UTC](https://discuss.elastic.co/t/0-90-0-rc2-java-api-compilation-error-org-apache-lucene-util-byteref-cannot-be-resolved/11663/2 "2013-04-23T05:48:59Z")

</div>

You should check if you have more than one Lucene jar in your class path.  
So clean your target directory or something like that.

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 23 avr. 2013 à 04:36, Harkirat Singh [singh.harkirat@gmail.com](mailto:singh.harkirat@gmail.com) a écrit :

> ES 0.90.0.RC2
> 
> I recently upgraded to ES 0.90.0.RC2 from 0.20.6, and I noticed that my JAVA client doesn't compile anymore. I used to only have elasticsearch-0.20.6.jar in my project classpath, and I replaced it with elasticsearch-0.90.0.rc2.jar. The offending class is org.apache.lucene.util.BytesRef, but this is used at quite a number of places. I found out from the source that this class is packaged in lucene-core-4.2.1.jar, grabbed that class (and some more like BytesRefComparator, UnicodeUtil after subsequent runtime errors), unpackaged elasticsearch-0.90.0.rc2.jar, and copied the class in the appropriate places. This gets rid of the compilation and runtime errors, however, performing a JAR surgery like this makes me a bit uncomfortable.
> 
> I was under the impression that elasticsearch-0.90.0.rc2.jar is all you need while creating a client for ES. So shouldn't it run standalone without depending on any other libraries in the lib/ directory? Am I missing something? Here is the error I see in Eclipse:
> 
> XContentBuilder o = XContentFactory.jsonBuilder().startObject();  
> o.field("line", "this is a test line"); // Error: "Type org.apache.lucene.util.ByteRef cannot be resolved. It is indirectly referenced from required .class files"
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Harkirat\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harkirat_singh/32/2367_2.png) [@Harkirat\_Singh](https://discuss.elastic.co/u/Harkirat_Singh)
#### Post date: [April 29, 2013, 11:50pm UTC](https://discuss.elastic.co/t/0-90-0-rc2-java-api-compilation-error-org-apache-lucene-util-byteref-cannot-be-resolved/11663/3 "2013-04-29T23:50:26Z")

</div>

Created a new issue for  
tracking: [0.90.0 Java API Compilation Error: "org.apache.lucene.util.ByteRef cannot be resolved" · Issue #2950 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/2950)

-Hark

On Monday, April 22, 2013 10:36:29 PM UTC-4, Harkirat Singh wrote:

> ES 0.90.0.RC2
> 
> I recently upgraded to ES 0.90.0.RC2 from 0.20.6, and I noticed that my  
> JAVA client doesn't compile anymore. I used to only have  
> elasticsearch-0.20.6.jar in my project classpath, and I replaced it with  
> elasticsearch-0.90.0.rc2.jar. The offending class is \*  
> org.apache.lucene.util.BytesRef\*, but this is used at quite a number of  
> places. I found out from the source that this class is packaged in  
> lucene-core-4.2.1.jar, grabbed that class (and some more like  
> BytesRefComparator, UnicodeUtil after subsequent runtime errors),  
> unpackaged elasticsearch-0.90.0.rc2.jar, and copied the class in the  
> appropriate places. This gets rid of the compilation and runtime errors,  
> however, performing a JAR surgery like this makes me a bit uncomfortable.
> 
> I was under the impression that elasticsearch-0.90.0.rc2.jar is all you  
> need while creating a client for ES. So shouldn't it run standalone without  
> depending on any other libraries in the lib/ directory? Am I missing  
> something? Here is the error I see in Eclipse:
> 
> XContentBuilder o = XContentFactory.jsonBuilder().startObject();  
> o.field("line", "this is a test line"); // Error: "Type  
> org.apache.lucene.util.ByteRef cannot be resolved. It is indirectly  
> referenced from required .class files"

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [April 30, 2013, 8:43am UTC](https://discuss.elastic.co/t/0-90-0-rc2-java-api-compilation-error-org-apache-lucene-util-byteref-cannot-be-resolved/11663/4 "2013-04-30T08:43:49Z")

</div>

The class org.apache.lucene.util.ByteRef was patched by ES before 0.90 and  
that version was included in the ES jar but this is no longer the case in  
0.90

Note, ES did never include the Lucene jars by intention. You have to add  
this dependency separately. I agree this is confusing developers (there are  
more confusing things when it comes to shading dependencies into the ES jar  
and to the optional jars). I assume this is just because ES deployments can  
be upgraded to a fix version of Lucene without the release of a new ES  
version.

Of course, you can build your own version of ES, adding Lucene as a shaded  
jar.  
Jörg

On Tuesday, April 23, 2013 4:36:29 AM UTC+2, Harkirat Singh wrote:

> ES 0.90.0.RC2
> 
> I recently upgraded to ES 0.90.0.RC2 from 0.20.6, and I noticed that my  
> JAVA client doesn't compile anymore. I used to only have  
> elasticsearch-0.20.6.jar in my project classpath, and I replaced it with  
> elasticsearch-0.90.0.rc2.jar. The offending class is \*  
> org.apache.lucene.util.BytesRef\*, but this is used at quite a number of  
> places. I found out from the source that this class is packaged in  
> lucene-core-4.2.1.jar, grabbed that class (and some more like  
> BytesRefComparator, UnicodeUtil after subsequent runtime errors),  
> unpackaged elasticsearch-0.90.0.rc2.jar, and copied the class in the  
> appropriate places. This gets rid of the compilation and runtime errors,  
> however, performing a JAR surgery like this makes me a bit uncomfortable.
> 
> I was under the impression that elasticsearch-0.90.0.rc2.jar is all you  
> need while creating a client for ES. So shouldn't it run standalone without  
> depending on any other libraries in the lib/ directory? Am I missing  
> something? Here is the error I see in Eclipse:
> 
> XContentBuilder o = XContentFactory.jsonBuilder().startObject();  
> o.field("line", "this is a test line"); // Error: "Type  
> org.apache.lucene.util.ByteRef cannot be resolved. It is indirectly  
> referenced from required .class files"

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [July 6, 2017, 2:39am UTC](https://discuss.elastic.co/t/0-90-0-rc2-java-api-compilation-error-org-apache-lucene-util-byteref-cannot-be-resolved/11663/5 "2017-07-06T02:39:06Z")

</div>


