wirewolf wirewolf - 2 months ago 16
Apache Configuration Question

java.lang.Exception: java.lang.NoClassDefFoundError: org/apache/lucene/util/OpenBitSet

In netbeans with maven i have added third party dependency of org.apache.lucene lucene-core 4.2.0 because newer core versions do not contain OpenBitSet class.
Here is the pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.hadoop</groupId>
<artifactId>DuccProject</artifactId>
<version>2.7.3</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.0.0-cdh4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-auth</artifactId>
<version>2.0.0-cdh4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.0.0-cdh4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>2.0.0-mr1-cdh4.0.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>it.unimi.dsi</groupId>
<artifactId>fastutil</artifactId>
<version>7.0.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>




I can use all of the classes contained in package via netbeans.
I have built the jar with "mvn clean install" inside the directory which contains .pom file.
But when I run the jar from cli:

bin/hadoop jar ~/NetBeansProjects/DuccProject/DuccProject/target/DuccProject-2.7.3.jar org.apache.hadoop.duccproject.Ducc /hdfs/path/to/input /hdfs/path/to/output


where org.apache.hadoop.duccproject.Ducc is the path to my main class,
I am facing the following error:

java.lang.Exception: java.lang.NoClassDefFoundError: org/apache/lucene/util/OpenBitSet
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:529)
Caused by: java.lang.NoClassDefFoundError: org/apache/lucene/util/OpenBitSet
at org.apache.hadoop.columns.ColumnCombinationBitset.<init>(ColumnCombinationBitset.java:33)
at org.apache.hadoop.duccproject.ParserReducer.reduce(ParserReducer.java:53)
at org.apache.hadoop.duccproject.ParserReducer.reduce(ParserReducer.java:24)
at org.apache.hadoop.mapreduce.Reducer.run(Reducer.java:171)
at org.apache.hadoop.mapred.ReduceTask.runNewReducer(ReduceTask.java:627)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:389)
at org.apache.hadoop.mapred.LocalJobRunner$Job$ReduceTaskRunnable.run(LocalJobRunner.java:319)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.util.OpenBitSet
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 12 more
16/09/04 17:41:53 INFO mapreduce.Job: map 100% reduce 0%

Answer

Error indicate that application was unable to find the required class , During run-time, you also need to provide the path of the lucene-core 4.2.0 jar using hadoop command options as follows

-libjars <comma seperated list of jars>

You can also see other hadoop command options

Comments