You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Delli Paoli Laura <l....@reply.it> on 2012/06/11 12:01:36 UTC

How to resolve a share path to a FileObject

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<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

[Discovery]
Via del Giorgione, 59
00147 - Roma - ITALY
phone: +39 06 844341
l.dellipaoli@reply.it
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.

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

Posted by ldp <l....@reply.it>.
[Do you have all of the dependencies you need?]  *My classpath is:
<?xml version="1.0" encoding="UTF-8"?>

       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
*

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


--
View this message in context: http://apache-commons.680414.n4.nabble.com/How-to-resolve-a-share-path-to-a-FileObject-tp4634909p4634919.html
Sent from the Commons - User mailing list archive at Nabble.com.

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

Posted by ldp <l....@reply.it>.
I solved this issue.
I had to download the VFS Sabdbox from SVN and recompile it!

--
View this message in context: http://apache-commons.680414.n4.nabble.com/How-to-resolve-a-share-path-to-a-FileObject-tp4634909p4634967.html
Sent from the Commons - User mailing list archive at Nabble.com.

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


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

Posted by ldp <l....@reply.it>.
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://Administrator:***@10.21.20.21/e/Varie/WinXP_key.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

--
View this message in context: http://apache-commons.680414.n4.nabble.com/How-to-resolve-a-share-path-to-a-FileObject-tp4634909p4634920.html
Sent from the Commons - User mailing list archive at Nabble.com.

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


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

Posted by James Carman <ja...@carmanconsulting.com>.
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 <l....@reply.it> 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: 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


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

Posted by ldp <l....@reply.it>.
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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


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

Posted by Indudhar Devanath <in...@gmail.com>.
>
> 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