Let’s me start from a scenario of a Java (Hibernate, Spring App)/tomcat application that would give you as myself, the error as stated in the subject above.

To reproduce

In some cases, as you do as following steps:

  • Build with clean install
  • Start Tomcat as normal
  • Stop Tomcat
  • And Start Tomcat again
  • You got an error with LockObtainFailedException

The error message

org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: SimpleFSLock@C:\Users\youruser\YourProject-1.0-SNAPSHOT\index\com.yourproject.model.MyModel\write.lock


Work Around Solution

Here is my first solution, I noticed each time I got the error

  • Each before start any tomcat, you need to run: mvn clean install
  • Then can start tomcat as normal


Exactly Cause & Temporary Solution

What’s the exactly issue I really found out. It is because of your search index in configuration of file: hibernate.properties


According to the doc of LockFactory as in one document of RedHat, the strategy config with simple said that:

If for some reason you had to kill your application, you will need to remove this file before restarting it.

So that for my temporary solution, I consider to disable the index for awhile in my development environment and keep above setting for my production environment.


Real Solution

I still need more flexible solution which is better than above “Work Around Solution” & “Temporary Solution” for my development environment, nor deleting the file for each restarting the tomcat.

Please drop in comment if you have some experiences about this issue.