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」ディスクは、マップされたネットワーク ディスクです。しかし、2 番目のパーティション ディスク 'D' ファイルを使用した同じルートで、正常に作成されます。

WAR ファイルを生成して、Apache Tomcat の Local System Service で実行します。

興味深いことに、サービスの前に、Maven による Eclipse で同じプロジェクトを実行すると、U ディスクへのコピーが正常に行われました。

4

1 に答える 1

2

ローカル システム サービスのユーザーは、マップされたドライブ 'U' を認識できない可能性があります。解決策: UNC パスを使用します。

Tomcat を実行しているユーザーには、ネットワーク パスにアクセスするためのアクセス許可が必要であることに注意してください。多くの場合、ローカル システム サービス ユーザーにはアクセス許可がありません。その場合、サービスの「ログオン」タブでユーザーを変更することにより、権限を持つユーザーとして Tomcat を実行できます。

于 2012-10-02T18:28:14.107 に答える