Java jcifs.smb.SmbException:找不到网络名称

Java jcifs.smb.SmbException:找不到网络名称,java,web-applications,smb,Java,Web Applications,Smb,下面是我的一段代码 SmbFile catalExp = new SmbFile("smb://<Shared machine name>/Project share/Home/4. Folders/planning - Design & Exec/sample.txt", new NtlmPasswordAuthentication(LoadProp.getShrdDomain(),"user","paswd")); 这与该特定共

下面是我的一段代码

SmbFile catalExp = new SmbFile("smb://<Shared machine name>/Project share/Home/4.  Folders/planning - Design & Exec/sample.txt",
                    new NtlmPasswordAuthentication(LoadProp.getShrdDomain(),"user","paswd"));
这与该特定共享文件夹的用户权限有关,还是我做错了什么
请注意,我也遇到了这个错误,但只有一台设备出现了这个错误,我在安卓4.04上的代码是

 String strprog = "STRING CREATED| "; //debug log string
    try {
        strprog += "NTLM| ";
        NtlmPasswordAuthentication auth =  new NtlmPasswordAuthentication("username:password");
        strprog += "SMB| ";
        SmbFile file = new SmbFile("smb://<pcname>/foldername/filename.txt",auth);

        strprog += "EXIST| ";
        String there = String.valueOf(file.exists());

        strprog += "View| ";
        TextView pp;
        pp = (TextView) findViewById(R.id.tv);
        pp.setText(there);



    } catch (Exception e) {
        // TODO Auto-generated catch block
        strprog += "ERROR! ";
        TextView ll;
        ll = (TextView) findViewById(R.id.tv);


        ll.setText(strprog + e.getStackTrace().toString() + "    " +  e.getMessage() + "   " + e.getLocalizedMessage() );
    }
String strprog=“String CREATED |”//调试日志字符串
试一试{
strprog+=“NTLM |”;
NtlmPasswordAuthentication auth=新的NtlmPasswordAuthentication(“用户名:密码”);
strprog+=“SMB |”;
SmbFile file=新SmbFile(“smb:///foldername/filename.txt“,auth);
strprog+=“存在|”;
String there=String.valueOf(file.exists());
strprog+=“视图|”;
文本视图pp;
pp=(TextView)findViewById(R.id.tv);
pp.setText(在那里);
}捕获(例外e){
//TODO自动生成的捕捉块
strprog+=“错误!”;
TextView-ll;
ll=(TextView)findViewById(R.id.tv);
ll.setText(strprog+e.getStackTrace().toString()+“”+e.getMessage()+“”+e.getLocalizedMessage());
}
我看到的唯一区别是,与我的相比,你的
NtlmPasswordAuth
在哪里。
但正如我所说的,由于某种原因,当我深入到andriod2.0时,它会抛出空输入
param
smb://host 但是我希望这能帮到你。

我遇到了这个错误消息,结果发现问题是我的网络路径不正确。您需要确保正确配置了
NtlmPasswordAuthentication
对象,网络路径正确,并且正确设置了jcifs.netbios.wins属性,如第一个示例所示

例如,要加载远程属性文件:

final NtlmPasswordAuthentication AUTH = new NtlmPasswordAuthentication("domainname", "username", "password");

Config.setProperty("jcifs.netbios.wins", "10.10.1.1");

Properties props = new Properties();
InputStream in = new SmbFileInputStream(new SmbFile("smb://10.10.1.1:445/rootfolder/path/filename.properties", AUTH));
props.load(in);
(您需要添加try/catch和输入流关闭)

确保所有参数正确的一个好方法是使用smb/cifs客户端测试登录和定位文件。例如,linux/unix上的smbclient:

smbclient -Uusername -p 139 //10.10.1.1/rootfolder
使用smbclient登录时,域显示在顶部:

Domain=[DOMAINNAME]

..您可以导航到您的文件,以确保路径正确。

我遇到了这个问题,结果我没有看到映射到Windows共享驱动器的共享名是什么。。。因此,使用Mac OS,我运行:

smbutil视图smb://MYUSERNAME@主机名

在提示我输入密码后,我看到了一个共享名列表(当我使用Windows查看这些内容时,这些名称并不明显)。一旦找到我的共享名,在连接JCIFS时使用它就很简单:


新建SMB文件(“smb://HOSTNAME/SHARENAME/path/I/was/trying/to/access“,auth)

在遇到这个问题将近一天后,我意识到这些异常毫无意义

  • 我只是给出了错误的服务器端位置路径
下面是为我工作的groovy代码

        String domain = "domain"
        String user = "username"
        String pass = "password"
        String IP = "xx.yy.zz.aa"
        String sharedFolder="//my//path//to//server//";

    String path="smb://$IP"+sharedFolder+"test.txt";
    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, user, pass );
    SmbFile smbFile = new SmbFile(path,auth);
    SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile);
    smbfos.write("testing....and writing to a file".getBytes());
    System.out.println("completed ...nice !");

#詹姆斯:共享名是什么意思?这是不是像当你将某个东西配置为共享时,你会提供一个必须共享它的名称?这对我来说也很有效,并且帮我省去了太多的麻烦!谢谢和+1@Sundhar-当您运行此命令时,您将清楚地看到:您将通过
smb://
获得远程服务器上所有可用共享(目录)的打印输出。
        String domain = "domain"
        String user = "username"
        String pass = "password"
        String IP = "xx.yy.zz.aa"
        String sharedFolder="//my//path//to//server//";

    String path="smb://$IP"+sharedFolder+"test.txt";
    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(domain, user, pass );
    SmbFile smbFile = new SmbFile(path,auth);
    SmbFileOutputStream smbfos = new SmbFileOutputStream(smbFile);
    smbfos.write("testing....and writing to a file".getBytes());
    System.out.println("completed ...nice !");