Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 71510 invoked from network); 9 Jun 2005 20:30:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jun 2005 20:30:51 -0000 Received: (qmail 48301 invoked by uid 500); 9 Jun 2005 20:30:43 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 48269 invoked by uid 500); 9 Jun 2005 20:30:42 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 48254 invoked by uid 99); 9 Jun 2005 20:30:42 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from hqmms4.hr.doe.gov (HELO hqwss.hr.doe.gov) (205.254.132.8) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 09 Jun 2005 13:30:38 -0700 Received: from 198.76.0.16 by hqwss.hr.doe.gov with SMTP (US Dept of Energy SMTP Relay (MMS v5.6.3)); Thu, 09 Jun 2005 16:31:39 -0400 X-Server-Uuid: 366EAC35-9A62-4FA1-94DD-815DE286956F Received: by scout.eia.doe.gov with Internet Mail Service (5.5.2657.72) id ; Thu, 9 Jun 2005 16:30:05 -0400 Message-ID: <5C8AD2C845ED3E43AEF65E40FC02A8BD07BC3D00@emailf2.eia.doe.gov> From: "Poppe, Troy" To: "'Jakarta Commons Users List'" Subject: RE: [io/configuration] file:// URL problem Date: Thu, 9 Jun 2005 16:27:06 -0400 X-Mailer: Internet Mail Service (5.5.2657.72) MIME-Version: 1.0 X-WSS-ID: 6EB678A10Y4370302-01-01 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N It appears that my problem stems not from io or configuration, but instead from VFS! 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) { buffer.append(getScheme()); buffer.append("://"); buffer.append(rootFile); } However, for file URLs, it appears that the JVM wants to see them as "file:/" or "file:///"... 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 [mailto:Troy.Poppe@eia.doe.gov] Sent: Thursday, June 09, 2005 3:46 PM To: 'commons-user@jakarta.apache.org' 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: file://c:/projects/IPDB/conf/input/oecdde.xml 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 org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfi guration.java:183) at org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfi guration.java:166) at org.apache.commons.configuration.XMLConfiguration.load(XMLConfiguration.java:348) at org.apache.commons.configuration.XMLConfiguration.(XMLConfiguration.java:13 4) at URLBuster.main(URLBuster.java:56) Exception in thread "main" It appears that the problem originates from AbstractFileConfiguration.java:180: 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 'c'! Any fixes for this? Troy Here's the sample code: import java.io.File; 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; } else { return false; } } }); FileObject[] children = inputDir.findFiles(ffs); for ( int i = 0 ; i < children.length ; ++i ) { FileObject fo = children[i]; System.out.println(fo); Configuration config = config = new XMLConfiguration(fo.getURL()); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org