gigaZhang / mmseg4j

Automatically exported from code.google.com/p/mmseg4j
Apache License 2.0
0 stars 0 forks source link

1.9 在solr 4 beta 下面创建索引的时候报错 #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
2012-8-16 0:14:43 com.chenlb.mmseg4j.solr.MMSegTokenizerFactory newSeg
信息: create new Seg ...
2012-8-16 0:14:43 com.chenlb.mmseg4j.solr.MMSegTokenizerFactory newSeg
信息: use max-word mode
2012-8-16 0:14:43 org.apache.solr.common.SolrException log
严重: null:java.lang.RuntimeException: java.lang.NoSuchMethodError: 
org.apache.l
ucene.analysis.Tokenizer.reset(Ljava/io/Reader;)V
        at org.apache.solr.servlet.SolrDispatchFilter.sendError(SolrDispatchFilt
er.java:468)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilte
r.java:296)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:224)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:169)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:168)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:98)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
927)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:407)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:987)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:579)
        at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:1805)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:908)
        at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoSuchMethodError: org.apache.lucene.analysis.Tokenizer.res
et(Ljava/io/Reader;)V
        at com.chenlb.mmseg4j.analysis.MMSegTokenizer.reset(MMSegTokenizer.java:
33)
        at com.chenlb.mmseg4j.solr.MMSegTokenizerFactory.create(MMSegTokenizerFa
ctory.java:51)
        at org.apache.solr.analysis.TokenizerChain.createComponents(TokenizerCha
in.java:64)
        at org.apache.lucene.analysis.AnalyzerWrapper.createComponents(AnalyzerW
rapper.java:69)
        at org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:82)
        at org.apache.solr.highlight.DefaultSolrHighlighter.createAnalyzerTStrea
m(DefaultSolrHighlighter.java:603)
        at org.apache.solr.highlight.DefaultSolrHighlighter.doHighlightingByHigh
lighter(DefaultSolrHighlighter.java:477)
        at org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(Defau
ltSolrHighlighter.java:401)
        at org.apache.solr.handler.component.HighlightComponent.process(Highligh
tComponent.java:136)
        at org.apache.solr.handler.component.SearchHandler.handleRequestBody(Sea
rchHandler.java:206)
        at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandl
erBase.java:129)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:1656)
        at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter
.java:454)
        at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilte
r.java:275)
        ... 15 more

Original issue reported on code.google.com by wjia...@gmail.com on 15 Aug 2012 at 4:23

GoogleCodeExporter commented 8 years ago
这个是因为Lucene 4.0 
beta里面Tokenizer的API改动的缘故,从之前的reset变成了现在的se
t,只需要把MMSegTokenizer类中reset方法的名字改成set去override掉�
��类的方法即可。

Original comment by EddieDu...@gmail.com on 3 Sep 2012 at 9:41

GoogleCodeExporter commented 8 years ago
楼上方法试了不行啊。

Original comment by dota.rep...@gmail.com on 3 Sep 2012 at 2:47

GoogleCodeExporter commented 8 years ago
不好意思,我没说清楚。
4.0Beta里,reset被改成了setReader,有两个类需要改动,一个是MM
SegTokenizerFactory(里面含有关于setReader的调用),另外一个是M
MSegTokenizer(需要override掉父类setReader的方法)。

Original comment by EddieDu...@gmail.com on 4 Sep 2012 at 2:17

GoogleCodeExporter commented 8 years ago
MMSegTokenizer.java文件改动:
        //public void reset(Reader input) throws IOException {
        public void setReader(Reader input) throws IOException {
                //super.reset(input);
                mmSeg.reset(input);
        }

MMSegTokenizerFactory.java文件改动:

                        try {
                                //tokenizer.reset(input);
                                tokenizer.setReader(input);
                        } catch (IOException e) {
                                tokenizer = newTokenizer(input);
                                log.info("MMSegTokenizer.reset i/o error by:"+e.getMessage());
                        }

是这样吗。

Original comment by dota.rep...@gmail.com on 4 Sep 2012 at 4:45

GoogleCodeExporter commented 8 years ago
//super.reset(input);
这个应该改为super.setReader(input);吧

Original comment by dota.rep...@gmail.com on 4 Sep 2012 at 4:58

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
   改后编译出错
    [javac] ~/tmp/mmseg4j/src/com/chenlb/mmseg4j/analysis/MMSegTokenizer.java:34: error: cannot find symbol
    [javac]             super.setReader(input);
    [javac]                  ^
    [javac]   symbol: method setReader(Reader)
    [javac] 1 error

Original comment by dota.rep...@gmail.com on 4 Sep 2012 at 6:02

GoogleCodeExporter commented 8 years ago
MMSegTokenizer.java文件改动:
        //public void reset(Reader input) throws IOException {
        public void setReader(Reader input) throws IOException {
                super.setReader(input);
                mmSeg.reset(input);
        }
另外,你有引入Lucene 4.0 
Beta吗?如果有,不应该编译不过啊!

Original comment by EddieDu...@gmail.com on 4 Sep 2012 at 6:21

GoogleCodeExporter commented 8 years ago
引入是不是就是该ivy.xml:

    <dependencies>^M
                <!-- solr/lucene -->^M
        <dependency org="org.apache.lucene" name="lucene-core" rev="4.0.0-BETA" conf="compile->master(*)"/>^M
        <dependency org="org.apache.lucene" name="lucene-analyzers-common" rev="4.0.0-BETA" conf="compile->master(*)"/>^M
        <dependency org="org.apache.lucene" name="lucene-queryparser" rev="4.0.0-BETA" conf="compile->master(*)"/>^M
        <dependency org="org.apache.solr" name="solr-core" rev="4.0.0-BETA" conf="compile->master(*)"/>^M
        <dependency org="org.apache.solr" name="solr-solrj" rev="4.0.0-BETA" conf="compile->master(*)"/>^M
^M
    </dependencies>^M

Original comment by dota.rep...@gmail.com on 4 Sep 2012 at 6:35

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
终于搞定了。

要吧lib下得ALPHA版本的jar文件删掉。

thanks.

Original comment by dota.rep...@gmail.com on 4 Sep 2012 at 6:57

GoogleCodeExporter commented 8 years ago
这个应该让作者编译一个版本才是啊

Original comment by wjia...@gmail.com on 4 Sep 2012 at 8:26

GoogleCodeExporter commented 8 years ago
我現在正在配置solr4正式版的時候也遇到這樣的問題 
有點不知道該怎麼去build 
不知道是否可以提供一下更改後編譯好的檔案呢? 謝謝

Original comment by ay771...@gmail.com on 23 Oct 2012 at 3:16

GoogleCodeExporter commented 8 years ago
照著上面的改成setReader會說無法override 
用原本的reset的話再solr那邊測試的時候會出現 Error occured 
while iterating over tokenstream 

請問該怎麼改?

[javac] Compiling 1 source file to /opt/mmseg4j/build/classes/java
    [javac] /opt/mmseg4j/src/com/chenlb/mmseg4j/analysis/MMSegTokenizer.java:32: setReader(java.io.Reader) in com.chenlb.mmseg4j.analysis.MMSegTokenizer cannot override setReader(java.io.Reader) in org.apache.lucene.analysis.Tokenizer; overridden method is final
    [javac]     public void setReader(Reader input) throws IOException {
    [javac]                 ^
    [javac] 1 error

Original comment by ay771...@gmail.com on 23 Oct 2012 at 6:12

GoogleCodeExporter commented 8 years ago
请将你的MMSegTokenizer类的 incrementToken 
方法标注成final。否则在debug模式下会抛异常。

Original comment by EddieDu...@gmail.com on 25 Oct 2012 at 2:27

GoogleCodeExporter commented 8 years ago

Comment 3 by EddieDu...@gmail.com, Sep 3, 2012
不好意思,我没说清楚。
4.0Beta里,reset被改成了setReader,有两个类需要改动,一个是MM
SegTokenizerFactory(里面含有关于setReader的调用),另外一个是M
MSegTokenizer(需要override掉父类setReader的方法)。

另外一个是MMSegTokenizer(需要override掉父类setReader的方法)

现在的正式版里,setReader已经是final,不能被override了,请作�
��抽点时间重新发布个版本吧

Original comment by x03570227 on 14 Nov 2012 at 8:46

GoogleCodeExporter commented 8 years ago
我也遇到这个问题了,还以为是lucene4和solr4不兼容呢, 
狂google了一圈. 还好找到了这个帖子. 麻烦作者更新下发布包.

Original comment by kch...@valueclickbrands.com on 29 Nov 2012 at 3:35

GoogleCodeExporter commented 8 years ago
谢谢eddie和dota的讨论, 我把solr, 
lucene都改称4.0.0正式版编译了一下. 自己测试能用了. 
付上编译后的jar包和大家分享.

Original comment by kch...@valueclickbrands.com on 29 Nov 2012 at 4:16

Attachments:

GoogleCodeExporter commented 8 years ago
下载kevin的包还是有问题

Original comment by liuzihen...@gmail.com on 25 Dec 2012 at 9:43

GoogleCodeExporter commented 8 years ago
solr4.6+mmseg4j1.9集成时报错
ERROR org.apache.solr.core.SolrCore  – java.lang.IllegalStateException: 
TokenStream contract violation: reset()/close() call missing, reset() called 
multiple times, or subclass does not call super.reset(). Please see Javadocs of 
TokenStream class for more information about the correct consuming workflow.

想问一下你们在修改代码然后重新编译项目。那么源代码是��
�哪儿下载的啊?!我怎么没找着源代码在哪儿?!

Original comment by qjayg...@gmail.com on 18 Feb 2014 at 8:39

GoogleCodeExporter commented 8 years ago
使用 2.0.0

参考 https://github.com/chenlb/mmseg4j-solr

Original comment by chenlb2...@gmail.com on 19 May 2014 at 12:08