commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Tanaka <Ken.Tan...@noaa.gov>
Subject Re: [VFS] problem on runtime connection to SFTp server
Date Thu, 05 Nov 2009 18:05:17 GMT
If you need to call release() (and reinitialize) between processing operations I recommend
you use a release method like this:

    public void release() {
        FileSystem fs = null;

        fs = this.src.getFileSystem(); // This works even if the src is closed.
        this.fsManager.closeFileSystem(fs);
    }

In order for this release() to work, your class will need to have a

    private FileObject src = null; // used for cleanup in release()

and some time after setting 

    children = this.sftpFile.getChildren();

you should 

    // Set src for cleanup in release()

    src = children[0];

There is an example in the wiki at 
http://wiki.apache.org/jakarta-commons/SimpleSftpFileDownload

tlc wrote:
> I have similar problem.  The call to 'resolveFile' failed with 'Unknown
> scheme "sftp"' error on the second operation.  I found couple things:
>
> 1) URL is of form sftp://user:pass@host/remotepath/ does not work on Tomcat. 
> I had to change to using the below to authenticate:
> StaticUserAuthenticator auth = new StaticUserAuthenticator(null, "username",
> "password");
> DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts,
> auth);
>
> 2) fsManager.close() between operations causes the error.  You need to
> remove this and close it only once when the whole process completes.
>
>
> lmk wrote:
>   
>> It seems that the problem comes from release function, when I call It
>> after  copying files, the second SFTP connection fail.
>>
>> here the release method code:
>>
>> public void release() {
>> 		this.fsManager.close();
>>
>> 	} // release()
>>
>>
>>
>> lmk wrote:
>>     
>>> I have
>>>  commons-net-2.0
>>> commons-vfs-1.0
>>> jsch-0.1.40
>>>
>>>
>>> the first call works..but the second  one does not.
>>>
>>>
>>>
>>>
>>> Jörg Schaible-2 wrote:
>>>       
>>>> lmk wrote at Dienstag, 24. März 2009 14:58:
>>>>
>>>>         
>>>>> Hi Sergey,
>>>>>
>>>>> here the exception trace
>>>>>
>>>>> org.apache.commons.vfs.FileSystemException: Unknown scheme "sftp" in
>>>>> URI
>>>>> "sftp://login:password@host/path/".
>>>>>           
>>>> This is an error message, but not a stack trace. However, it seems that
>>>> you
>>>> do not have commons-net and jsch in your deps ...
>>>>
>>>> - Jörg
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>>> For additional commands, e-mail: user-help@commons.apache.org
>>>>
>>>>
>>>>
>>>>         
>>>       
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message