DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=30702>. 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: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
