Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 49131 invoked from network); 16 Aug 2004 22:08:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Aug 2004 22:08:10 -0000 Received: (qmail 59021 invoked by uid 500); 16 Aug 2004 22:08:07 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 58881 invoked by uid 500); 16 Aug 2004 22:08:06 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 58868 invoked by uid 99); 16 Aug 2004 22:08:06 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [192.18.33.10] (HELO exchange.sun.com) (192.18.33.10) by apache.org (qpsmtpd/0.27.1) with SMTP; Mon, 16 Aug 2004 15:08:06 -0700 Received: (qmail 14085 invoked by uid 50); 16 Aug 2004 22:09:42 -0000 Date: 16 Aug 2004 22:09:42 -0000 Message-ID: <20040816220942.14084.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: commons-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 30702] New: - [Configuration] XMLConfiguration cannot read from XML from jar X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=30702 [Configuration] XMLConfiguration cannot read from XML from jar Summary: [Configuration] XMLConfiguration cannot read from XML from jar Product: Commons Version: 1.0 Beta 2 Platform: All OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Configuration AssignedTo: commons-dev@jakarta.apache.org ReportedBy: jromanda@infophase.com In the current RC1 codebase, the XMLConfiguration class cannot read an xml configuration file packaged in a jar file. The PropertiesConfiguration class handles this correctly using an InputStream rather than a File object, but the XMLConfiguration does not. Here is a patch for XMLConfiguration that lets you put XML files into a jar file. Index: XMLConfiguration.java =================================================================== RCS file: /home/cvspublic/jakarta- commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration .java,v retrieving revision 1.10 diff -u -r1.10 XMLConfiguration.java --- XMLConfiguration.java 14 Aug 2004 11:32:06 -0000 1.10 +++ XMLConfiguration.java 16 Aug 2004 21:55:26 -0000 @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; @@ -142,20 +143,20 @@ } public void load() throws ConfigurationException { - File file = null; + InputStream resource = null; try { URL url = ConfigurationUtils.getURL(getBasePath(), getFileName()); - file = new File(url.getFile()); + resource = url.openStream(); DocumentBuilder builder = DocumentBuilderFactory.newInstance ().newDocumentBuilder(); - document = builder.parse(file); + document = builder.parse(resource); } catch (IOException de) { - throw new ConfigurationException("Could not load from " + file.getAbsolutePath(), de); + throw new ConfigurationException("Could not load from " + getFileName(), de); } catch (ParserConfigurationException ex) { throw new ConfigurationException("Could not configure parser", ex); } catch (FactoryConfigurationError ex) { throw new ConfigurationException("Could not create parser", ex); } catch (SAXException ex) { - throw new ConfigurationException("Error parsing file " + file.getAbsolutePath(), ex); + throw new ConfigurationException("Error parsing file " + getFileName(), ex); } initProperties(document.getDocumentElement(), new StringBuffer()); --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org