[
https://issues.apache.org/jira/browse/VFS-454?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13573446#comment-13573446
]
MH edited comment on VFS-454 at 2/7/13 3:28 PM:
------------------------------------------------
Forgot to note that this SFTP connection is established with a key:
-- code start ---
final SftpFileSystemConfigBuilder cb =
SftpFileSystemConfigBuilder.getInstance();
cb.setStrictHostKeyChecking(opts, "no"); //don't check, if host is in
$HOME/.ssh/known_hosts
if (fileKey != null) {
cb.setIdentities(opts, new File[]{fileKey}); //set private key
}//else: DO NOT ADD null VALUES IN Identities! (or you'll get " Could not
connect to SFTP server" errors!)
--- code end ---
I tried many close() calls without success:
--- code start ---
if (vfs != null) {
try {
LOGGER.info("--- clean up VFS --- 4");
if (dirRoot != null) {
dirRoot.close();
vfs.closeFileSystem(dirRoot.getFileSystem());
((StandardFileSystemManager)
vfs).closeFileSystem(dirRoot.getFileSystem());
}
((StandardFileSystemManager) vfs).close();
((DefaultFileSystemManager) vfs).close();
vfs.getFilesCache().close();
} catch (final Exception e) {
LOGGER.warning("Can't close SFTP root: "+e);
}
}
--- code end ---
was (Author: mhilpert):
Forgot to note that this SFTP connection is established with a key:
final SftpFileSystemConfigBuilder cb =
SftpFileSystemConfigBuilder.getInstance();
cb.setStrictHostKeyChecking(opts, "no"); //don't check, if host is in
$HOME/.ssh/known_hosts
if (fileKey != null) {
cb.setIdentities(opts, new File[]{fileKey}); //set private key
}//else: DO NOT ADD null VALUES IN Identities! (or you'll get " Could not
connect to SFTP server" errors!)
I tried many close() calls without success:
if (vfs != null) {
try {
LOGGER.info("--- clean up VFS --- 4");
if (dirRoot != null) {
dirRoot.close();
vfs.closeFileSystem(dirRoot.getFileSystem());
((StandardFileSystemManager)
vfs).closeFileSystem(dirRoot.getFileSystem());
}
((StandardFileSystemManager) vfs).close();
((DefaultFileSystemManager) vfs).close();
vfs.getFilesCache().close();
} catch (final Exception e) {
LOGGER.warning("Can't close SFTP root: "+e);
}
}
> SFTP: first access OK, second access: Unknown scheme "sftp" in URI
> "sftp://..."
> -------------------------------------------------------------------------------
>
> Key: VFS-454
> URL: https://issues.apache.org/jira/browse/VFS-454
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0
> Environment: Java 1.7.0_13 64 Bit
> Reporter: MH
> Priority: Critical
>
> I access files from an SFTP server and accesm them roughly via
> -----------------
> vfs.resolveFile(uri, opts);
> ...
> vfs.resolveFile(cwd, directory);
> ...
> cwd.getChildren();
> ...
> vfs.resolveFile(fn);
> ...
> ((DefaultFileSystemManager) vfs).close();
> --------------------------
> If the same code runs a second time, the first call to resolveFile() throws
> Unknown scheme "sftp" in URI "sftp://..."
> I tried
> vfs.closeFileSystem(children[0].getFileSystem());
> like stated in http://wiki.apache.org/commons/SimpleSftpFileDownload, but
> this doesn't help!
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira