0

在 Apache Nutch/Solr 中出现以下错误:

java.lang.RuntimeException: Error in configuring object
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:93)
    at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:64)
    at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:354)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:307)
    at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:177)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:88)
    ... 5 more
Caused by: java.lang.RuntimeException: Error in configuring object
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:93)
    at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:64)
    at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117)
    at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:34)
    ... 10 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:88)
    ... 13 more
Caused by: java.lang.NoClassDefFoundError: opennlp/tools/sentdetect/SentenceDetector
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.newInstance0(Class.java:326)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.nutch.plugin.Extension.getExtensionInstance(Extension.java:160)
    at org.apache.nutch.indexer.IndexingFilters.<init>(IndexingFilters.java:69)
    at org.apache.nutch.indexer.IndexerMapReduce.configure(IndexerMapReduce.java:62)
    ... 18 more
Caused by: java.lang.ClassNotFoundException: opennlp.tools.sentdetect.SentenceDetector
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:315)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
    ... 26 more
2012-04-24 13:59:18,713 ERROR solr.SolrIndexer - java.io.IOException: Job failed!

我修改了一个名为 BasicIndexingFilter.java 的过滤器类以使用 OpenNLP 的 SentenceDetector 类。BasicIndexingFilter.java 的相关部分:

SentenceDetector sentenceDetector = null;

        InputStream modelIn = null;
        try {
            // Loading sentence detection model
            modelIn = getClass().getResourceAsStream("/models/sentdetect/en-sent.bin");
            final SentenceModel sentenceModel = new SentenceModel(modelIn);
            modelIn.close();

            sentenceDetector = new SentenceDetectorME(sentenceModel);

        } catch (final IOException ioe) {
            LOG.info("Model input error");
            ioe.printStackTrace();
        } finally {
            if (modelIn != null) {
                try {
                    modelIn.close();
                } catch (final IOException e) {} // oh well!
            }
        }

我已将此添加到 build.xml 文件中:

 <property name="lib.dir"     value="lib"/>

    <path id="classpath">
        <fileset dir="${lib.dir}" includes="**/*.jar"/>
    </path>

它现在编译得很好,但我得到了运行时错误。我是 Java 新手,但我猜它与我尝试加载的模型文件有关:

modelIn = getClass().getResourceAsStream("/models/sentdetect/en-sent.bin");

opennlp-tools-1.5.0.jarSentenceDetector 类在我的./lib folder,模型文件en-sent.bin.lib/models/sentdetect. BasicIndexingFilter 类在其他地方,它都是从 Nutch 的 bin 文件中运行的。

指向模型文件或其他东西有问题吗?

4

2 回答 2

0

我认为您缺少maxent 3.0.0 jar类路径中的文件。如果你确实有这个,那么尝试将opennlp-tools-1.5.1-incubating.jar添加到你的库中。

于 2012-04-24T21:15:26.167 回答
0

由于您使用的是 jar 文件中的应用程序,因此请向其中添加 Manifest.mf。在清单中插入要添加到类路径中的 jar 文件。请按照此处的说明进行操作:http: //java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html#applications 希望这可以帮助您。

于 2012-04-24T21:20:43.950 回答