title: How can I refresh the resolution of a network name in java?
body: <p>I am currently writing a Java EE application to search over an index with Lucene.</p>
  
  <p>My application resides in a Tomcat server on a Windows Machine and index data is on another machine.</p>
  
  <p>Sometimes (apparently randomly), the network name becomes unreachable.</p>
  
  <p>This is the exception I get:</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>Here is the relevant code. The exception is thrown on the <code>FSDirectory.open</code></p>
  
  <pre><code>private void addReaderForRegistry(String indexDirectoryPath, List&lt;IndexReader&gt; 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&lt;String&gt; subfolders = FileSystemHelper.listDirectories(indexFolder.getAbsolutePath());
  
          if(subfolders.isEmpty()){
              Directory fsDirectory = FSDirectory.open(indexFolder);
              IndexReader reader = IndexReader.open(fsDirectory);
              readers.add(reader);                
          }
      }
  }
  </code></pre>
  
  <p>I am sure that the server is up.</p>
  
  <p>To fix this I have to restart the Tomcat Application Server. Is there something I can do to do some errror recovery?</p>
  
  <p>Note that the FSDirectory is opened at each request, so a simple bean reinitialization does not work.</p>
  
  <p>thanks.</p>
  
  <p>Edit: here is a more complete stacktrace</p>
  
  <pre><code>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]
  </code></pre>