在不使用bin / nutch的情况下从java Web应用程序中抓取网站

时间:2010-05-17 09:12:23

标签: web-applications nutch web-crawler

我正试图在我的(java)mojarra 2.0.2 webapp中使用没有bin / nutch的nutch(1.1)...我在google搜索示例,但是没有例子我怎么能意识到这一点:/。 ..我得到一个例外而且工作失败了:/(我认为原因是hadoop)......这是我的代码:

  public void run() throws Exception {
      final String[] args = new String[] {
            String.format("%s%s%s%s", JSFUtils.getWebAppRoot(), "nutch", File.separator, DIRECTORY_URLS),
            "-dir", String.format("%s%s%s%s", JSFUtils.getWebAppRoot(), "nutch", File.separator, DIRECTORY_CRAWL),
            "-threads", this.preferences.get("threads"),
            "-depth", this.preferences.get("depth"),
            "-topN", this.preferences.get("topN"),
            "-solr", this.preferences.get("solr")
        };
      Crawl.main(args);
  }

和日志记录的一部分:

10/05/17 10:42:54 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
10/05/17 10:42:54 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
10/05/17 10:42:54 INFO mapred.FileInputFormat: Total input paths to process : 1
10/05/17 10:42:54 INFO mapred.JobClient: Running job: job_local_0001
10/05/17 10:42:54 INFO mapred.FileInputFormat: Total input paths to process : 1
10/05/17 10:42:55 INFO mapred.MapTask: numReduceTasks: 1
10/05/17 10:42:55 INFO mapred.MapTask: io.sort.mb = 100
java.io.IOException: Job failed!
        at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1232)
        at org.apache.nutch.crawl.Injector.inject(Injector.java:211)
        at org.apache.nutch.crawl.Crawl.main(Crawl.java:124)
        at lan.localhost.process.NutchCrawling.run(NutchCrawling.java:108)
        at lan.localhost.main.Index.indexing(Index.java:71)
        at lan.localhost.bean.FeedingBean.actionStart(FeedingBean.java:25)
        ....

有人可以帮助我或告诉我如何从Java应用程序中爬行吗?我已将Xms增加到256m,将Xmx增加到768m,但没有任何改变......

最好的问候marcel

3 个答案:

答案 0 :(得分:1)

您可能必须将nutch配置文件添加到类路径中。通常,在调用脚本bin / nutch时,它是通过 NUTCH_CONF_DIR 环境变量设置的。

还可能需要设置 -Dhadoop.log.dir

花点时间检查bin / nutch脚本以了解更多相关信息。

答案 1 :(得分:0)

您可以分叉一个新进程并运行bin / nutch脚本。

答案 2 :(得分:0)

由于某些原因无法使用提供的sysout诊断注入作业失败。需要更多日志。

相关问题