2012-10-02 82 views
1

我需要保存文件使用系统服务的Apache Tomcat到网络驱动器,并得到所有的时间错误:网络磁盘骆驼文件组件

Exception: org.apache.camel.component.file.GenericFileOperationFailedException: Cannot store file: u:\xxx.txt 

我的路线示例:

<route id="myRoute"> 
     <from uri="quartz:myQuartz?cron=0+0+*+?+*+MON-FRI"/> 
     <camel:doTry> 
      <bean method="getData" ref="myService"/> 
      <marshal ref="bindyFixedDataformat"/> 
      <to uri="file:u:?fileName=xxx.txt&amp;autoCreate=false&amp;fileExist=Append"/> 
      <to uri="file://c:/XXX/files?fileName=xxx-${date:now:yyyyMMdd}.txt"/> 
      <camel:bean method="setProcessed" ref="myService"/> 
     <camel:doCatch> 
      <exception>java.io.IOException</exception> 
      <camel:log message="Network drive (U:) is not available, please renew connection!" loggingLevel="ERROR"/> 
      <camel:bean method="setFailed" ref="myService"/> 
     </camel:doCatch> 
     <camel:doCatch> 
      <exception>java.lang.Exception</exception> 
      <camel:log message="Unexpected error has occured!" loggingLevel="ERROR" /> 
      <camel:bean method="setFailed" ref="myService"/> 
     </camel:doCatch> 
     </camel:doTry> 
    </route> 

“U '磁盘是映射的网络磁盘。但与我的第二个分区磁盘'D'文件相同的路线创建成功。

我正在生成WAR文件并使用Apache Tomcat的本地系统服务运行它。

有趣的是,在服务之前,当我通过Maven运行同一个项目并通过maven复制到U盘时,发生了成功。

回答

2

本地系统服务用户可能看不到您映射的驱动器'U'。解决方案:使用UNC路径。

请注意,运行Tomcat的用户需要访问网络路径的权限 - 通常是本地系统服务用户不会拥有的权限。在这种情况下,您可以以拥有权限的用户身份运行Tomcat,即通过在服务的“登录”选项卡中更改用户。

+0

如果我改成这样: <到URI = “文件:\\?1.255.255.1 \目录文件名= xxx.txt & AUTOCREATE =假& fileExist =附加”/> 我得到同样的错误 异常:org.apache.camel.component.file.GenericFileOperationFailedException:无法存储文件:\\ 1.255.255.1 \ directory \ xxx.txt 此外,如果我更改登录为服务相同的用户对此网络驱动器的权限是什么 - 结果相同。 :( – iriwkins

+0

因此,如果您在以该用户身份登录时将其键入/粘贴到Windows资源管理器中,是否可以打开\\ 1.255.255.1 \目录? –

+0

是的!我甚至可以创建,更改和删除那些文件 – iriwkins