-1

I am using Elasticsearch Jest client to write my own client-app.

i keep getting this
java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils

even though i've included all JARs in the build pass.

actions taken:

  1. Disabled maven and manually added all JARS
  2. Added apache-common-lang-2.6 on top of 3.3.2
  3. clean/restart eclipse

got NOTHING :(

screenshot with error:
screenshot with error

error message:

Exception in thread "main" java.lang.NoClassDefFoundError:       
    org/apache/commons/lang3/StringUtils

    at io.searchbox.action.AbstractAction.buildURI(AbstractAction.java:171)
    at    io.searchbox.action.AbstractDocumentTargetedAction.buildURI(AbstractDocumentTarg     etedAction.java:40)
    at io.searchbox.core.Index.<init>(Index.java:23)
    at io.searchbox.core.Index.<init>(Index.java:15)
    at io.searchbox.core.Index$Builder.build(Index.java:63)
at   
   
Kinnetics.KinneticsElasticsearchClient.indexParameter(KinneticsElasticsearchClient.java:54)
at Kinnetics.ManagementWrapper.main(PredictoModule.java:74)
at Kinnetics.PredictoModule.main(PredictoModule.java:28)
Caused by: java.lang.ClassNotFoundException:     org.apache.commons.lang3.StringUtils
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 8 more

verbose:class output:
             Line 6: C:\Users\Eitan\workspace\SelfAnomalyDetector - ver7\JARs For   Jest\commons-lang-2.6.jar;
            Line 7: C:\Users\Eitan\workspace\SelfAnomalyDetector - ver7\JARs For Jest\commons-lang-2.6-javadoc.jar;
            Line 8: C:\Users\Eitan\workspace\SelfAnomalyDetector - ver7\JARs For Jest\commons-lang-2.6-sources.jar;
            Line 9: C:\Users\Eitan\workspace\SelfAnomalyDetector - ver7\JARs For Jest\commons-lang3-3.3.2.jar;
            Line 10: :\Users\Eitan\workspace\SelfAnomalyDetector - ver7\JARs For Jest\commons-lang3-3.3.2-javadoc.jar;
            Line 11: C:\Users\Eitan\workspace\SelfAnomalyDetector - ver7\JARs For Jest\commons-lang3-3.3.2-sources.jar;
             Line 64: C:\Users\Eitan\.m2\repository\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar
8
  • Please provide your error inline as code (4 indents) as a start. Easily to copy/paste, and quickly glanced. Lets also not reverse-engineer all libraries you do need, and lets start from a healthy (best effort) pom. Which dependency are you using to include "Elasticsearch"? Provide another code fragment inline with the dependency. Commented May 16, 2015 at 18:55
  • 1
    Please add -verbose:class to the execution and post results. It will tell you exactly what jars are being loaded and from where Commented May 16, 2015 at 19:28
  • thanks @ChristianBongiorno and JoD. not sure about how to use --verbose yet i did run System.out.println(System.getProperty("java.class.path")) to list all classes loaded. i can see that appache-common-lang is written twice (same version)... Commented May 16, 2015 at 21:20
  • In addition, i was under the impression that the problem is somewhere in the Maven-Eclipse so i manually loaded all relevant JARs into the build path and disabled Maven Commented May 16, 2015 at 21:27
  • Found those two entries in verbose:Line 9: C:\Users\Eitan\workspace\SelfAnomalyDetector - ver7\JARs For Jest\commons-lang3-3.3.2.jar; Line 64: C:\Users\Eitan\.m2\repository\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar Commented May 17, 2015 at 5:43

1 Answer 1

0

Just browsing, and not even having a clue what you are trying to do, my first guess would be that those two main dependencies should be enough:

<dependency>
  <groupId>io.searchbox</groupId>
  <artifactId>jest</artifactId>
  <version>0.1.1</version>
</dependency>
<dependency>
  <groupId>org.elasticsearch</groupId>
  <artifactId>elasticsearch</artifactId>
  <version>1.0.1</version>
</dependency>

Also my guess is that you have a mixup of two versions of appache-common-lang3. One might be repackaged as part of another.

However, I went through all your dependencies (that I could see in your snapshot), and could not find a repackaging of apache-common-lang3:

  • jest
  • jest-common - it does have the nested dependency to automatically pull in apache-common-lang3
  • gson
  • elasticsearch

I also went through all the nested dependencies of those just mentioned. No trace of repackaging. So not sure now.

I hope you also do not have your class path customized, or dropped in somewhere a version of the library manually somewhere in a lib/ext of your java installation.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, I detached this project from Maven so there is now POM with dependencies. i manually placed all JARS in a the project. in addition, i did not customize class path manualy, yet when i use : System.out.println( System.getProperty("java.class.path")) i see that appache-common-lang 3 is loaded twice, from 2 different locations. (same version) does that matter?
*no POM (instead of now POM...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.