Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.3.0 GA core
3.1.0 Beta1
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Code:
@Transactional(propagation=Propagation.REQUIRES_NEW,
isolation=Isolation.SERIALIZABLE,
readOnly=true)
public void batchProcessPostingIndex
{
Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
FullTextSession fullTextSession = Search.getFullTextSession(session);
fullTextSession.setFlushMode(FlushMode.MANUAL);
fullTextSession.setCacheMode(CacheMode.IGNORE);
//Scrollable results will avoid loading too many objects in memory
ScrollableResults results = fullTextSession.createCriteria(Post.class )
.setFetchSize(BATCH_SIZE)
.scroll( ScrollMode.FORWARD_ONLY );
int index = 0;
while( results.next() ) {
index++;
fullTextSession.index( results.get(0) ); //index each element
if (index % BATCH_SIZE == 0) {
fullTextSession.flushToIndexes(); //apply changes to indexes
fullTextSession.clear(); //clear since the queue is processed
}
}
}
Full stack trace of any exception that occurs:Code:
Exception in thread "main" org.hibernate.search.SearchException: Unable to remov
e from Lucene index: class ups.message.board.domain.Post#192114
at org.hibernate.search.backend.impl.lucene.LuceneWorker.remove(LuceneWo
rker.java:108)
at org.hibernate.search.backend.impl.lucene.LuceneWorker.performWork(Luc
eneWorker.java:79)
at org.hibernate.search.backend.impl.lucene.LuceneWorker.performWork(Luc
eneWorker.java:46)
at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueProcessor.
run(LuceneBackendQueueProcessor.java:98)
at org.hibernate.search.backend.impl.BatchedQueueingProcessor.performWor
ks(BatchedQueueingProcessor.java:151)
at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchroniza
tion.flushWorks(PostTransactionWorkQueueSynchronization.java:63)
at org.hibernate.search.backend.impl.TransactionalWorker.flushWorks(Tran
sactionalWorker.java:63)
at org.hibernate.search.impl.FullTextSessionImpl.flushToIndexes(FullText
SessionImpl.java:100)
at ups.message.board.dao.PostingDaoHibernateImpl.batchPro
cessPostingIndex(PostingDaoHibernateImpl.java:110)
at ups.message.board.service.PostingServiceImpl.batchProc
essPostingIndex(PostingServiceImpl.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflecti
on(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJo
inpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.in
voke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynami
cAopProxy.java:204)
at $Proxy14.batchProcessPostingIndex(Unknown Source)
at ups.message.board.main.BatchPostingIndex.main(BatchPostingIndex.java
:27)
Caused by: org.apache.lucene.store.LockObtainFailedException: Lock obtain timed
out: SimpleFSLock@C:\searchIndex\Post\write.lock
at org.apache.lucene.store.Lock.obtain(Lock.java:85)
at org.apache.lucene.index.DirectoryIndexReader.acquireWriteLock(Directo
ryIndexReader.java:250)
at org.apache.lucene.index.IndexReader.deleteDocument(IndexReader.java:7
25)
at org.hibernate.search.backend.impl.lucene.LuceneWorker.remove(LuceneWo
rker.java:103)
... 25 more
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html