Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.3
Hibernate Search Version: 3.0.0
I'm working on performing a bulk indexing of a number of classes in my domain model using hibernate search. The building of the indexes works nicely, and I can query them, but as soon as I try to build a full index of all the objects in the database for a given class I get the following exception:
Full stack trace of any exception that occurs:
Exception in thread "main" org.hibernate.search.SearchException: Unable to open IndexWriter for class com.myorg.SourceCustomer
at org.hibernate.search.backend.Workspace.getIndexWriter(Workspace.java:135)
at org.hibernate.search.backend.impl.lucene.LuceneWorker.add(LuceneWorker.java:68)
at org.hibernate.search.backend.impl.lucene.LuceneWorker.performWork(LuceneWorker.java:62)
at org.hibernate.search.backend.impl.lucene.LuceneWorker.performWork(LuceneWorker.java:43)
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessor.run(LuceneBackendQueueProcessor.java:98)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.performWorks(BatchedQueueingProcessor.java:132)
at org.hibernate.search.backend.impl.TransactionalWorker.performWork(TransactionalWorker.java:48)
at org.hibernate.search.impl.FullTextSessionImpl.index(FullTextSessionImpl.java:140)
at com.myorg.IndexMaintServiceImpl.indexClass(IndexMaintServiceImpl.java:58)
at com.myorg.IndexBuilderMain.main(IndexBuilderMain.java:36)
Caused by: java.io.FileNotFoundException: C:\scnindexes\primary\segments_2ir (Access is denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:212)
at org.apache.lucene.store.FSDirectory$FSIndexInput$Descriptor.<init>(FSDirectory.java:506)
at org.apache.lucene.store.FSDirectory$FSIndexInput.<init>(FSDirectory.java:536)
at org.apache.lucene.store.FSDirectory$FSIndexInput.<init>(FSDirectory.java:531)
at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:440)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:193)
at org.apache.lucene.index.IndexFileDeleter.<init>(IndexFileDeleter.java:156)
at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:626)
at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:410)
at org.hibernate.search.backend.Workspace.getIndexWriter(Workspace.java:118)
... 9 more
The code that generates this exception:
Code:
Criteria c = fullTextSession.createCriteria(clazz);
c.setFetchSize(1000);
ScrollableResults results = c.scroll(ScrollMode.FORWARD_ONLY);
int index = 0;
int batchSize = 1000;
System.out.println("Got the list");
while( results.next() )
{
if(index % 5 == 0)
System.out.print(".");
if(index % 500 == 0)
System.out.println(" " + index);
index++;
fullTextSession.index( results.get(0) );
if (index % batchSize == 0)
{
System.out.println("flushing the session...");
fullTextSession.clear(); //clear every batchSize since the queue is processed
fullTextSession.flush();
}
}
I am able to index between 500 and 1000 objects (though once around 1200) before the above exception occurs. I've played with tuning parameters for the index etc, and nothing seems to help.
If there's anything else I can provide please let me know, but this is what I've been staring at for a while and I'm drawing a blank. Any pointers or things to look at would be greatly appreciated. The code I'm using to perform the bulk index is VERY close to the code in the hibernate search reference docs, but clearly I'm doing something wrong.
Thanks in advance for any assist you can give.