While running my compiled jar files on hadoop cluster I faced this error many times:
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
Usually, I don't use maven and attach libraries manually to the project.
The libraries that I use are mostly apache's libraries related to hadoop, hive, hbase and etc..
After successful compilation I export the project as a Jar file.
I tried to export in many ways but I faced this ClassNotFoundException every time.
So I realized that exporting my project with attached jar libraries is not the optimal solution for the problem.
Then I found this solution on StackOverflow
http://stackoverflow.com/questions/2096283/including-jars-in-classpath-on-commandline-javac-or-apt
It describes the way how to add required (dependency) jar files while running the main jar.
It is simple! You just put all jars into the same folder where your main jar file is and Run:
>java -cp *:. com.kh.demo.RealtimeTFIDF
Note that you have to write down the full package name of your main class.
Asterix * tells java to load jar files from current directory.
Now you don't need to check Libs path while exporting your project as a jar file, i.e You don't need to include dependency jar files inside the main jar file.
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration
Usually, I don't use maven and attach libraries manually to the project.
The libraries that I use are mostly apache's libraries related to hadoop, hive, hbase and etc..
After successful compilation I export the project as a Jar file.
I tried to export in many ways but I faced this ClassNotFoundException every time.
So I realized that exporting my project with attached jar libraries is not the optimal solution for the problem.
Then I found this solution on StackOverflow
http://stackoverflow.com/questions/2096283/including-jars-in-classpath-on-commandline-javac-or-apt
It describes the way how to add required (dependency) jar files while running the main jar.
It is simple! You just put all jars into the same folder where your main jar file is and Run:
>java -cp *:. com.kh.demo.RealtimeTFIDF
Note that you have to write down the full package name of your main class.
Asterix * tells java to load jar files from current directory.
Now you don't need to check Libs path while exporting your project as a jar file, i.e You don't need to include dependency jar files inside the main jar file.
Comments
Post a Comment