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 使用 eclipse 运行同一个项目时 - 复制到 U 盘是成功的。

4

1 回答 1

2

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

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

于 2012-10-02T18:28:14.107 回答