2010-05-17 75 views
0

我想从我的(java)mojarra 2.0.2 webapp使用nutch(1.1)而不使用bin/nutch ...我在google搜索示例,但有没有例子我怎么能认识到这一点:/ ...我得到一个异常和作业失败:/(我想原因的东西用Hadoop)...这里是我的代码:无需使用bin/nutch从java web应用程序抓取网站

 
    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应用程序爬行吗?我增加了X毫秒为256M和XMX到768米,但什么都没有改变......

问候马塞尔

回答

1

你可能有到Nutch的配置文件添加到类路径。通常,在调用脚本bin/nutch时,通过NUTCH_CONF_DIR环境变量进行设置。

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

花时间检查bin/nutch脚本以了解更多关于这些的信息。

0

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

0

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