Error - XPack Class not found Exception in java


(Azhar) #1

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


(David Pilato) #2

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


(Azhar) #3

yes i do follow the steps as explained in the documentation: 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.


(David Pilato) #4

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?


(Azhar) #5

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


(Alexander Reelsen) #6

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


(Azhar) #7

thank you the solution work for me


(Igor) #8

So what solution is that?
I am following these steps 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)

(Alexander Reelsen) #9

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


(lukasSirhal) #10

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


(Tim Vernum) #11

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.

(lukasSirhal) #12

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

Do you have any public elastic repository?


(David Pilato) #13

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

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.


(lukasSirhal) #14

Ok i created new topic


(system) #15

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