# NoClassDefFoundError exception with SearchSourceBuilder (6.0) in GWT server side

**URL:** <https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281>\
**Category:** Elasticsearch\
**Created:** [November 19, 2017, 12:37pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281 "2017-11-19T12:37:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wassx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassx/32/24440_2.png) [@wassx](https://discuss.elastic.co/u/wassx)\
**Post date:** [November 19, 2017, 12:37pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/1 "2017-11-19T12:37:09Z")

</div>

Hi!

I try to query my local elastic search instance via high level rest client with:  
SearchRequest searchRequest = new SearchRequest("jobs");  
searchRequest.types("job");  
SearchSourceBuilder ssb = new SearchSourceBuilder();  
ssb.query(QueryBuilders.matchAllQuery());  
searchRequest.source(ssb);

But searchRequest throws a NoSuchFieldError due to another exception in SearchSourceBuilder (NoClassDefFoundError).  
I tried elastic version 6.0 and 5.6.4.

The code sample above is called on the server side of my gwt application.  
I cleared my maven repo, reimport,... but no success.  
Any ideas please?

---

<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:** [November 19, 2017, 12:59pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/2 "2017-11-19T12:59:17Z")

</div>

What is the full error / stacktrace?

---

<div class="post-metadata">

**Author:** ![wassx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassx/32/24440_2.png) [@wassx](https://discuss.elastic.co/u/wassx)\
**Post date:** [November 19, 2017, 5:47pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/3 "2017-11-19T17:47:10Z")

</div>

**_Method threw 'java.lang.NoClassDefFoundError' exception. Cannot evaluate org.elasticsearch.search.builder.SearchSourceBuilder.toString()_**  
This is thrown when the default constructor in SearchSourceBuilder is called in the constructor for SearchRequest(String... indices) (SearchRequest:60)

There is no clear stacktrace, it's only visible that the field source in SearchRequest contains the message above (bold).  
When I execute the request gwt catches an InvocatoinTargetException with the cause:  
java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.common.xcontent.json.JsonXContent  
I guess this is just the resulting error from the corrupt request.

---

<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:** [November 19, 2017, 6:02pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/4 "2017-11-19T18:02:48Z")

</div>

How did you import the High Level Rest Client in your project?

---

<div class="post-metadata">

**Author:** ![wassx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassx/32/24440_2.png) [@wassx](https://discuss.elastic.co/u/wassx)\
**Post date:** [November 19, 2017, 9:40pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/5 "2017-11-19T21:40:15Z")

</div>

via maven:  
  
org.elasticsearch.client  
elasticsearch-rest-high-level-client  
6.0.0

That's the only elasticsearch dependency in my pom.  
I'll try an isolated version because I think it is maybe a clash with another dependency in the pom:

```
	</dependency>
	<dependency>
		<groupId>com.google.gwt</groupId>
		<artifactId>gwt-elemental</artifactId>
		<version>${gwt.version}</version>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>com.google.gwt</groupId>
		<artifactId>gwt-dev</artifactId>
		<version>${gwt.version}</version>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>com.google.gwt</groupId>
		<artifactId>gwt-codeserver</artifactId>
		<version>${gwt.version}</version>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>com.gwtplatform</groupId>
		<artifactId>gwtp-mvp-client</artifactId>
		<version>${gwtp.version}</version>
	</dependency>
	<dependency>
		<groupId>com.gwtplatform</groupId>
		<artifactId>gwtp-dispatch-rpc-client</artifactId>
		<version>${gwtp.version}</version>
	</dependency>
	<dependency>
		<groupId>com.gwtplatform</groupId>
		<artifactId>gwtp-dispatch-rpc-server-guice</artifactId>
		<version>${gwtp.version}</version>
	</dependency>
	<dependency>
		<groupId>com.gwtplatform</groupId>
		<artifactId>gwtp-dispatch-rpc-shared</artifactId>
		<version>${gwtp.version}</version>
	</dependency>

	<dependency>
		<groupId>com.google.inject</groupId>
		<artifactId>guice</artifactId>
		<version>${guice.version}</version>
	</dependency>
	<dependency>
		<groupId>com.google.inject.extensions</groupId>
		<artifactId>guice-servlet</artifactId>
		<version>${guice.version}</version>
	</dependency>
	<dependency>
		<groupId>com.google.inject.extensions</groupId>
		<artifactId>guice-assistedinject</artifactId>
		<version>${guice.version}</version>
	</dependency>
	<dependency>
		<groupId>com.google.gwt.inject</groupId>
		<artifactId>gin</artifactId>
		<version>${gin.version}</version>
	</dependency>
	<dependency>
	    <groupId>com.google.maps</groupId>
	    <artifactId>google-maps-services</artifactId>
	    <version>0.1.6</version>
	</dependency>

	<dependency>
	    <groupId>org.ektorp</groupId>
	    <artifactId>org.ektorp</artifactId>
	    <version>1.4.4</version>
	</dependency>
	<dependency>
		<groupId>com.github.ldriscoll</groupId>
		<artifactId>ektorplucene</artifactId>
		<version>0.2.0</version>
	</dependency>

	<dependency>
		<groupId>org.mindrot</groupId>
		<artifactId>jbcrypt</artifactId>
		<version>0.3m</version>
	</dependency>
	<dependency>
		<groupId>javax.validation</groupId>
		<artifactId>validation-api</artifactId>
		<version>1.0.0.GA</version>
	</dependency>
	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate-validator</artifactId>
		<version>4.1.0.Final</version>
	</dependency>

	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-api</artifactId>
		<version>1.7.21</version>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>slf4j-log4j12</artifactId>
		<version>1.7.21</version>
	</dependency>
	<dependency>
		<groupId>org.apache.logging.log4j</groupId>
		<artifactId>log4j-core</artifactId>
		<version>2.7</version>
	</dependency>

	<dependency>
		<groupId>commons-fileupload</groupId>
		<artifactId>commons-fileupload</artifactId>
		<version>1.3.1</version>
	</dependency>
	<dependency>
		<groupId>org.vectomatic</groupId>
		<artifactId>lib-gwt-svg</artifactId>
		<version>0.5.10</version>
	</dependency>
	
	<dependency>
	    <groupId>com.arcbees.analytics</groupId>
	    <artifactId>universal-analytics</artifactId>
	    <version>2.1</version>
	</dependency>

	<dependency>
		<groupId>org.gwtopenmaps.openlayers</groupId>
		<artifactId>gwt-openlayers-client</artifactId>
		<version>1.1-SNAPSHOT</version>
	</dependency>

	<dependency>
		<groupId>org.xhtmlrenderer</groupId>
		<artifactId>flying-saucer-pdf</artifactId>
		<version>9.0.7</version>
	</dependency>

	<!-- Test -->
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>${junit.version}</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.jukito</groupId>
		<artifactId>jukito</artifactId>
		<version>${jukito.version}</version>
		<scope>test</scope>
	</dependency>

	<dependency>
		<groupId>org.moxieapps</groupId>
		<artifactId>moxieapps</artifactId>
		<version>1.1.0</version>
		<scope>system</scope>
		<systemPath>${project.basedir}/lib/org.moxieapps.gwt.uploader-1.1.0.jar</systemPath>
	</dependency>

	<!--Material Design GWT-->

	<dependency>
		<groupId>com.github.gwtmaterialdesign</groupId>
		<artifactId>gwt-material</artifactId>
		<version>2.0-rc7</version>
		<scope>provided</scope>
	</dependency>

	<dependency>
		<groupId>com.github.gwtmaterialdesign</groupId>
		<artifactId>gwt-material-addins</artifactId>
		<version>2.0-rc7</version>
		<scope>provided</scope>
	</dependency>

	<dependency>
		<groupId>com.github.gwtmaterialdesign</groupId>
		<artifactId>gwt-material-themes</artifactId>
		<version>2.0-rc7</version>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>com.github.gwtmaterialdesign</groupId>
		<artifactId>gwt-material-jquery</artifactId>
		<version>2.0-rc7</version>
		<scope>provided</scope>
	</dependency>
	<dependency>
		<groupId>com.github.gwtmaterialdesign</groupId>
		<artifactId>gwt-material-table</artifactId>
		<version>2.0-rc7</version>
		<scope>provided</scope>
	</dependency>

	<!--Guava-->

	<dependency>
		<groupId>com.google.guava</groupId>
		<artifactId>guava</artifactId>
		<version>23.0</version>
	</dependency>

	<dependency>
		<groupId>com.google.guava</groupId>
		<artifactId>guava-gwt</artifactId>
		<version>23.0</version>
	</dependency>

	<dependency>
		<groupId>org.mockito</groupId>
		<artifactId>mockito-core</artifactId>
		<version>2.1.0-RC.2</version>
	</dependency>

	<dependency>
		<groupId>org.jsoup</groupId>
		<artifactId>jsoup</artifactId>
		<version>1.10.2</version>
	</dependency>

	<dependency>
		<groupId>org.apache.httpcomponents</groupId>
		<artifactId>httpclient</artifactId>
		<version>4.5.3</version>
	</dependency>
	<dependency>
		<groupId>commons-io</groupId>
		<artifactId>commons-io</artifactId>
		<version>2.5</version>
	</dependency>

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

---

<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:** [November 19, 2017, 9:55pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/6 "2017-11-19T21:55:55Z")

</div>

Could you try with only elasticsearch dependency so it will tell us if this is caused by a conflict or something else?

---

<div class="post-metadata">

**Author:** ![wassx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wassx/32/24440_2.png) [@wassx](https://discuss.elastic.co/u/wassx)\
**Post date:** [November 22, 2017, 8:19pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/7 "2017-11-22T20:19:39Z")

</div>

Ok, I got it up and running. I had a dependency on ektorp for my couchdb, because I wanted to port all couchdb entries into elastic. After removing all ektorp couchdb and lucene dependencies it worked perfectly. Thanks!

---

<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:** [December 20, 2017, 8:19pm UTC](https://discuss.elastic.co/t/noclassdeffounderror-exception-with-searchsourcebuilder-6-0-in-gwt-server-side/108281/8 "2017-12-20T20:19:52Z")

</div>

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