-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
Eitan Vesely
  • 125
  • 3
  • 16
  • 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. – YoYo May 16 '15 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 – Christian Bongiorno May 16 '15 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)... – Eitan Vesely May 16 '15 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 – Eitan Vesely May 16 '15 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 – Eitan Vesely May 17 '15 at 05:43
  • Is it `Eitan.m2` or `Eitan\.m2`? Please correct either place. – YoYo May 19 '15 at 02:36
  • Remove the entire `repository` sub-directory. In your `.m2` folder. Try again. – YoYo May 19 '15 at 02:45
  • Eitan\.m2 <-- this is the corect path. Removing entire .m2\repository doesnt do the trick,,, :-( any other ideas? – Eitan Vesely May 20 '15 at 10:03

1 Answers1

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.

YoYo
  • 9,157
  • 8
  • 57
  • 74
  • 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? – Eitan Vesely May 16 '15 at 21:17
  • *no POM (instead of now POM...) – Eitan Vesely May 16 '15 at 21:24