# Error - XPack Class not found Exception in java

**URL:** https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168
**Category:** Elasticsearch
**Created:** [November 7, 2016, 6:27am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168 "2016-11-07T06:27:38Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![wow148](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@wow148](https://discuss.elastic.co/u/wow148)
#### Post date: [November 7, 2016, 6:27am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/1 "2016-11-07T06:27:38Z")

</div>

I got this error please help.

Exception in thread "main" java.lang.NoClassDefFoundError: org/elasticsearch/xpack/XPackPlugin  
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:50)  
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:46)  
at com.ef.elastics.elastic.main(elastic.java:29)  
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.xpack.XPackPlugin  
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)  
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)  
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)  
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)  
... 3 more

---

<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 7, 2016, 6:50am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/2 "2016-11-07T06:50:55Z")

</div>

What are you doing and how?  
Did you follow the guide?  
Any step you missed?

---

<div class="post-metadata">

### Author: ![wow148](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@wow148](https://discuss.elastic.co/u/wow148)
#### Post date: [November 7, 2016, 7:07am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/3 "2016-11-07T07:07:12Z")

</div>

yes i do follow the steps as explained in the documentation: [https://www.elastic.co/guide/en/x-pack/current/api-java.html](https://www.elastic.co/guide/en/x-pack/current/api-java.html)  
when i try to download the maven repo it says artifact missing id, so i download x-pack transport manually and insert it in my java project but now i have this problem says class not found exception. I trying to do indexing using java api client since i install x-pack it needs authentication.

---

<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 7, 2016, 7:48am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/4 "2016-11-07T07:48:09Z")

</div>

You have to fix the maven problem first. You are missing dependencies here.  
Did you add the repository?

If it's not working may be you are using Nexus in your company and it is misconfigured?

---

<div class="post-metadata">

### Author: ![wow148](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@wow148](https://discuss.elastic.co/u/wow148)
#### Post date: [November 7, 2016, 8:11am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/5 "2016-11-07T08:11:40Z")

</div>

I have fixed my repository problem now i have different error:  
Exception in thread "main" java.lang.ExceptionInInitializerError  
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)  
at org.elasticsearch.plugins.PluginsService.loadPlugin(PluginsService.java:451)  
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:116)  
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:81)  
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:106)  
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:228)  
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:69)  
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:50)  
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.(PreBuiltXPackTransportClient.java:46)  
at com.ef.elastics.elastic.main(elastic.java:35)  
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.unboundid.util.Debug  
at org.elasticsearch.xpack.XPackPlugin$1.run(XPackPlugin.java:144)  
at org.elasticsearch.xpack.XPackPlugin$1.run(XPackPlugin.java:138)  
at java.security.AccessController.doPrivileged(Native Method)  
at org.elasticsearch.xpack.XPackPlugin.(XPackPlugin.java:138)  
... 13 more

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [November 7, 2016, 8:16am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/6 "2016-11-07T08:16:58Z")

</div>

Hey,

can you make sure, that you are also downloading and using transitive dependencies of the x-pack client. Running `mvn dependency:tree` will show you those for example. It seems, those are missing.

--Alex

---

<div class="post-metadata">

### Author: ![wow148](https://avatars.discourse-cdn.com/v4/letter/w/898d66/32.png) [@wow148](https://discuss.elastic.co/u/wow148)
#### Post date: [November 7, 2016, 9:15am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/7 "2016-11-07T09:15:31Z")

</div>

thank you the solution work for me

---

<div class="post-metadata">

### Author: ![gig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gig/32/13379_2.png) [@gig](https://discuss.elastic.co/u/gig)
#### Post date: [November 23, 2016, 11:43pm UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/8 "2016-11-23T23:43:57Z")

</div>

So what solution is that?  
I am following these steps [https://www.elastic.co/guide/en/x-pack/current/java-clients.html](https://www.elastic.co/guide/en/x-pack/current/java-clients.html) and I am getting:

```
ava.lang.NoClassDefFoundError: org/elasticsearch/xpack/XPackPlugin
    at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:50)
    at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:46)
```

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [November 24, 2016, 5:58am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/9 "2016-11-24T05:58:16Z")

</div>

Please open new issues instead of appending to old issues, that have been resolved.

This looks as if the dependency you specified could not be downloaded. Did you specify the additional repository as mentioned at the documentation you linked?

How does your `pom.xml`/`gradle.build` file look like?

--Alex

---

<div class="post-metadata">

### Author: ![lukasSirhal1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukassirhal1/32/13873_2.png) [@lukasSirhal1](https://discuss.elastic.co/u/lukasSirhal1)
#### Post date: [December 13, 2016, 11:48am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/10 "2016-12-13T11:48:41Z")

</div>

Hello, I have same issue.

My pom.xml look like:

```
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>5.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
        <version>5.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>x-pack-transport</artifactId>
        <version>5.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.7</version>
    </dependency>

```

And while i create TransportClient

```
    TransportClient transportClient = new PreBuiltXPackTransportClient(
    Settings.builder()
    .put("cluster.name", cluster)
    .put("xpack.security.user", String.format("%s:%s", user, passwd))
    .build());

```

i have this error:

```
java.lang.NoClassDefFoundError: org/elasticsearch/xpack/XPackPlugin
at org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.<init>(PreBuiltXPackTransportClient.java:55)

```

thanks for help

---

<div class="post-metadata">

### Author: ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)
#### Post date: [December 13, 2016, 2:18pm UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/11 "2016-12-13T14:18:06Z")

</div>

`org.elasticsearch.xpack.XPackPlugin` can be found in `x-pack-api-5.1.1.jar`

If you follow the instructions on the Java API page linked above, then you should automatically download the API jar.

If you run `mvn dependency:tree` then you should see output that looks like:

```
[INFO] +- org.elasticsearch.client:x-pack-transport:jar:5.1.1:compile
[INFO] | +- org.elasticsearch.plugin:x-pack-api:jar:5.1.1:compile
[INFO] | | +- org.elasticsearch.plugin:transport-netty3-client:jar:5.1.1:compile
[INFO] | | | \- io.netty:netty:jar:3.10.6.Final:compile
[INFO] | | +- org.elasticsearch.plugin:transport-netty4-client:jar:5.1.1:compile

```

_etc._

If you're not seeing that, then either:

1. You didn't follow the instructions correctly, and you need to try them again - the #1 thing people miss is that you _need_ to add the `elasticsearch-releases` repository to your `pom.xml`.
2. You have an internal repository manager (nexus, artifactory, etc) that hasn't been configured correctly. If that's the case then you need to talk to whoever administers your repository manager, there's not a lot we can do to diagnose the problem.

---

<div class="post-metadata">

### Author: ![lukasSirhal1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukassirhal1/32/13873_2.png) [@lukasSirhal1](https://discuss.elastic.co/u/lukasSirhal1)
#### Post date: [December 14, 2016, 6:44am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/12 "2016-12-14T06:44:49Z")

</div>

It seems that this is it, we have own artifactory but when i try use  
**[https://artifacts.elastic.co/maven](https://artifacts.elastic.co/maven)**  
i have 404 error.

Do you have any public elastic repository?

---

<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: [December 14, 2016, 7:10am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/13 "2016-12-14T07:10:30Z")

</div>

@lukasSirhal1 May be you did not declare correctly the elasticsearch repo in artifactory?

[https://artifacts.elastic.co/maven](https://artifacts.elastic.co/maven) is where artifacts are stored. IIRC there is a specific option which basically tries to list files in the repo which is not supported. So you have to uncheck that option (don't remember the name).

If you are still having troubles, share in a new thread how you configured artifactory.

---

<div class="post-metadata">

### Author: ![lukasSirhal1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukassirhal1/32/13873_2.png) [@lukasSirhal1](https://discuss.elastic.co/u/lukasSirhal1)
#### Post date: [December 14, 2016, 8:35am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/14 "2016-12-14T08:35:26Z")

</div>

Ok i created [new topic](https://discuss.elastic.co/t/how-to-set-up-elastic-maven-reposiroty/68986)

---

<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: [January 11, 2017, 8:35am UTC](https://discuss.elastic.co/t/error-xpack-class-not-found-exception-in-java/65168/15 "2017-01-11T08:35:52Z")

</div>

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