我目前正在编写一个 Java EE 应用程序来使用 Lucene 搜索索引。
我的应用程序驻留在 Windows 机器上的 Tomcat 服务器中,而索引数据位于另一台机器上。
有时(显然是随机的)网络名称变得无法访问。
这是我得到的例外:
12:29:39.011 [ajp-8039-5] ERROR o.f.c.d.p.viewmodel.PilotViewModel - The specified network name is no longer available: SimpleFSIndexInput(path="\\INDEXFILEPATH\indexfile.ext")
java.io.IOException: The specified network name is no longer available: SimpleFSIndexInput(path="\\INDEXFILEPATH\indexfile.ext")
at org.apache.lucene.store.SimpleFSDirectory$SimpleFSIndexInput.readInternal(SimpleFSDirectory.java:140) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
这是相关的代码。异常被抛出FSDirectory.open
private void addReaderForRegistry(String indexDirectoryPath, List<IndexReader> readers) throws IOException{
File indexFolder = new File(indexDirectoryPath);
if (!(indexFolder.exists() || !(indexFolder.isDirectory()))) {
throw new IOException(indexFolder.getName() + "is not a valid index location");
}else{
// search for subfolders
List<String> subfolders = FileSystemHelper.listDirectories(indexFolder.getAbsolutePath());
if(subfolders.isEmpty()){
Directory fsDirectory = FSDirectory.open(indexFolder);
IndexReader reader = IndexReader.open(fsDirectory);
readers.add(reader);
}
}
}
我确定服务器已启动。
要解决此问题,我必须重新启动 Tomcat 应用程序服务器。我可以做些什么来做一些错误恢复吗?
请注意,FSDirectory 在每次请求时都会打开,因此简单的 bean 重新初始化不起作用。
谢谢。
编辑:这是一个更完整的堆栈跟踪
java.io.IOException: The specified network name is no longer available: SimpleFSIndexInput(path="\\hqwprceb1\DRMS-STRUCTURE\indexes_ready\AG\_o48.nrm")
at org.apache.lucene.store.SimpleFSDirectory$SimpleFSIndexInput.readInternal(SimpleFSDirectory.java:140) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.store.BufferedIndexInput.readBytes(BufferedIndexInput.java:156) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.index.SegmentNorms.bytes(SegmentNorms.java:164) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.index.SegmentReader.norms(SegmentReader.java:575) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.search.TermQuery$TermWeight.scorer(TermQuery.java:107) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.search.BooleanQuery$BooleanWeight.scorer(BooleanQuery.java:298) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.search.ConstantScoreQuery$ConstantWeight.scorer(ConstantScoreQuery.java:145) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.search.BooleanQuery$BooleanWeight.scorer(BooleanQuery.java:298) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:577) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:383) ~[lucene-core-3.6.1.jar:3.6.1 1362471 - thetaphi - 2012-07-17 12:40:12]