博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
运行nutch报错:unzipBestEffort returned null
阅读量:7146 次
发布时间:2019-06-29

本文共 2657 字,大约阅读时间需要 8 分钟。

hot3.png

报错信息:fetch of  failed with: java.io.IOException: unzipBestEffort returned null

 

完整的报错信息为:

 

2014-03-12 16:48:38,031 ERROR http.Http - Failed to get protocol outputjava.io.IOException: unzipBestEffort returned nullat org.apache.nutch.protocol.http.api.HttpBase.processGzipEncoded(HttpBase.java:317)at org.apache.nutch.protocol.http.HttpResponse.
(HttpResponse.java:164)at org.apache.nutch.protocol.http.Http.getResponse(Http.java:64)at org.apache.nutch.protocol.http.api.HttpBase.getProtocolOutput(HttpBase.java:140)at org.apache.nutch.fetcher.Fetcher$FetcherThread.run(Fetcher.java:703)2014-03-12 16:48:38,031 INFO  fetcher.Fetcher - fetch of http://szs.mof.gov.cn/zhengwuxinxi/zhengcefabu/201402/t20140224_1046354.html failed with: java.io.IOException: unzipBestEffort returned null2014-03-12 16:48:38,031 INFO  fetcher.Fetcher - -finishing thread FetcherThread, activeThreads=0

 

由此可知抛出异常的代码位于src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java(lib-http插件)类的processGzipEncoded方法的317行:

 

byte[] content;if (getMaxContent() >= 0) {  content = GZIPUtils.unzipBestEffort(compressed, getMaxContent());} else {  content = GZIPUtils.unzipBestEffort(compressed);}if (content == null)  throw new IOException("unzipBestEffort returned null");

 

nutch1.7\src\plugin\protocol-http\src\java\org\apache\nutch\protocol\http\HttpResponse.java(protocol-http插件)的164行调用了processGzipEncoded方法: 

 

readPlainContent(in);String contentEncoding = getHeader(Response.CONTENT_ENCODING);if ("gzip".equals(contentEncoding) || "x-gzip".equals(contentEncoding)) {	content = http.processGzipEncoded(content, url);} else if ("deflate".equals(contentEncoding)) {	content = http.processDeflateEncoded(content, url);} else {	if (Http.LOG.isTraceEnabled()) {		Http.LOG.trace("fetched " + content.length + " bytes from " + url);	}}

 

 

通过Firefox的Firebug工具可查看该URL的响应头为Content-Encoding:gzip,Transfer-Encoding:chunked

 

解决方法如下:

 

1、修改文件nutch1.7\src\java\org\apache\nutch\metadata\HttpHeaders.java,增加一个field:

 

public final static String TRANSFER_ENCODING = "Transfer-Encoding";

 

2、修改文件nutch1.7\src\plugin\protocol-http\src\java\org\apache\nutch\protocol\http\HttpResponse.java,替换第160行代码readPlainContent(in);为如下代码

 

String transferEncoding = getHeader(Response.TRANSFER_ENCODING); if(transferEncoding != null && "chunked".equalsIgnoreCase(transferEncoding.trim())){    	    readChunkedContent(in, line);  }else{  readPlainContent(in);  }

 

3、http内容长度限制不能使用负值,只能使用一个大整数:

 

http.content.limit
655360000

 

4、因为修改了核心代码插件代码,所以需要重新编译打包发布,执行nutch1.7\build.xml的默认target:runtime  

 

cd nutch1.7ant

 

提交BUG:

1、

2、

 

 

 

 

 

转载于:https://my.oschina.net/apdplat/blog/207653

你可能感兴趣的文章
四舍五入网络Java保留两位小数
查看>>
MFC 循环界面假死的解决(MFC 按钮终止循环)
查看>>
详细解说九宫图比较常用的多控件布局
查看>>
程序员的出路在哪里?挣钱的机会来了续-福利来了,仿QQ界面,放出全部源码,打造创业框架及实现思路...
查看>>
浅析Android线程模型一 --- 转
查看>>
Cocos2d-x PluginX (二)增加新的Plugin
查看>>
python-django开发学习笔记四
查看>>
cocos2d-x开发记录:二,基本概念(导演,场景,层和精灵,场景切换,效果)...
查看>>
Binutils工具集中的一些比较常用的工具
查看>>
jsp里面实现asp.net的Global文件内容。
查看>>
Oracle ROWID
查看>>
WCF服务通信测试
查看>>
dos命令dir查找文件的用法及实例
查看>>
Hadoop守护进程【简--】
查看>>
uboot中gd的定义和使用
查看>>
Tcpdump MySQL Query
查看>>
mac jdbc连接mysql
查看>>
Activity生命周期的学习以及Logcat的使用
查看>>
Environment 常用方法
查看>>
【TYVJ】1338 QQ农场(最大流+最大权闭合图)
查看>>