2

こんにちは、SMB プロトコルに接続するためのテスト プログラムを作成しました。私の動機は、次のような共有場所に test.txt ファイルを作成することですString path="smb://192.168.143.134/rtf2xml/"+sharedFolder+"/test.txt";

しかし、プログラムを実行しようとすると(以下はコードサンプルです)

import java.io.IOException;

import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;


public class Test {

    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException {
        String user = "abc";
        String pass ="123456";

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

}

例外をスローしています

Exception in thread "main" jcifs.smb.SmbException: Failed to negotiate
jcifs.smb.SmbException: Timeout trying to open socket
java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at jcifs.netbios.NbtSocket.<init>(NbtSocket.java:59)
    at jcifs.smb.SmbTransport.run(SmbTransport.java:342)
    at java.lang.Thread.run(Unknown Source)

    at jcifs.smb.SmbTransport.start(SmbTransport.java:315)
    at jcifs.smb.SmbTransport.negotiate0(SmbTransport.java:865)
    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:941)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:119)
    at jcifs.smb.SmbFile.connect(SmbFile.java:827)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:797)
    at jcifs.smb.SmbFile.open0(SmbFile.java:852)
    at jcifs.smb.SmbFile.createNewFile(SmbFile.java:2265)
    at Test.main(Test.java:22)

    at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:947)
    at jcifs.smb.SmbTree.treeConnect(SmbTree.java:119)
    at jcifs.smb.SmbFile.connect(SmbFile.java:827)
    at jcifs.smb.SmbFile.connect0(SmbFile.java:797)
    at jcifs.smb.SmbFile.open0(SmbFile.java:852)
    at jcifs.smb.SmbFile.createNewFile(SmbFile.java:2265)
    at Test.main(Test.java:22)

これを取り除く方法は?

4

1 に答える 1