You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ralph Goers (JIRA)" <ji...@apache.org> on 2009/11/08 17:48:32 UTC

[jira] Commented: (VFS-251) Cannot read relative file URL

    [ https://issues.apache.org/jira/browse/VFS-251?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12774796#action_12774796 ] 

Ralph Goers commented on VFS-251:
---------------------------------

Have you tried this anywhere besides Windows? Running your test on my Mac fails with

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.237 sec <<< FAILURE!
testJavaNetURL(org.apache.commons.vfs.test.VfsRelativePathTestCase)  Time elapsed: 0.007 sec  <<< ERROR!
java.io.FileNotFoundException: vfs-test/hello.txt (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
        at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
        at java.net.URL.openStream(URL.java:1010)
        at org.apache.commons.vfs.test.VfsRelativePathTestCase.testJavaNetURL(VfsRelativePathTestCase.java:46)

testVfs(org.apache.commons.vfs.test.VfsRelativePathTestCase)  Time elapsed: 0.188 sec  <<< ERROR!
org.apache.commons.vfs.FileSystemException: Invalid absolute URI "file:vfs-test/hello.txt".
        at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:62)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:692)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:648)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:604)
        at org.apache.commons.vfs.test.VfsRelativePathTestCase.testVfs(VfsRelativePathTestCase.java:56)
Caused by: org.apache.commons.vfs.FileSystemException: URI "file:vfs-test/hello.txt" is not an absolute file name.
        at org.apache.commons.vfs.provider.local.GenericFileNameParser.extractRootPrefix(GenericFileNameParser.java:56)
        at org.apache.commons.vfs.provider.local.LocalFileNameParser.parseUri(LocalFileNameParser.java:78)
        at org.apache.commons.vfs.provider.AbstractFileProvider.parseUri(AbstractFileProvider.java:188)
        at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:58)
        ... 30 more

I don't believe file:vfs-test/hello.txt is a valid url. Changing it to file://vfs-test/hello.txt results in 

Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.309 sec <<< FAILURE!
testJavaNetURL(org.apache.commons.vfs.test.VfsRelativePathTestCase)  Time elapsed: 0.065 sec  <<< ERROR!
java.net.UnknownHostException: vfs-test
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
        at java.net.Socket.connect(Socket.java:525)
        at java.net.Socket.connect(Socket.java:475)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
        at sun.net.NetworkClient.openServer(NetworkClient.java:118)
        at sun.net.ftp.FtpClient.openServer(FtpClient.java:488)
        at sun.net.ftp.FtpClient.openServer(FtpClient.java:475)
        at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:270)
        at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:352)
        at java.net.URL.openStream(URL.java:1010)
        at org.apache.commons.vfs.test.VfsRelativePathTestCase.testJavaNetURL(VfsRelativePathTestCase.java:46)

So in this case it appears to work with resolveFile but not with java.net.URL.

I tried Sergey's suggestion of using "vfs-test/hello.txt" but that failed with

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.231 sec <<< FAILURE!
testJavaNetURL(org.apache.commons.vfs.test.VfsRelativePathTestCase)  Time elapsed: 0.007 sec  <<< ERROR!
java.net.MalformedURLException: no protocol: vfs-test/hello.txt
        at java.net.URL.<init>(URL.java:567)
        at java.net.URL.<init>(URL.java:464)
        at java.net.URL.<init>(URL.java:413)
        at org.apache.commons.vfs.test.VfsRelativePathTestCase.testJavaNetURL(VfsRelativePathTestCase.java:46)

testVfs(org.apache.commons.vfs.test.VfsRelativePathTestCase)  Time elapsed: 0.186 sec  <<< ERROR!
org.apache.commons.vfs.FileSystemException: Could not find file with URI "vfs-test/hello.txt" because it is a relative path, and no base URI was provided.
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:718)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:648)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:604)
        at org.apache.commons.vfs.test.VfsRelativePathTestCase.testVfs(VfsRelativePathTestCase.java:56)

In all the places I've used relative paths I have always provided a base path and the error above does not occur.

Let me know what you would like to do with this.


> Cannot read relative file URL
> -----------------------------
>
>                 Key: VFS-251
>                 URL: https://issues.apache.org/jira/browse/VFS-251
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 1.0, Nightly Builds
>         Environment: java version "1.6.0_12"
> Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
> Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)
> Windows XP SP3
>            Reporter: Gary Gregory
>         Attachments: VfsRelativePathTestCase.java
>
>
> While the documentation talks about absolute path URLs for the file:// scheme, using relative URLs is a requirement for us. For now I've hacked around it in our server. Please see the attached unit test for an illustration.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.