1

我们在 Web 应用程序中使用 Hibernate Search,以下是我们正在使用的版本:

hibernate-search-3.4.1.Final
hibernate3.6.10.jar
lucene-core-3.4.0.jar

由于另一个问题,我们在lucene-core-3.1几个月前进行了升级。现在我经常收到以下错误。我在网上搜索并找到了这个这个以及其他几个,但它们似乎与我的不一样。这是堆栈跟踪:

2013-09-29 15:10:43,624 ERROR LogErrorHandler:82 - Exception occurred java.io.FileNotFoundException: \\sql-cluster\data\indexes\mycomp.domain.Item\_1ut.cfs (The system cannot find the file specified)
Primary Failure:
    Entity mycomp.domain.Item  Id 4761556  Work Type  org.hibernate.search.backend.AddLuceneWork

java.io.FileNotFoundException: \\sql-cluster\data\indexes\mycomp.domain.Item\_1ut.cfs (The system cannot find the file specified)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233)
    at org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:214)
    at org.apache.lucene.index.CompoundFileReader.<init>(CompoundFileReader.java:64)
    at org.apache.lucene.index.CompoundFileReader.<init>(CompoundFileReader.java:52)
    at org.apache.lucene.index.IndexWriter.getFieldInfos(IndexWriter.java:1222)
    at org.apache.lucene.index.IndexWriter.getCurrentFieldInfos(IndexWriter.java:1242)
    at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1175)
    at org.hibernate.search.backend.Workspace.createNewIndexWriter(Workspace.java:202)
    at org.hibernate.search.backend.Workspace.getIndexWriter(Workspace.java:180)
    at org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.run(PerDPQueueProcessor.java:103)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    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)
2013-09-29 15:10:43,624 ERROR PerDPQueueProcessor:118 - Unexpected error in Lucene Backend: 
java.lang.NullPointerException
    at org.hibernate.search.backend.impl.lucene.works.AddWorkDelegate.performWork(AddWorkDelegate.java:76)
    at org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.run(PerDPQueueProcessor.java:106)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    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)
2013-09-29 15:10:43,624 ERROR LogErrorHandler:82 - Exception occurred java.lang.NullPointerException
Primary Failure:
    Entity mycomp.domain.Item  Id 4761556  Work Type  org.hibernate.search.backend.AddLuceneWork

java.lang.NullPointerException
    at org.hibernate.search.backend.impl.lucene.works.AddWorkDelegate.performWork(AddWorkDelegate.java:76)
    at org.hibernate.search.backend.impl.lucene.PerDPQueueProcessor.run(PerDPQueueProcessor.java:106)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    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)

任何帮助深表感谢。

4

3 回答 3

1

您是否检查了指定实体的索引文件夹?您也可以使用卢克工具检查您的实体索引。详情https://lucene.apache.org/core/3_5_0/contributions.html

于 2013-09-30T06:39:54.343 回答
1

似乎该位置中不存在索引文件。请验证以下位置。

\sql-cluster\data\indexes\mycomp.domain.Item_1ut.cfs

在加载上下文时,它会查找索引位置。

    Most likely your index file is corrupted.

或者

    Your new hibernate lucene library pointing the wrong index path.

要解决此问题,您需要重新创建索引,如下所示。

FullTextSession session = Search.getFullTextSession(getSessionFactory().openSession());
        session.setFlushMode(FlushMode.MANUAL);
        session.setCacheMode(CacheMode.IGNORE);

 Transaction transaction  = session.beginTransaction();
 ScrollableResults items = session.createQuery("from Item i ")
                .scroll(ScrollMode.FORWARD_ONLY);

 while(items.next()) {

      Object nextToIndex = items.get(0);
      session.index(nextToIndex);
      session.flushToIndexes();
      session.clear();
}
transaction.commit();
于 2013-09-30T06:47:23.160 回答
1

Hibernate Search 3.4.x 需要 Lucene 版本 3.1.x。另见https://repository.jboss.org/nexus/content/repositories/public/org/hibernate/hibernate-search-parent/3.4.1.Final/hibernate-search-parent-3.4.1.Final.pom

您需要再次降级 Lucene,或者,如果您想使用 Lucene 3.4.x,您还需要升级 Hibernate Search。

于 2013-09-30T09:11:38.557 回答