commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Roth <Mark.R...@Sun.COM>
Subject [Configuration] autoSave causing FileNotFoundException
Date Sat, 02 Oct 2004 03:14:37 GMT
I believe I've found a bug.  When trying to use autoSave, 
jakarta-commons-configuration gives me the following error:

-----
java.io.FileNotFoundException: file:/tmp/test.xml (No such file or 
directory)
	at java.io.FileOutputStream.open(Native Method)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
	at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
	at 
org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:259)
	at 
org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:216)
	at 
org.apache.commons.configuration.AbstractFileConfiguration.save(AbstractFileConfiguration.java:200)
	at 
org.apache.commons.configuration.XMLConfiguration.possiblySave(XMLConfiguration.java:566)
	at 
org.apache.commons.configuration.XMLConfiguration.clearProperty(XMLConfiguration.java:489)
	at 
org.apache.commons.configuration.AbstractConfiguration.setProperty(AbstractConfiguration.java:318)
	at 
org.apache.commons.configuration.XMLConfiguration.setProperty(XMLConfiguration.java:371)
	at test.Main.main(Main.java:22)
-----

For some reason, it converted my File into a URL but then tries to 
access it as a File path again when trying to persist my settings.

Here is a simple test application to reproduce the problem:

-----
package test;

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import org.apache.commons.configuration.XMLConfiguration;

/**
  * Illustrates a bug in jakarta-commons-configuration
  *
  * @author Mark Roth
  */
public class Main {

     public static void main(String[] args)
         throws Exception
     {
         File configFile = new File("/tmp/test.xml");
         createSampleTestXml(configFile);
         XMLConfiguration config = new XMLConfiguration(configFile);
         config.setAutoSave(true);
         config.setProperty("a", "b");
     }

     private static void createSampleTestXml(File f)
         throws Exception
     {
         PrintWriter out = new PrintWriter(new FileWriter(f));
         out.println("<root>");
         out.println("  test");
         out.println("</root>");
         out.close();
     }
}
-----

Is this a known error?  Any known workarounds?

Thanks,
---
Mark Roth, Staff Engineer, Java Software
JSP 2.0 / 2.1 Specification Lead
Java Enterprise Community Leader
http://community.java.net/java-enterprise
Sun Microsystems, Inc.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message