Conflict with Java Preferences class

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Fran Tonello
Posts: 8
Joined: Thu Mar 20, 2003 7:45 pm

Conflict with Java Preferences class

Post by Fran Tonello » Fri Mar 21, 2003 3:07 am

Just a word of caution to folks using the Java 1.4+ java.util.Preferences class...

I have an application that used the Xerces XML parser and the new Java Preferences class. Shortly after I upgraded to JBuilder 8, I discovered that on UNIX machines Java would think there was a problem with the XML files it created to persist the preferences in and I'd see messages like this when running my application in JBuilder:

Mar 6, 2003 6:32:25 PM java.util.prefs.FileSystemPreferences$11 run
WARNING: Invalid preferences format in /<path>/prefs.xml
Mar 6, 2003 6:32:55 PM java.util.prefs.FileSystemPreferences$11 run
WARNING: Prefs file removed in background

-Java would remove the offending preferences file, and you'd get that second message later when it tried to access it. BTW, you don't see this problem on Windows machines because Preferences are persisted in the Registry in a non-XML format.

After much wailing and gnashing of teeth, I was able to determine that it was the new version of Xerces that shipped with JBuilder 8 that conflicted with Preferences and caused this problem. -When Java went to parse the Preferences XML file, it would get an error because the new Xerces wants to be set up differently than the old. The answer for me was to convert my XML parsing code to use the new DocumentBuilderFactory and DocumentBuilder classes instead of instanciating Xerces directly, and eliminate Xerces from my path.

I mention all of this here because JFreeChart comes with JAXP, which also includes pieces of Xerces which again cause the conflict with Java Preferences. If you're using Preferences and you're not using the XML features of JFreeChart, you can solve this mysterious problem by taking gnujaxp.jar out of your path.

I hope I can save somebody else the consternation this caused me!

-Fran

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Mar 21, 2003 12:47 pm

Hi Fran,

Thanks for the info. This is bound to come up again some time!

Regards,

Dave Gilbert

Locked