java.lang.ClassNotFoundException:org.apache.commons.jexl2.JexlContext在运行Apache Nuch时

时间:2019-02-14 06:16:23

标签: java apache nutch

我正在尝试通过java运行apache nutch,并且包括了

所需的所有jar。

运行apatche nutch 1.15版本,它给我以下错误

java.lang.ClassNotFoundException: org.apache.commons.jexl2.JexlContext
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configuration.java:2288)
    at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2253)
    at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2347)
    at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2373)
    at org.apache.hadoop.mapred.JobConf.getOutputValueClass(JobConf.java:1096)
    at org.apache.hadoop.mapred.JobConf.getMapOutputValueClass(JobConf.java:847)
    at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.init(MapTask.java:1013)
    at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:402)
    at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:81)
    at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:704)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:776)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1924)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

我正在使用的pom是

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“>     4.0.0

<groupId>com.nutch</groupId>
<artifactId>ApacheNutch</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>org.apache.nutch</groupId>
        <artifactId>nutch</artifactId>
        <version>1.15</version>
    </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20160810</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.25</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.7</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>4.1</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.5</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.11</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-compress</artifactId>
        <version>1.16.1</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-jexl</artifactId>
        <version>2.1.1</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.tdunning</groupId>
        <artifactId>t-digest</artifactId>
        <version>3.2</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.7.4</version>
        <optional>true</optional>
        <exclusions>
            <exclusion>
                <groupId>hsqldb</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>net.sf.kosmosfs</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>net.java.dev.jets3t</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.eclipse.jdt</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>ant</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-hdfs</artifactId>
        <version>2.7.4</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce-client-core</artifactId>
        <version>2.7.4</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-mapreduce-client-jobclient</artifactId>
        <version>2.7.4</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.tika</groupId>
        <artifactId>tika-core</artifactId>
        <version>1.18</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.icu</groupId>
        <artifactId>icu4j</artifactId>
        <version>61.1</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xercesImpl</artifactId>
        <version>2.11.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>xerces</groupId>
        <artifactId>xmlParserAPIs</artifactId>
        <version>2.6.2</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>oro</groupId>
        <artifactId>oro</artifactId>
        <version>2.0.8</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>25.0-jre</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.github.crawler-commons</groupId>
        <artifactId>crawler-commons</artifactId>
        <version>0.10</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.martinkl.warc</groupId>
        <artifactId>warc-hadoop</artifactId>
        <version>0.1.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.1.15</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        <version>3.1.15</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>3.1.15</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http-jetty</artifactId>
        <version>3.1.15</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-rs-client</artifactId>
        <version>3.1.15</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.9.5</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-cbor</artifactId>
        <version>2.9.5</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.jaxrs</groupId>
        <artifactId>jackson-jaxrs-json-provider</artifactId>
        <version>2.9.5</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.netpreserve.commons</groupId>
        <artifactId>webarchive-commons</artifactId>
        <version>1.1.5</version>
        <optional>true</optional>
        <exclusions>
            <exclusion>
                <groupId>*</groupId>
                <artifactId>hadoop-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.json</groupId>
                <artifactId>*</artifactId>
            </exclusion>
            <exclusion>
                <groupId>it.unimi.dsi</groupId>
                <artifactId>dsiutils</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.gnu.inet</groupId>
                <artifactId>libidn</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.mrunit</groupId>
        <artifactId>mrunit</artifactId>
        <version>1.1.0</version>
        <classifier>hadoop2</classifier>
        <optional>true</optional>
        <exclusions>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-client</artifactId>
        <version>6.1.26</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <version>6.1.26</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-util</artifactId>
        <version>6.1.26</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>tomcat</groupId>
        <artifactId>jasper-runtime</artifactId>
        <version>5.5.23</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>tomcat</groupId>
        <artifactId>jasper-compiler</artifactId>
        <version>5.5.23</version>
        <optional>true</optional>
        <exclusions>
            <exclusion>
                <groupId>ant</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <version>6.1.26</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>4.1</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.0.9.RELEASE</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.0.9.RELEASE</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.0.9.RELEASE</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-client</artifactId>
        <version>1.19.4</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.j256.ormlite</groupId>
        <artifactId>ormlite-jdbc</artifactId>
        <version>5.1</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.4.197</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.2.0</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.wicket</groupId>
        <artifactId>wicket-core</artifactId>
        <version>6.17.0</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.wicket</groupId>
        <artifactId>wicket-spring</artifactId>
        <version>6.17.0</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>de.agilecoders.wicket</groupId>
        <artifactId>wicket-bootstrap-core</artifactId>
        <version>0.9.2</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>de.agilecoders.wicket</groupId>
        <artifactId>wicket-bootstrap-extensions</artifactId>
        <version>0.9.2</version>
        <optional>true</optional>
        <exclusions>
            <exclusion>
                <groupId>org.json</groupId>
                <artifactId>*</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.rabbitmq</groupId>
        <artifactId>amqp-client</artifactId>
        <version>5.2.0</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore-nio</artifactId>
        <version>4.4.9</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.9</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.5</version>
        <scope>compile</scope>
    </dependency>


</dependencies>

运行jar时,我将commons-jexl-2.1.1.jar包含在类路径中,但仍然出现相同的错误,请帮助我

预先感谢

2 个答案:

答案 0 :(得分:0)

对我来说,就像是一个类加载问题。尝试使用与执行代码的类相同的类加载器加载相关的类。

答案 1 :(得分:0)

添加以下依赖项解决了我的错误:

<dependency>
            <groupId>org.perf4j</groupId>
            <artifactId>perf4j</artifactId>
            <version>0.9.16</version>
        </dependency>
         <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.5</version>
        </dependency>    
        <dependency>
            <groupId>commons-jexl</groupId>
            <artifactId>commons-jexl</artifactId>
            <version>1.1</version>
        </dependency>