[ 
https://issues.apache.org/jira/browse/SSHD-1238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17480860#comment-17480860
 ] 

Guillaume Nodet commented on SSHD-1238:
---------------------------------------

The exception thrown indicates that the FileSystem was not found.  Indeed, the 
call to \{{java.nio.file.Paths.get}} will not automatically create the {{SFTP}} 
filesystem, and you need to explicitely create it using a call to 
{{FileSystems.newFileSystem}}.

The following will work:
{code:java}

URI uri = SftpFileSystemProvider.createFileSystemURI("127.0.0.1", port, 
"deneme", "deneme");
try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.<String, 
Object>emptyMap())) {
    Path sourceFile = Paths.get(new URI("sftp://deneme:[email protected]:"; + 
port + "/C:/Users/XXX/Desktop/sil/sftp/sil.txt"));
}
 {code}

> java.nio.file.FileSystemNotFoundException by 
> SftpFileSystemProvider.getFileSystem
> ---------------------------------------------------------------------------------
>
>                 Key: SSHD-1238
>                 URL: https://issues.apache.org/jira/browse/SSHD-1238
>             Project: MINA SSHD
>          Issue Type: Request
>    Affects Versions: 2.8.0
>         Environment: Java SE 8, Apache NetBeans IDE 12.5
>            Reporter: dgü
>            Priority: Major
>
> Hello!
> The following code runs successfully:
> {noformat}
>     public static void main(String[] args) throws IOException  {
>         URI uri = SftpFileSystemProvider.createFileSystemURI("127.0.0.1", 22, 
> "deneme", "deneme123");
>         try (FileSystem fs = FileSystems.newFileSystem(uri, 
> Collections.<String, Object>emptyMap())) {
>             Path localPath = 
> fs.getPath("C:/Users/XXX/Desktop/sil/sftp/sil1.txt");
>             Path targetPath = 
> fs.getPath("C:/Users/XXX/Desktop/sil/sftp/sil2.txt");
>             Files.copy(localPath, targetPath, 
> StandardCopyOption.REPLACE_EXISTING);
>         }
>     }
> {noformat}
> The following code fails:
> {noformat}
>     public static void main(String[] args) throws URISyntaxException  {
>         Path sourceFile = Paths.get(new 
> URI("sftp://deneme:[email protected]/C:/Users/XXX/Desktop/sil/sftp/sil.txt";));
>     }
> {noformat}
> The exeption is:
> {noformat}
> Exception in thread "main" java.nio.file.FileSystemNotFoundException: 
> 127.0.0.1:22:deneme
>       at 
> org.apache.sshd.sftp.client.fs.SftpFileSystemProvider.getFileSystem(SftpFileSystemProvider.java:451)
>       at 
> org.apache.sshd.sftp.client.fs.SftpFileSystemProvider.getPath(SftpFileSystemProvider.java:492)
>       at java.nio.file.Paths.get(Paths.java:143)
>       at com.ubtools.ubutils.UBTest.main(UBTest.java:30)
> {noformat}
>  
> How can I solve this problem ?
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to