Hi,
Mahesh wrote:
> Hi
>
> I am getting the below exception while converting XML to object. I am
> using Xstream 1.4.1 and JDK 1.6.
>
> It's working fine in one websphere server (RAD 7.5 and websphere 7.0) and
> it's not working in another websphere server 7.0.
>
> Please tell me the reason, why i am getting the below exception.
>
> 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)
> at com.thoughtworks.xstream.XStream.<init>(XStream.java:385)
> at com.thoughtworks.xstream.XStream.<init>(XStream.java:342)
> ... 39 more
> Caused by:
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance
> (NativeConstructorAccessorImpl.java:56)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
> (DelegatingConstructorAccessorImpl.java:39)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
> at com.thoughtworks.xstream.XStream.dynamicallyRegisterConverter
> (XStream.java:725)
> ... 46 more
> Caused by:
> java.lang.ClassCastException:
> org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl incompatible with
> javax.xml.datatype.DatatypeFactory
> at javax.xml.datatype.DatatypeFactory.newInstance(Unknown Source)
> at com.thoughtworks.xstream.converters.extended.DurationConverter.<init>
> (DurationConverter.java:33)
> ... 51 more
You have a classpath problem. This class is normally part of the JDK since
Java 5. Does your EnterpriseApp or WebApp contain an own copy of it (look
into xml_apis.jar or some versions of xercesImpl.jar)? Main problem is that
the factory is provided by Java SPI mechanism (it is somewhere registered in
a jar's META-INF/services/javax.xml.datatype.DatatypeFactory), but the
instantiated class and the interface are nor compatible (because loaded by
different classloaders).
You may also try latest XStream SNAPSHOT (see download page), it has a
modified class initialization and it should ignore this problem (at the cost
of not registering DurationConverter).
- Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email