# How to solve java.lang.NoSuchFieldError: LUCENE\_7\_7\_2

**URL:** <https://discuss.elastic.co/t/how-to-solve-java-lang-nosuchfielderror-lucene-7-7-2/235533>\
**Category:** Elasticsearch\
**Created:** [June 3, 2020, 11:24am UTC](https://discuss.elastic.co/t/how-to-solve-java-lang-nosuchfielderror-lucene-7-7-2/235533 "2020-06-03T11:24:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://discuss.elastic.co/u/apar)\
**Post date:** [June 3, 2020, 11:24am UTC](https://discuss.elastic.co/t/how-to-solve-java-lang-nosuchfielderror-lucene-7-7-2/235533/1 "2020-06-03T11:24:47Z")

</div>

Hi, I'm using the elasticsearch 7.6.2 and I'm trying to create an index and update the mappings in a second step. The index gets successfully created, however the mapping update fails with the following error:

```
nested exception is java.lang.NoSuchFieldError: LUCENE_7_7_2] with root cause
java.lang.NoSuchFieldError: LUCENE_7_7_2
	at org.elasticsearch.Version.<clinit>(Version.java:111)
	at org.elasticsearch.common.io.stream.StreamInput.<init>(StreamInput.java:113)
	at org.elasticsearch.common.bytes.AbstractBytesReference$MarkSupportingStreamInputWrapper.<init>(AbstractBytesReference.java:195)
	at org.elasticsearch.common.bytes.AbstractBytesReference$MarkSupportingStreamInputWrapper.<init>(AbstractBytesReference.java:189)

```

My code looks like that:

```
 private void createIndex(String indexname) {
  String indexname = "myIndex";
    try {
	  RestClientBuilder builder = RestClient.builder(new HttpHost(hostname, port, scheme));
      RestHighLevelClient client = new RestHighLevelClient(builder);
	  
      CreateIndexRequest indexRequest = new CreateIndexRequest(indexname);
      CreateIndexResponse createIndexResponse = client.indices()
          .create(indexRequest, RequestOptions.DEFAULT);
		  
      if (createIndexResponse.isAcknowledged()) {
		// Index gets created, proceed to update the mappings
        updateIndexMapping(client, indexname);
      }
    } catch (Exception e) {
      log.error("Unable to create the elasticsearch index : [" + e.getMessage() + "]");
    }
  }
  
  
  private void updateIndexMapping(RestHighLevelClient client, String indexname) {
    try {
      PutMappingRequest request = new PutMappingRequest(indexname);
      XContentBuilder builder = XContentFactory.jsonBuilder();
      builder.startObject();
      {
        builder.startObject("properties");
        {
          builder.startObject("date");
          {
            builder.field("type", "date");
          }
          {
            builder.field("format", "dd.MM.yyyy");
          }
          builder.endObject();
          builder.startObject("location");
          {
            builder.field("type", "geo_point");
          }
          builder.endObject();
        }
        builder.endObject();
      }
      builder.endObject();
      request.source(builder);

      if (!client.indices().putMapping(request, RequestOptions.DEFAULT).isAcknowledged()) {
		log.error(String.format("Unable to update the mappings for index %s.", indexname));		
      } else {
        log.info(String.format("Mappings for index %s successfully updated ", indexname));
        // Mappings updated, procced with saving a doc ..
      }
    } catch (Exception e) {
      log.error("Unable to update the index mappings : [" + e.getMessage() + "]");
    }
  }

```

My pom includes the elasticsearch version as a property  
`<elasticsearch.version>7.6.2</elasticsearch.version>`

and I have both elasticsearch and elasticsearch.client as dependencies :

```
<dependency>
  <groupId>org.elasticsearch</groupId>
  <artifactId>elasticsearch</artifactId>
  <version>${elasticsearch.version}</version>
</dependency>
<dependency>
  <groupId>org.elasticsearch.client</groupId>
  <artifactId>elasticsearch-rest-high-level-client</artifactId>
  <version>${elasticsearch.version}</version>
</dependency>

```

Lucene is also present for other project purposes:  
`<lucene.version>8.1.1</lucene.version>`

```
    <dependency>
      <groupId>org.apache.lucene</groupId>
      <artifactId>lucene-core</artifactId>
      <version>${lucene.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.lucene</groupId>
      <artifactId>lucene-analyzers-common</artifactId>
      <version>${lucene.version}</version>
    </dependency>

```

mvn dependency:tree -Dverbose -Dincludes=org.apache.lucene Gives the following :

```
[INFO] +- org.apache.lucene:lucene-core:jar:8.1.1:compile
[INFO] +- org.apache.lucene:lucene-analyzers-common:jar:8.1.1:compile
[INFO] | \- (org.apache.lucene:lucene-core:jar:8.1.1:compile - omitted for duplicate)
[INFO] \- org.elasticsearch:elasticsearch:jar:7.6.2:compile
[INFO] +- (org.apache.lucene:lucene-core:jar:8.4.0:compile - omitted for conflict with 8.1.1)
[INFO] +- (org.apache.lucene:lucene-analyzers-common:jar:8.4.0:compile - omitted for conflict with 8.1.1)
[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

```

Our spring-boot-version is 2.3.0 if that helps. Any ideas on how to solve this problem? Thanks in advance

---

<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:** [June 3, 2020, 12:30pm UTC](https://discuss.elastic.co/t/how-to-solve-java-lang-nosuchfielderror-lucene-7-7-2/235533/2 "2020-06-03T12:30:59Z")

</div>

When using springboot with elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your `pom.xml`:

```auto
<properties>
  <elasticsearch.version>7.7.0<elasticsearch.version>
</properties>

```

See documentation here: [https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions)

---

<div class="post-metadata">

**Author:** ![apar](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@apar](https://discuss.elastic.co/u/apar)\
**Post date:** [June 4, 2020, 1:38pm UTC](https://discuss.elastic.co/t/how-to-solve-java-lang-nosuchfielderror-lucene-7-7-2/235533/3 "2020-06-04T13:38:24Z")

</div>

Thanks for responding.  
My problem was solved after upgrading to Lucene 8.5.2 .  
I'm declaring the rest-high-level-client dependecy which uses the spring-boot elastic dependency. (Spring-boot 2.3.0 declares the elasticsearch 7.6.2 dependency )

```
<dependency>
  <groupId>org.elasticsearch.client</groupId>
  <artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>
```

---

<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 2, 2020, 1:38pm UTC](https://discuss.elastic.co/t/how-to-solve-java-lang-nosuchfielderror-lucene-7-7-2/235533/4 "2020-07-02T13:38:39Z")

</div>

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