2016-05-10 96 views
0

我試圖從本地文件夾中將一些文件複製到Apache Camel JCIFS組件的另一個本地文件夾。org.apache.camel.component.file.GenericFileOperationFailedException:無法獲取文件無法找到網絡名稱

這裏是MyRouteBuilder類我的Java代碼:

package abc; 

import org.apache.camel.builder.RouteBuilder; 

public class MyRouteBuilder extends RouteBuilder { 

    public void configure() { 
     long delay = 60 * 60 * 1000L; 
     from("smb://[email protected]/WORKGROUP/home/user/folder?password=secret&delay=" + delay) 
     .to("file://home/otherUser/folder"); 

    // This doesn't work either: 
    //from("smb://localhost;[email protected]/WORKGROUP/home/user/folder?password=secret&delay=" + delay) 
    //  .to("file://home/otherUser/folder"); 
    } 
} 

執行該航線後,以下情況例外出現:

org.apache.camel.component.file.GenericFileOperationFailedException: Could not get files The network name cannot be found. 
at org.apacheextras.camel.component.jcifs.SmbOperations.listFiles(SmbOperations.java:345) 
at org.apacheextras.camel.component.jcifs.SmbConsumer.pollDirectory(SmbConsumer.java:58) 
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:131) 
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175) 
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) 
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:745) 
Caused by: jcifs.smb.SmbException: The network name cannot be found. 
at jcifs.smb.SmbTransport.checkStatus(SmbTransport.java:563) 
at jcifs.smb.SmbTransport.send(SmbTransport.java:663) 
at jcifs.smb.SmbSession.send(SmbSession.java:238) 
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:176) 
at jcifs.smb.SmbFile.doConnect(SmbFile.java:911) 
at jcifs.smb.SmbFile.connect(SmbFile.java:954) 
at jcifs.smb.SmbFile.connect0(SmbFile.java:880) 
at jcifs.smb.SmbFile.resolveDfs(SmbFile.java:669) 
at jcifs.smb.SmbFile.send(SmbFile.java:773) 
at jcifs.smb.SmbFile.doFindFirstNext(SmbFile.java:1986) 
at jcifs.smb.SmbFile.doEnum(SmbFile.java:1738) 
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1715) 
at jcifs.smb.SmbFile.listFiles(SmbFile.java:1648) 
at org.apacheextras.camel.component.jcifs.DefaultSmbClient.listFiles(DefaultSmbClient.java:161) 
at org.apacheextras.camel.component.jcifs.SmbOperations.listFiles(SmbOperations.java:341) 
... 11 more 

注1:我在我的電腦配置Samba服務器,並我正在共享一個包含四個文件的簡單文件夾。

注2:我使用本地主機,只是爲了測試。我得到這個工作後,我將使用另一臺機器IP /域。

謝謝你的幫助!

回答

0

我只是讓它工作。我的路線錯了。它應該是這樣的:

package abc; 

import org.apache.camel.builder.RouteBuilder; 

public class MyRouteBuilder extends RouteBuilder { 

    public void configure() { 
     long delay = 60 * 60 * 1000L; 
     from("smb://[email protected]/folder?password=secret&delay=" + delay) 
     .to("file://home/otherUser/folder"); 
    } 
} 

我發現我的錯誤在終端上執行以下命令:

smbclient -L localhost 

該命令給我的共享名是我的共享文件夾「文件夾」。