org.apache.camel.component.file.GenericFileOperationFailedException:无法获取文件无法找到网络名称

时间:2016-05-10 17:48:05

标签: java apache-camel jcifs

我尝试将一些文件从本地文件夹复制到另一个使用Apache Camel JCIFS组件的本地文件夹。

这是我的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://otherUser@localhost/WORKGROUP/home/user/folder?password=secret&delay=" + delay)
        .to("file://home/otherUser/folder");

    // This doesn't work either:
    //from("smb://localhost;otherUser@localhost/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:我使用localhost,只是为了测试。在我开始工作之后,我将使用另一台机器IP /域。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我刚刚开始工作。我的路线错了。它应该是这样的:

package abc;

import org.apache.camel.builder.RouteBuilder;

public class MyRouteBuilder extends RouteBuilder {

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

我注意到我在终端上执行以下命令时出现错误:

smbclient -L localhost

该命令告诉我Sharename是我的共享文件夹"文件夹"。