简体   繁体   中英

Unable to create a CoreContainer when embedding Solr in Jetty

I followed the instructions on this post: http://javaskeleton.blogspot.de/2011/07/adding-solr-to-existing-web-application.html .

When I tried to execute this code:

File home = new File(System.getProperty("solr.solr.home"));
CoreContainer container = new CoreContainer(home.getPath());
container.load();
EmbeddedSolrServer server = new EmbeddedSolrServer(container, "collection1");

I encountered the following error:

org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: NativeFSLock@C:\\solr-4.6.0\\example\\solr\\collection1\\data\\index\\write.lock

Upon investigation, the error is issued while loading the CoreContainer. It attempts to lock a file in the index that is apparently locked.

Further investigation revealed that the SolrRequestFilter (the one that is initialized by Jetty) also instantiates a CoreContainer and my guess is that he is the offender. When I removed the SolrRequestFilter definition from web.xml, I was able to successfully instantiate the CoreContainer and the EmbeddedServer.

I am looking for insight as to how I can try to overcome the problem since it seems that it should be able to work.

You must find who lock this index.

Also there are several approaches that might help:

  • Since you starting embedded Solr, you need to be sure, that Solr isn't running now (my bet is that 99% this is the cause of this issue)
  • You could remove this lock file manually

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM