[
https://issues.apache.org/jira/browse/VFS-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13904826#comment-13904826
]
Jon Storch commented on VFS-340:
--------------------------------
Hello. I should have been clearer.
I didn't make a code change, the solution is to Url encode the username and
password before calling resolveFile();
So if you need to call something like:
manager.resolveFile("sftp://sftpuser@Location:Test!@#$%^&*()[]:;@US456564/home57556");
Where the username is "sftpuser@Location" and the password is "Test!@#$%^&*[]:;:
you encode just the username and password and call it like:
manager.resolveFile("sftp://sftpuser%40Location:Test!%40%23%24%25%5E%26*%5B%5D%3A%3B@US456564/home57556");
It might look a bit messy as a Sting but in the calling code there isn't much
of a problem.
Does this make sense?
Thanks.
> FileSystemException: Badly formed URI
> --------------------------------------
>
> Key: VFS-340
> URL: https://issues.apache.org/jira/browse/VFS-340
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 1.0
> Environment: windows XP, JDK1.5
> Reporter: bharani
> Original Estimate: 96h
> Remaining Estimate: 96h
>
> I am trying to connect to SFTP using commons.vfs . The program is running
> fine initially by connecting to SFTP and retrieving files ,but after one
> point of time it throws following exception repeatedly and refuses to connect
> thereafter.
> FileSystemException: Badly formed URI
> "sftp://sftpuser:XXXXXXXX@US456564/home57556/".
> at
> org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:58)
> at
> org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:641)
> at
> org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:582)
> at
> com.java.workflow.trigger.BaseTask.establishConnection(BaseTask.java:167)
> at
> com.java.workflow.trigger.sftp.sampleconnect.getSource2System(sampleconnect.java:11)
> at com.java.workflow.trigger.sftp.samplecnt.perform(samplecnt.java:27)
> at com.java.workflow.trigger.BaseTask.execute(BaseTask.java:127)
> at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
> at
> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
> Caused by: org.apache.commons.vfs.FileSystemException: Port number is missing
> from URI "sftp://sftpuser:XXXXXXXX@US456564/home57556/".
> at
> org.apache.commons.vfs.provider.HostFileNameParser.extractPort(HostFileNameParser.java:229)
> at
> org.apache.commons.vfs.provider.HostFileNameParser.extractToPath(HostFileNameParser.java:134)
> at
> org.apache.commons.vfs.provider.URLFileNameParser.parseUri(URLFileNameParser.java:48)
> at
> org.apache.commons.vfs.provider.AbstractFileProvider.parseUri(AbstractFileProvider.java:170)
> at
> org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:54)
> ... 8 more
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)