title: FileNotFound by Jenkins on Windows virtual drive
body: <p>I have a Jenkins installation (version 1.474) running on a Windows Server Enterprise 2007 machine and 
  I am having a problem when running maven test goal through Jenkins. My test needs to read a txt file in a 
  configured path and I am getting "FileNotFound" exception when running it:</p>
  
  <pre><code>path: file:////X:/TESTIN/file.txt
  java.io.FileNotFoundException: X:\TESTIN\file.txt (The system cannot find the path specified)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:120)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:79)
      at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
      at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
      at br.com.telecomassociates.taalarms.EncoderTest.open(EncoderTest.java:69)
      at br.com.telecomassociates.taalarms.EncoderTest.readFile(EncoderTest.java:48)
      at br.com.telecomassociates.taalarms.EncoderTest.testDecrypt(EncoderTest.java:22)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
      at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
      at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
      at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
      at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
      at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
      at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
  </code></pre>
  
  <p>The problematic point is that this file is referenced through a virtual windows drive:</p>
  
  <p>The file resides physically at D:/TESTOUT/TESTIN/file.txt but we used the above command:</p>
  
  <pre><code>subst X: D:/TESTOUT
  </code></pre>
  
  <p>and we reference it in our test code by the URI file:///X:/TESTIN/file.txt.</p>
  
  <p>When Jenkins/maven runs it I get a FileNotFound exception, but, when I run the same command using "mvn test"
  on a Windows command line the file is read correctly:</p>
  
  <p><img src="https://i.stack.imgur.com/j4Ywc.png" alt="Runs fine on mvn test"></p>
  
  <p>Do you guys have any idea of what may be causing the issue ?</p>