---------- Forwarded Mail ---------- Subject: ConverterLookup Date: 24th December 2013, 13:02:09 From: Alvaro <alv...@pwntester.com> To: joerg.schai...@gmx.de
Hi Joerg, Im trying to write to the xstream dev list but get bounced by the mailing daemon even though Im subscribed. Maybe you can help me with this problem since you are one of the developers of the ConverterLookup class. Im trying to register the folloging ConverterLookup: import com.thoughtworks.xstream.converters.ConversionException; import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.converters.ConverterLookup; import com.thoughtworks.xstream.converters.basic.NullConverter; public class MyConverterLookup implements ConverterLookup { private final Converter nullConverter = new NullConverter(); public Converter lookupConverterForType(Class type) throws ConversionException { if (type == null) { return nullConverter; } if (type.equals(Contact.class)) { return new ContactConverter(); } else { throw new ConversionException("No converter specified for " + type); } } } But Im getting the following exception: Exception in thread "main" org.springframework.oxm.UncategorizedMappingException: Unknown XStream exception; nested exception is com.thoughtworks.xstream.InitializationException: Could not instantiate mapper : com.thoughtworks.xstream.mapper.AnnotationMapper : argument type mismatch at org.springframework.oxm.xstream.XStreamMarshaller.convertXStreamException(XStreamMarshaller.java:807) at org.springframework.oxm.xstream.XStreamMarshaller.doMarshal(XStreamMarshaller.java:689) at org.springframework.oxm.xstream.XStreamMarshaller.marshalWriter(XStreamMarshaller.java:676) at org.springframework.oxm.xstream.XStreamMarshaller.marshalWriter(XStreamMarshaller.java:666) at org.springframework.oxm.support.AbstractMarshaller.marshalStreamResult(AbstractMarshaller.java:272) at org.springframework.oxm.support.AbstractMarshaller.marshal(AbstractMarshaller.java:103) at org.pwntester.xstreamoxm.Main.main(Main.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: com.thoughtworks.xstream.InitializationException: Could not instantiate mapper : com.thoughtworks.xstream.mapper.AnnotationMapper : argument type mismatch at com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:604) at com.thoughtworks.xstream.XStream.buildMapper(XStream.java:586) at com.thoughtworks.xstream.XStream.<init>(XStream.java:552) at com.thoughtworks.xstream.XStream.<init>(XStream.java:514) at org.springframework.oxm.xstream.XStreamMarshaller$1.<init>(XStreamMarshaller.java:388) at org.springframework.oxm.xstream.XStreamMarshaller.constructXStream(XStreamMarshaller.java:387) at org.springframework.oxm.xstream.XStreamMarshaller.buildXStream(XStreamMarshaller.java:372) at org.springframework.oxm.xstream.XStreamMarshaller.getXStream(XStreamMarshaller.java:584) at org.springframework.oxm.xstream.XStreamMarshaller.doMarshal(XStreamMarshaller.java:686) ... 10 more Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at com.thoughtworks.xstream.XStream.buildMapperDynamically(XStream.java:602) ... 18 more Im using the following code to set up the converterlookup XStreamMarshaller xstream = new XStreamMarshaller(); xstream.setConverterLookup(new MyConverterLookup()); Any idea why is failing? Im trying to use the lookup class as an elegant solution for the remote code execution problem when using the reflection converters. So I just want to use the Contact converter or fail. I already implemented the other solution you proposed: - register a ContactConverter - register a CatchAllConverter with low priority That approach works but I found the lookup class and it seems a more elegant solution Thanks, A ------------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email