当前位置: 首页 > 知识库问答 >
问题:

异常:java.lang.NoClassDeffounderRror:org/apache/lucene/util/openbitset

齐承运
2023-03-14

在netbeans with maven中,我添加了org.apache.lucene的第三方依赖项lucene-core 4.2.0,因为较新的核心版本不包含OpenBitSet类。以下是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>

null

我可以通过NetBeans使用包中包含的所有类。我已经在包含.pom文件的目录中构建了带有“mvn clean install”的jar。但当我从CLI运行jar时:

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

其中org.apache.hadoop.duccproject.ducc是我的主类的路径,我面临以下错误:

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%

共有1个答案

步胜
2023-03-14

错误指示应用程序无法找到所需类,在运行时,您还需要使用hadoop命令选项提供lucene-core 4.2.0 jar的路径,如下所示

-libjars <comma seperated list of jars>

您还可以看到其他hadoop命令选项

 类似资料: