commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Poppe, Troy" <>
Subject RE: [io/configuration] file:// URL problem
Date Thu, 09 Jun 2005 20:27:06 GMT

It appears that my problem stems not from io or configuration, but instead from

I grabbed the latest VFS from SVN, and dug through it a bit, and I think there
might be a bug in org.apache.commons.vfs.provider.local.LocalFileName.

Currently the code reads:
     * Builds the root URI for this file name.
    protected void appendRootUri(final StringBuffer buffer)

However, for file URLs, it appears that the JVM wants to see them as "file:/" or

Is this a fix that would be acceptable?  (I'm not able to verify if this is a JVM
'bug' or a conflict with RFC2396.)  Is there another work around?

Troy Poppe

-----Original Message-----
From: Poppe, Troy [] 
Sent: Thursday, June 09, 2005 3:46 PM
To: ''
Subject: [io/configuration] file:// URL problem

I'm running on a 1.4.2 JVM, commons-io 1.0, commons-configuration 1.1.

I've got a set of FileObjects, and on each I call getURL(), they return URLs that
point to valid files and look like the following:


Now, if I try to open these with Windows directly, this works fine.  However, if
I try to pass each of these URLs to the XMLConfiguration constructor, an
exception like the following is thrown:

org.apache.commons.configuration.ConfigurationException: Cannot locate
configuration source oecdde.xml
	at URLBuster.main(
Exception in thread "main" 

It appears that the problem originates from
            URL url = ConfigurationUtils.locate(basePath, fileName);

In locate(String base, String name), it attempts to construct a URL to the file
by constructing a baseURL, and then using this as a 'context' onto which the
fileName is to be added.  The problem crops up here:

                URL baseURL = new URL(base);
                url = new URL(baseURL, name);

Prior to this point, the URLs that had been used did not refer to a 'host', and
were local to the JVM's execution.  At this point, baseURL refers to a host named

Any fixes for this?


Here's the sample code:


import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.vfs.FileFilter;
import org.apache.commons.vfs.FileFilterSelector;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSelectInfo;
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.VFS;

public class URLBuster

    public static void main(String[] args)
    	throws Exception
        FileSystemManager fsManager = VFS.getManager();
        FileObject inputDir = fsManager.resolveFile( new File("."), "conf/input/"
        FileFilterSelector ffs = new FileFilterSelector(new FileFilter()
            public boolean accept(FileSelectInfo fsi)
                if ( "xml".equals(fsi.getFile().getName().getExtension()) )
                    return true;
                    return false;
        FileObject[] children = inputDir.findFiles(ffs);

        for ( int i = 0 ; i < children.length ; ++i )
            FileObject fo = children[i];
            Configuration config = config = new XMLConfiguration(fo.getURL());


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message