my simple code is
I am run this code in java WebServlet
solrDir = config.getServletContext().getRealPath("/lotiya");
container = new CoreContainer(solrDir);
container.load();
server = new EmbeddedSolrServer(container, "collection1");
solrParams = new ModifiableSolrParams();
solrParams = new ModifiableSolrParams();
solrParams.add(CommonParams.Q, "*:*");
//solrParams.set("qt", "/dataimport");
//solrParams.set("command", "full-import");
//solrParams.set("command", "reload-config");
solrParams.set("wt", "json");
QueryResponse queryResponse = server.query(solrParams);
for (SolrDocument document : queryResponse.getResults()) {
System.out.println(document);
}
at first time , when dataimport is run well. Exception is come when run second time because of "write.lock" in indexes that I know one solution is that restart the server and check but every time this technique not possible. so, Is there any method to reindex.
Exception code like...
org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Index locked for write for core collection1
at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:827)
at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:110)
at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:90)
at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
at solrjj.TestSolr.doGet(TestSolr.java:71)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.solr.common.SolrException: Index locked for write for core collection1
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:844)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:630)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:562)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:597)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:258)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:250)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
... 3 more
Caused by: org.apache.lucene.store.LockObtainFailedException: Index locked for write for core collection1
at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:496)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:761)
... 11 more
I think you are using Servlet. Try this following code with init() method of servlet.
container = new CoreContainer(solrDir);
container.load();
server = new EmbeddedSolrServer(container, "collection1");
solrParams = new ModifiableSolrParams();
Reason: When ever servlet is load initialized, every time it creates container object and server object which is already using collection1 so that why is raises error of write.lock
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments