A bit late, but I'm finally checking out the latest version of xstream for
Applet compatibility. So far no luck. When I run the following code
inside of appletviewer it crashes on the "new XStream()" line. Code and
exception below. Am I doing something wrong or are there still issues that
need to be worked around? I'm using version 1.4.7 from Maven central
repository.
Thanks!
--------------------- BEGIN -------------------------
public static <T> T loadXML( Reader r ) {
XStream xstream = new XStream(new PureJavaReflectionProvider(),new
DomDriver(),new
ClassLoaderReference(r.getClass().getClassLoader()));
xstream.registerConverter(new
JavaBeanConverter(xstream.getMapper()));
return (T)xstream.fromXML(r);
}
--------------------- END -------------------------
Exception in thread "Thread-1"
com.thoughtworks.xstream.InitializationException: Could not instantiate
mapper : com.thoughtworks.xstream.mapper.EnumMapper : access denied
("java.lang.RuntimePermission" "getClassLoader")
at
com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:622)
at com.thoughtworks.xstream.XStream.buildMapper(XStream.java:596)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:568)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:496)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:489)
at com.thoughtworks.xstream.XStream.<init>(XStream.java:428)
at boofcv.io.UtilIO.loadXML(UtilIO.java:157)
On Mon, Jul 15, 2013 at 3:01 AM, Jörg Schaible
<[email protected]>wrote:
> Peter A wrote:
>
> > Hi Jörg,
> >
> > When I skimmed the code I thought it handled the null case, must have
> read
> > the code in correctly. Please ignore that comment.
> >
> > My first attempt to use the new code failed and throws an exception. See
> > below for my code. Did I do something wrong?
> >
> > ---------------- BEGIN -----------------------
> > ClassLoaderReference loader = new
> > ClassLoaderReference(BoofMiscOps.class.getClassLoader());
> > XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> > DomDriver(),loader,null,new DefaultConverterLookup(), null);
> >
> > xstream.registerConverter(new JavaBeanConverter(xstream.getMapper()));
> >
> > try {
> > xstream.toXML(o,new FileOutputStream(fileName));
> > } catch (FileNotFoundException e) {
> > throw new RuntimeException(e);
> > }
> > ---------------- END -----------------------
>
>
> You did not provide a ConverterRegistry, so no converter was registered at
> all. Since you use the defaults anyway, simply instantiate with:
>
> XStream xstream = new XStream(new PureJavaReflectionProvider(),new
> DomDriver(),loader);
>
> Cheers,
> Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
--
"Now, now my good man, this is no time for making enemies." — Voltaire
(1694-1778), on his deathbed in response to a priest asking that he
renounce Satan.