Although I've never used commons-configurations, the NoSuchMethodException leads me to believe that you need to have JDK 1.4 or higher. The docs say that the StringBuffer.indexOf(String) method was introduced in that version.
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/StringBuffer.html#indexOf( java.lang.String) -----Original Message----- From: Vikas Phonsa [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 14, 2004 2:32 PM To: '[EMAIL PROTECTED]' Subject: Hierarchical Configuration Problem: Newbie Hi Everybody, I am trying to learn the commons-configuration from the examples given on the website http://jakarta.apache.org/commons/configuration/examples.html Things were working as expected until I started to use the Hierarchical Properties. I'm listing my source code, the exceptions that I'm getting and the properties file that I'm using. I would appreciate any thoughts. Thanks Vikas ---------------Source Code---------------------------------- public class FirstConfig { public static void main(String[] args) throws Exception{ ConfigurationFactory configFactory = new ConfigurationFactory(); URL configFile = new File("config\\config.xml").toURL(); System.out.println("URL== "+ configFile); configFactory.setConfigurationURL(configFile); Configuration config = configFactory.getConfiguration(); String backgroundColor = config.getString("color.background"); String textColor = config.getString("color.text"); String rows = config.getString("rowsPerPage"); System.out.println("Here is the back ground color property: "+ backgroundColor); System.out.println("Here is the text color property: "+ textColor); System.out.println("Here is the rows per page property: "+ rows); //Everything is working perfectly fine till here Object tablename = config.getProperty("tables.table(0).name"); System.out.println("Here is tablename.toString() : "+tablename.toString()); } } --------------Exception Stack Trace---------------------------------------- URL== file:/c:/wsad_workspaces/Eclipse/Commons-Config/config/config.xml Here is the back ground color property: black; Here is the text color property: #000000 Here is the rows per page property: 15 java.lang.NoSuchMethodError: java.lang.StringBuffer: method indexOf(Ljava/lang/String;I)I not found at org.apache.commons.configuration.ConfigurationKey$KeyIterator.findNextIndice s(ConfigurationKey.java:431) at org.apache.commons.configuration.ConfigurationKey$KeyIterator.nextKey(Config urationKey.java:472) at org.apache.commons.configuration.HierarchicalConfiguration.findPropertyNodes (HierarchicalConfiguration.java:476) at org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(Hie rarchicalConfiguration.java:449) at org.apache.commons.configuration.HierarchicalConfiguration.getPropertyDirect (HierarchicalConfiguration.java:188) at org.apache.commons.configuration.HierarchicalConfiguration.containsKey(Hiera rchicalConfiguration.java:354) at org.apache.commons.configuration.CompositeConfiguration.getFirstMatchingConf ig(CompositeConfiguration.java:753) at org.apache.commons.configuration.CompositeConfiguration.getProperty(Composit eConfiguration.java:220) at com.suz.config.first.FirstConfig.main(FirstConfig.java:58) Exception in thread "main" --------------------config.xml------------------------- <?xml version="1.0"?> <configuration> <properties fileName="first.properties"/> <dom4j fileName="first.xml"/> <hierarchicalDom4j fileName="tables.xml"/> </configuration> ---------------------tables.xml---------------------- ?xml version="1.0" encoding="ISO-8859-1" ?> <database> <tables> <table tableType="system"> <name>users</name> <fields> <field> <name>uid</name> <type>long</type> </field> <field> <name>uname</name> <type>java.lang.String</type> </field> <field> <name>firstName</name> <type>java.lang.String</type> </field> <field> <name>lastName</name> <type>java.lang.String</type> </field> <field> <name>email</name> <type>java.lang.String</type> </field> </fields> </table> <table tableType="application"> <name>documents</name> <fields> <field> <name>docid</name> <type>long</type> </field> <field> <name>name</name> <type>java.lang.String</type> </field> <field> <name>creationDate</name> <type>java.util.Date</type> </field> <field> <name>authorID</name> <type>long</type> </field> <field> <name>version</name> <type>int</type> </field> </fields> </table> </tables> </database> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
