0

If I will run this hibernate search program first time it works correctly, while if I compile it a second time it generates an error:

   ERROR: HSEARCH000058: Exception occurred org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@D:\data\index\com.srccodes.example.hibernate.Contact\write.lock
    Primary Failure:
        Entity com.srccodes.example.hibernate.Contact  Id null  Work Type  org.hibernate.search.backend.PurgeAllLuceneWork

    org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@D:\data\index\com.srccodes.example.hibernate.Contact\write.lock
        at org.apache.lucene.store.Lock.obtain(Lock.java:84)
        at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1108)
        at org.hibernate.search.backend.impl.lucene.IndexWriterHolder.createNewIndexWriter(IndexWriterHolder.java:127)
        at org.hibernate.search.backend.impl.lucene.IndexWriterHolder.getIndexWriter(IndexWriterHolder.java:102)
        at org.hibernate.search.backend.impl.lucene.AbstractWorkspaceImpl.getIndexWriter(AbstractWorkspaceImpl.java:119)
        at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.applyUpdates(LuceneBackendQueueTask.java:99)
        at org.hibernate.search.backend.impl.lucene.LuceneBackendQueueTask.run(LuceneBackendQueueTask.java:67)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
Draken
  • 3,134
  • 13
  • 34
  • 54
  • 2
    Possible duplicate of [LockObtainFailedException updating Lucene search index using solr](http://stackoverflow.com/questions/5327978/lockobtainfailedexception-updating-lucene-search-index-using-solr) - I suspect you are forgetting to close the first handle before trying to open a second. – Ken Y-N Oct 17 '16 at 07:07

1 Answers1

0

You will get such an error if the first instance of your Hibernate Search application is still running (on any operating system).

In addition, if you're running Windows you might also get this error if you didn't shut down the first instance correctly.

Remember that a correct shut down of any Hibernate application requires you to invoke the "close()" method on the Hibernate SessionFactory, or if you're using JPA you'll have to close the EntityManagerFactory.

Sanne
  • 6,027
  • 19
  • 34