Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.3.1
-
Fix Version/s: None
-
Component/s: Converters
-
Labels:None
-
JDK version and platform:GNU libgcj 4.3.2
Description
The following (shortend) stacktrace says it all:
com.thoughtworks.xstream.XStream$InitializationException: Could not instantiate converter : com.thoughtworks.xstream.converters.extended.DurationConverter : null
at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:732)
at com.thoughtworks.xstream.XStream.setupConverters(XStream.java:696)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:445)
...
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(libgcj.so.90)
at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter(XStream.java:725)
...61 more
Caused by: javax.xml.datatype.DatatypeConfigurationException: java.lang.ClassNotFoundException: gnu.xml.datatype.JAXPDatatypeFactory
at javax.xml.datatype.DatatypeFactory.newInstance(libgcj.so.90)
at com.thoughtworks.xstream.converters.extended.DurationConverter.<init>(DurationConverter.java:33)
at java.lang.reflect.Constructor.newInstance(libgcj.so.90)
...62 more
Caused by: java.lang.ClassNotFoundException: gnu.xml.datatype.JAXPDatatypeFactory
at java.lang.Class.forName(libgcj.so.90)
at javax.xml.datatype.DatatypeFactory.newInstance(libgcj.so.90)
...64 more
Since javax.xml.datatype.Duration is on the classpath, XStream will try to create a javax.xml.datatype.DatatypeFactory. On gcj this factory is configured to utilize gnu.xml.datatype.JAXPDatatypeFactory, which itself is not present .
So strictly speaking it is gcj's fault. But why does XStream fail so badly because of one failing 'optional' converter?
Workaround: overwrite setupAliases() and catch InitializationExceptions.
Note that this issue is related to but not the same as http://jira.codehaus.org/browse/XSTR-537 .
This class is part of JDK 5 and only in this case its converter is automatically registered. XStream can therefore expect to be able to instantiate this class.