Java Jenkins在Windows虚拟驱动器上未找到文件

Java Jenkins在Windows虚拟驱动器上未找到文件,java,windows,maven,jenkins,Java,Windows,Maven,Jenkins,我有一个Jenkins安装(版本1.474)在Windows Server Enterprise 2007计算机上运行,并且 我在通过Jenkins运行maven测试目标时遇到了问题。我的测试需要读取文件中的txt文件 已配置路径,运行时出现“FileNotFound”异常: path: file:////X:/TESTIN/file.txt java.io.FileNotFoundException: X:\TESTIN\file.txt (The system cannot find the

我有一个Jenkins安装(版本1.474)在Windows Server Enterprise 2007计算机上运行,并且 我在通过Jenkins运行maven测试目标时遇到了问题。我的测试需要读取文件中的txt文件 已配置路径,运行时出现“FileNotFound”异常:

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.<init>(FileInputStream.java:120)
    at java.io.FileInputStream.<init>(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)
我们在测试代码中通过URI引用它file:///X:/TESTIN/file.txt.

当Jenkins/maven运行它时,我会得到一个FileNotFound异常,但是,当我使用“mvn测试”运行相同的命令时 在Windows命令行上正确读取文件:


你们知道问题的起因吗?

lee meador和@jtahlborn都给我指出了正确的方向。My Jenkins在Tomcat中作为web应用程序运行,而Tomcat是作为服务运行的。结果是詹金斯看不到X:drive

为了解决这个问题,我听从了办公室的建议。我生成了一个包含以下内容的“.reg”文件:

REGEDIT4 

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices] 
"Z:"="\\??\\D:\\TESTOUT" 
然后我执行了它并重新启动了机器


驱动器X:现在对所有用户都可见,Jenkins可以很好地看到它。

Jenkins是在与您的命令行相同的用户下运行的吗?我猜Jenkins是作为服务用户运行的,但没有映射该驱动器。
REGEDIT4 

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices] 
"Z:"="\\??\\D:\\TESTOUT"