How to resolve a share path to a FileObject

classic Classic list List threaded Threaded
8 messages Options
ldp
Reply | Threaded
Open this post in threaded view
|

How to resolve a share path to a FileObject

ldp
This post has NOT been accepted by the mailing list yet.
Hello everybody!
I'm trying to use VFS2 to copy a file from a remote path to a local folder.
If I run
FileObject srcFile = fsManager.resolveFile(//+hostname+"/"+filename);
localFile.getName().getURI() returns something like file:////path
and srcFile.exists() returns false.
On the othe hand
FileObject srcFile = fsManager.resolveFile("smb://"+user+":"+pw+"@"+hostname+"/"+filename);
fails with the following exception:
Badly formed URI "smb://user:***@hostname/filename"

Can anyone help me??
How can I resolve a share path to a FileObject??
thanks
Laura
ldp
Reply | Threaded
Open this post in threaded view
|

How to resolve a share path to a FileObject

ldp

Hello everybody!

I'm trying to use VFS2 to copy a file from a remote path to a local folder.

If I run

FileObject srcFile = fsManager.resolveFile(//+hostname+"/"+filename);

localFile.getName().getURI() returns something like <a href="file:///\\path">file:////path and srcFile.exists() returns false.

On the othe hand

FileObject srcFile =

fsManager.resolveFile("smb://"+user+":"+pw+"@"+hostname+"/"+filename);

fails with the following exception:

Badly formed URI "smb://user:***@hostname/filename"

 

Can anyone help me??

How can I resolve a share path to a FileObject??

thanks

Laura



Laura Delli Paoli


Via del Giorgione, 59
00147 - Roma - ITALY
phone: +39 06 844341
l.dellipaoli@...
www.reply.it

 




--
The information transmitted is intended for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Reply | Threaded
Open this post in threaded view
|

Re: [vfs] How to resolve a share path to a FileObject

Indudhar Devanath
>
> I'm trying to use VFS2 to copy a file from a remote path to a local folder.
>
> If I run
>
> FileObject srcFile = fsManager.resolveFile(//+hostname+"/"+filename);
>
> localFile.getName().getURI() returns something like file:////path and
> srcFile.exists() returns false.
>
> On the othe hand
>
> FileObject srcFile =
>
> fsManager.resolveFile("smb://"+user+":"+pw+"@"+hostname+"/"+filename);
>
> fails with the following exception:
>
> Badly formed URI "smb://user:***@hostname/filename"
>

Did you try checking if you can access the file with URI
"smb://user:***@hostname/filename"
There are chances that this URI might indeed be badly formed.

Also try this:
String srcURI = "smb://"+user+":"+pw+"@"+hostname+"/"+filename;
FileObject srcFile = fsManager.resolveFile(srcURI, new FileSystemOptions());

Indu
ldp
Reply | Threaded
Open this post in threaded view
|

Re: [vfs] How to resolve a share path to a FileObject

ldp
I get the same error
Reply | Threaded
Open this post in threaded view
|

Re: [vfs] How to resolve a share path to a FileObject

James Carman
Do you have all of the dependencies you need?  Turn up logging to see
what providers VFS is loading.  In trunk it looks like the SMB stuff
is in the sandbox.  It requires JCIFS, it looks like.  Do you have
that?

On Mon, Jun 11, 2012 at 8:28 AM, ldp <[hidden email]> wrote:

> I get the same error
>
> --
> View this message in context: http://apache-commons.680414.n4.nabble.com/How-to-resolve-a-share-path-to-a-FileObject-tp4634909p4634915.html
> Sent from the Commons - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

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

ldp
Reply | Threaded
Open this post in threaded view
|

Re: [vfs] How to resolve a share path to a FileObject

ldp
[Do you have all of the dependencies you need?] My classpath is: Turn up logging to see what providers VFS is loading. How can I do this? In trunk it looks like the SMB stuff is in the sandbox. It requires JCIFS, it looks like. Do you have that? yes The full error trace is: org.apache.commons.vfs2.FileSystemException: Badly formed URI "smb://usr:***@hostname/filename". at org.apache.commons.vfs2.provider.url.UrlFileProvider.findFile(UrlFileProvider.java:91) at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:713) at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:621) at FileTransfer.copyFileUsingVFS(FileTransfer.java:97) at FileTransfer.main(FileTransfer.java:67) Caused by: java.net.MalformedURLException: unknown protocol: smb at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at java.net.URL.(Unknown Source) at org.apache.commons.vfs2.provider.url.UrlFileProvider.findFile(UrlFileProvider.java:72) ... 4 more
ldp
Reply | Threaded
Open this post in threaded view
|

Re: [vfs] How to resolve a share path to a FileObject

ldp
This post was updated on .
In reply to this post by James Carman
Do you have all of the dependencies you need?  
My classpath is:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
        <classpathentry kind="lib" path="lib/commons-collections-3.1.jar"/>
        <classpathentry kind="lib" path="lib/commons-httpclient-3.0.jar"/>
        <classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
        <classpathentry kind="lib" path="lib/commons-net-2.0.0.jar"/>
        <classpathentry kind="lib" path="lib/commons-net-ftp-2.0.0.jar"/>
        <classpathentry kind="lib" path="lib/jcifs-1.1.11.jar"/>
        <classpathentry kind="lib" path="lib/jsch-0.1.48.jar"/>
        <classpathentry kind="lib" path="mail/dsn.jar"/>
        <classpathentry kind="lib" path="mail/imap.jar"/>
        <classpathentry kind="lib" path="mail/mail.jar"/>
        <classpathentry kind="lib" path="mail/mailapi.jar"/>
        <classpathentry kind="lib" path="mail/pop3.jar"/>
        <classpathentry kind="lib" path="mail/smtp.jar"/>
        <classpathentry kind="lib" path="lib/commons-vfs2-2.0.jar"/>
        <classpathentry kind="lib" path="lib/commons-vfs2-2.0-sources.jar"/>
        <classpathentry kind="lib" path="lib/jackrabbit-standalone-2.5.0.jar"/>
        <classpathentry kind="output" path="bin"/>
</classpath>


Turn up logging to see what providers VFS is loading.  How can I do this?
 

org.apache.commons.vfs2.FileSystemException: Badly formed URI "smb://usr:***@host/filename.txt".
        at org.apache.commons.vfs2.provider.url.UrlFileProvider.findFile(UrlFileProvider.java:91)
        at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:713)
        at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:621)
        at FileTransfer.copyFileUsingVFS(FileTransfer.java:97)
        at FileTransfer.main(FileTransfer.java:67)
Caused by: java.net.MalformedURLException: unknown protocol: smb
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at java.net.URL.<init>(Unknown Source)
        at org.apache.commons.vfs2.provider.url.UrlFileProvider.findFile(UrlFileProvider.java:72)
        ... 4 more
ldp
Reply | Threaded
Open this post in threaded view
|

Re: [vfs] How to resolve a share path to a FileObject

ldp
I solved this issue.
I had to download the VFS Sabdbox from SVN and recompile it!