0

我想将PhoneticFilterFactory 与ColognePhonetic 一起使用,但我只得到一个“ java.lang.NoClassDefFoundError:” 知道这里有什么问题吗?

我对 PhoeneticFilterFactory 的定义

@TokenFilterDef(factory = PhoneticFilterFactory.class, params = {
     @Parameter(name = "encoder", value="ColognePhonetic")
     })

这是整个 Anyalyzer 定义:

@AnalyzerDef(name = "customanalyzer", tokenizer =
@TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
  @TokenFilterDef(factory = LowerCaseFilterFactory.class),
  @TokenFilterDef(factory = PhoneticFilterFactory.class, params = {
     @Parameter(name = "encoder", value="ColognePhonetic")
     }),
  @TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
    @Parameter(name = "language", value = "German")
  })
})

错误:

ERROR 2013-11-11 14:20:08,010 [LogErrorHandler] HSEARCH000058: HSEARCH000116: Unexpected error during MassIndexer operation: java.lang.NoClassDefFoundError: org/apache/commons/codec/Encoder
   at org.apache.lucene.analysis.phonetic.PhoneticFilter.incrementToken(PhoneticFilter.java:64)
   at org.apache.lucene.analysis.snowball.SnowballFilter.incrementToken(SnowballFilter.java:76)
   at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:146)
   at org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:278)
   at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:766)
   at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2060)
   at org.hibernate.search.backend.impl.lucene.works.AddWorkDelegate.performWork(AddWorkDelegate.java:71)
   at org.hibernate.search.backend.impl.lucene.LuceneBackendTaskStreamer.doWork(LuceneBackendTaskStreamer.java:66)
   at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessor.applyStreamWork(LuceneBackendQueueProcessor.java:83)
   at org.hibernate.search.indexes.impl.DirectoryBasedIndexManager.performStreamOperation(DirectoryBasedIndexManager.java:121)
   at org.hibernate.search.backend.impl.StreamingSelectionVisitor$AddSelectionDelegate.performStreamOperation(StreamingSelectionVisitor.java:99)
   at org.hibernate.search.backend.impl.batch.DefaultBatchBackend.sendWorkToShards(DefaultBatchBackend.java:75)
   at org.hibernate.search.backend.impl.batch.DefaultBatchBackend.enqueueAsyncWork(DefaultBatchBackend.java:62)
   at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.index(EntityConsumerLuceneWorkProducer.java:210)
   at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.indexAllQueue(EntityConsumerLuceneWorkProducer.java:138)
   at org.hibernate.search.batchindexing.impl.EntityConsumerLuceneWorkProducer.run(EntityConsumerLuceneWorkProducer.java:106)
   at org.hibernate.search.batchindexing.impl.OptionallyWrapInJTATransaction.run(OptionallyWrapInJTATransaction.java:89)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:722)

在 JBoss AS 7.1.3.Final 上使用 Hibernate Search 4.4.0 Final 和 Hibernate Core {4.1.6.Final}

4

2 回答 2

2

您的类路径中似乎缺少 Apache Commons Codec 库。如果你看一下 Hibernate Search 4.4.0.Final 的依赖树,你会看到对 commons-codec 1.6 有一个传递依赖:

hibernate-search:4.4.0.Final
- hibernate-search-orm:4.4.0.Final
  - hibernate-search-analyzers:4.4.0.Final
    - solr-analysis-extras:3.6.2
      - solr-core:3.6.2
        - commons-codec:1.6
        - lucene-phonetic:3.6.2
          - commons-codec:1.6

因此,将 commons-codec 添加到您的类路径至少应该解决NoClassDefFoundError.

于 2013-11-11T18:45:51.713 回答
0

在休眠团队的 Gunnar 的帮助下,问题得以解决。(https://forum.hibernate.org/viewtopic.php?f=9&t=1029612

解决方案是将 commons-codec-1.8.jar 复制到我的 jboss 安装中的 apache lucene 模块文件夹(JBOSS_HOME/modules/org/apache/lucene/3.6.2),并在 module.xml 中创建一个条目。

之后,语音过滤器工厂,尤其是古语语音,被发现并且我的索引正在工作。

感谢所有帮助过的人。

于 2013-11-15T14:32:15.897 回答