# java.lang.NoClassDefFoundError: org/elasticsearch/index/query/QueryBuilder

**URL:** <https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311>\
**Category:** Elasticsearch\
**Created:** [July 19, 2019, 5:17am UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311 "2019-07-19T05:17:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kalyanikolimali93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kalyanikolimali93/32/50619_2.png) [@kalyanikolimali93](https://discuss.elastic.co/u/kalyanikolimali93)\
**Post date:** [July 19, 2019, 5:17am UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/1 "2019-07-19T05:17:35Z")

</div>

Hi Sir,

I am Kalyani Naidu, Working as an IT Professional in India.

I am facing a problem

java.lang.ClassNotFoundException: org.elasticsearch.index.query.QueryBuilder

--- It is happening when an trying to build a custom grant jar for mobile grant access in wso2.

I have received no problem in building the maven jar and also worked on sample it is also working fine.

But, When I am trying to restart wso2 its throwing the error message as below..

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)  
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)  
at java.lang.Thread.run(Thread.java:748)  
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/index/query/QueryBuilder  
at java.lang.Class.forName0(Native Method)  
at java.lang.Class.forName(Class.java:264)  
at org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration.getSupportedGrantTypes(OAuthServerConfiguration.java:614)  
at org.wso2.carbon.identity.oauth.OAuthAdminService.getAllowedGrantTypes(OAuthAdminService.java:1091)  
... 154 more  
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.index.query.QueryBuilder cannot be found by custom\_grant\_1.1.2\_1.0.0  
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)  
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)  
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)  
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)  
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)  
... 158 more  
[2019-07-18 21:15:39,856] ERROR - ApplicationDispatcher Servlet.service() for servlet bridgeservlet threw exception  
java.lang.NullPointerException  
at org.apache.jsp.oauth.edit\_jsp.\_jspService(edit\_jsp.java:1076)  
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

-- Elastic Java Client jar throwing this error when I load from wso2

the jar is placed is wso2/2.6.0/repository/components/lib - to support custom grant mobile support over cross cluster search!

- I have a sample with elasticsearch java client its working absolutely fine. But its throwing error only when I tried using the maven generated jar in the wso2 libraries

please help.  
am using elastic search 6.5.4  
java 1.8  
wso2 2.6.0

---

<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:** [July 19, 2019, 10:07am UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/2 "2019-07-19T10:07:48Z")

</div>

Welcome!

Could you please:

- [read this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) about how to format properly your code and why it's important
- provide a `pom.xml` file which can help to reproduce your problem

---

<div class="post-metadata">

**Author:** ![kalyanikolimali93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kalyanikolimali93/32/50619_2.png) [@kalyanikolimali93](https://discuss.elastic.co/u/kalyanikolimali93)\
**Post date:** [July 21, 2019, 2:35pm UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/3 "2019-07-21T14:35:01Z")

</div>

Sure Sir,

my pom.xml

```
<groupId>org.wso2.is</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>custom-grant</artifactId>
<version>1.1.2</version>
<packaging>jar</packaging>
<name>OAuth 2.0 Custom Grant</name>
<url>http://maven.apache.org</url>

 <properties>
    <elasticsearch.version>7.2.0</elasticsearch.version>
    <log4j.version>2.11.2</log4j.version>
    <junit.version>5.4.2</junit.version>
    <java.compiler.version>1.8</java.compiler.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.oltu.oauth2</groupId>
        <artifactId>org.apache.oltu.oauth2.client</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.wso2.carbon.identity</groupId>
        <artifactId>org.wso2.carbon.identity.oauth</artifactId>
        <version>5.0.7</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>org.wso2.carbon.user.core</artifactId>
        <version>4.4.3</version>
    </dependency>
    <dependency>
		<groupId>org.apache.httpcomponents</groupId>
		<artifactId>httpclient</artifactId>
		<version>4.1.1</version>
	</dependency>
	<dependency>
	    <groupId>org.json</groupId>
	    <artifactId>json</artifactId>
	    <version>20180130</version>
	</dependency>
    <dependency>
         <groupId>org.elasticsearch.client</groupId>
         <artifactId>elasticsearch-rest-high-level-client</artifactId>
         <version>6.5.4</version>
    </dependency> 
     <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.4.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.4.2</version>
    </dependency>

</dependencies>

<repositories>
    <repository>
        <id>wso2-nexus</id>
        <name>WSO2 internal Repository</name>
        <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
            <checksumPolicy>ignore</checksumPolicy>
        </releases>
    </repository>
</repositories>

<build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
                <optimize>true</optimize>
                <showDeprecation>true</showDeprecation>
                <showWarnings>true</showWarnings>
                <compilerArgument>-Xlint:all,-serial,-path,-rawtypes,-unchecked</compilerArgument>
            </configuration>
        </plugin>
    </plugins>
</build>

```

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [July 21, 2019, 5:58pm UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/4 "2019-07-21T17:58:25Z")

</div>

> Elastic Java Client jar throwing this error when I load from wso2

Do you have all the dependencies of the client jar? The missing class is in the server jar, which is currently a dependency.

---

<div class="post-metadata">

**Author:** ![kalyanikolimali93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kalyanikolimali93/32/50619_2.png) [@kalyanikolimali93](https://discuss.elastic.co/u/kalyanikolimali93)\
**Post date:** [July 22, 2019, 5:04am UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/5 "2019-07-22T05:04:52Z")

</div>

Yes I do.. It is working fine when I have tested on eclipse ie...,, elastic search java client sample.. But when I placed this jar in wso2 components lib.. its throwing error while restarting.,..

am really clueless on this..

---

<div class="post-metadata">

**Author:** ![kalyanikolimali93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kalyanikolimali93/32/50619_2.png) [@kalyanikolimali93](https://discuss.elastic.co/u/kalyanikolimali93)\
**Post date:** [July 22, 2019, 5:09am UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/6 "2019-07-22T05:09:16Z")

</div>

@rjernst: Can you be more specific ?

The elastic search java client sample is working fine with same dependencies. But, its not working when I placed it in the wso2 components/lib ... its throwing error like that in starting the server?

---

<div class="post-metadata">

**Author:** ![kalyanikolimali93](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kalyanikolimali93/32/50619_2.png) [@kalyanikolimali93](https://discuss.elastic.co/u/kalyanikolimali93)\
**Post date:** [July 22, 2019, 5:10am UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/7 "2019-07-22T05:10:33Z")

</div>

@dadoonet:

Please find my pom.xml Sir..

```
<groupId>org.wso2.is</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>custom-grant</artifactId>
<version>1.1.2</version>
<packaging>jar</packaging>
<name>OAuth 2.0 Custom Grant</name>
<url>http://maven.apache.org</url>

 <properties>
    <elasticsearch.version>7.2.0</elasticsearch.version>
    <log4j.version>2.11.2</log4j.version>
    <junit.version>5.4.2</junit.version>
    <java.compiler.version>1.8</java.compiler.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.oltu.oauth2</groupId>
        <artifactId>org.apache.oltu.oauth2.client</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.wso2.carbon.identity</groupId>
        <artifactId>org.wso2.carbon.identity.oauth</artifactId>
        <version>5.0.7</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.wso2.carbon</groupId>
        <artifactId>org.wso2.carbon.user.core</artifactId>
        <version>4.4.3</version>
    </dependency>
    <dependency>
		<groupId>org.apache.httpcomponents</groupId>
		<artifactId>httpclient</artifactId>
		<version>4.1.1</version>
	</dependency>
	<dependency>
	    <groupId>org.json</groupId>
	    <artifactId>json</artifactId>
	    <version>20180130</version>
	</dependency>
    <dependency>
         <groupId>org.elasticsearch.client</groupId>
         <artifactId>elasticsearch-rest-high-level-client</artifactId>
         <version>6.5.4</version>
    </dependency> 
     <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.4.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.4.2</version>
    </dependency>

</dependencies>

<repositories>
    <repository>
        <id>wso2-nexus</id>
        <name>WSO2 internal Repository</name>
        <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
            <checksumPolicy>ignore</checksumPolicy>
        </releases>
    </repository>
</repositories>

<build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
                <optimize>true</optimize>
                <showDeprecation>true</showDeprecation>
                <showWarnings>true</showWarnings>
                <compilerArgument>-Xlint:all,-serial,-path,-rawtypes,-unchecked</compilerArgument>
            </configuration>
        </plugin>
    </plugins>
</build>

```

---

<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:** [August 19, 2019, 5:10am UTC](https://discuss.elastic.co/t/java-lang-noclassdeffounderror-org-elasticsearch-index-query-querybuilder/191311/8 "2019-08-19T05:10:36Z")

</div>

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