簡體   English   中英

Hibernate搜索和Lucene中的FileNotFoundException

[英]FileNotFoundException in Hibernate search and Lucene

我們在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)

任何幫助深表感謝。

您是否檢查了指定實體的索引文件夾? 您還可以使用luke工具檢查實體索引。 有關詳細信息, 請訪問https://lucene.apache.org/core/3_5_0/contributions.html

它似乎索引文件不在該位置。 請驗證以下位置。

\\ SQL簇\\數據\\索引\\ 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();

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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM