osdir.com
mailing list archive

Subject: [jira] Created: (XSTR-442) array class attributes corrupt JSON using JettisonMappedXmlDriver unless they are the last class attribute - msg#00016

List: java.xstream.cvs

Date: Prev Next Index Thread: Prev Next Index
array class attributes corrupt JSON using JettisonMappedXmlDriver unless they
are the last class attribute
----------------------------------------------------------------------------------------------------------

Key: XSTR-442
URL: http://jira.codehaus.org/browse/XSTR-442
Project: XStream
Issue Type: Bug
Affects Versions: 1.2.2
Reporter: david wilson
Attachments: Test.java

Serializing a class that has an array as an attrubute creates invalid JSON that
wont reload into original Java class. It seems to misplace the } at the end of
the array data in the generated JSON text, see below.

{"customer":{"ids":{"string":["1","2","3","4"],"name":"david","postCode":"gu27
8uu"}}}

BTW if you use the default XML driver all works fine.

In the attached class if the ids attribute of the testCustomer class is the
last attribute then all works fine if not it produces the following error :

Exception in thread "main"
com.thoughtworks.xstream.converters.ConversionException: name : name
---- Debugging information ----
message : name : name
cause-exception :
com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : name : name
class : json.test.TestCustomer
required-type : [Ljava.lang.String;
path : /customer/ids/name
line number : -1
-------------------------------
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:63)
at
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at
com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)
at
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)
at
com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
at
com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)
at
com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:833)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:781)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:773)
at json.test.Test.JSONToJava(Test.java:22)
at json.test.Test.main(Test.java:30)
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: name :
name
at
com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:49)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:76)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:60)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:76)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:26)
at
com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:34)
at
com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:62)
at
com.thoughtworks.xstream.converters.collections.ArrayConverter.unmarshal(ArrayConverter.java:44)
at
com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)
... 16 more

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira



<hr/>
<p>
To unsubscribe from this list please visit:
</p>
<p>
<a
href="http://xircles.codehaus.org/manage_email";>http://xircles.codehaus.org/manage_email</a>




Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

[jira] Commented: (XSTR-431) xStream unable to use Sun14ReflectionProvider with SAP VM

[ http://jira.codehaus.org/browse/XSTR-431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_109493 ] Norbert Kuck commented on XSTR-431: ----------------------------------- Hi Joerg, it seems that it is currently a little difficult to download a copy of the VM (mainly because it is delivered as part of the application server), but I could provide you with a prerelease copy of just the VM itself directly from SAP development. I have sent you a mail explaining the details. Greetings - Norbert > xStream unable to use Sun14ReflectionProvider with SAP VM > --------------------------------------------------------- > > Key: XSTR-431 > URL: http://jira.codehaus.org/browse/XSTR-431 > Project: XStream > Issue Type: Bug > Components: Core > Affects Versions: 1.2.2 > Reporter: Rico Neubauer > Fix For: Upcoming > > > Hi, > There is a VM from SAP, which is not > The XStream Library includes code that checks the Vendor name of the VM > und depending on that, different reflection providers are used. > In class com.thoughtworks.xstream.core.JVM (example for sun): > private static boolean isSun() { > return System.getProperty("java.vm.vendor").indexOf("Sun") != -1; > } > or comparable demands in the same class for VMs of IBM, HP and others. > private boolean canUseSun14ReflectionProvider() { > return (isSun() || isApple() || isHPUX() || isIBM() || isBlackdown() || > isBEAWithUnsafeSupport() || isHitachi()) && is14() && loadClass > "sun.misc.Unsafe") != null; > } > The SAP JVM will not be identified from this check and as a result, a the > PureJavaReflectionProvider is used, which does not support all features. > adding a check for "SAP AG" results in the Sun14ReflectionProvider being used > without problems, so imho this can be easily and safely added. > For your information, here what the System-Properties return: > VM-Version: 5.1.0717 > VM-Vendor: SAP AG -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira <hr/> <p> To unsubscribe from this list please visit: </p> <p> <a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>

Next Message by Date: click to view message preview

[1271] trunk/xstream-distribution/src/content: Support for SAP JVM (XSTR-431).

Revision 1271 Author joehni Date 2007-10-11 12:13:51 -0500 (Thu, 11 Oct 2007) Log Message Support for SAP JVM (XSTR-431). Modified Paths trunk/xstream-distribution/src/content/changes.html trunk/xstream-distribution/src/content/faq.html Diff Modified: trunk/xstream-distribution/src/content/changes.html (1270 => 1271) --- trunk/xstream-distribution/src/content/changes.html 2007-10-07 15:56:58 UTC (rev 1270) +++ trunk/xstream-distribution/src/content/changes.html 2007-10-11 17:13:51 UTC (rev 1271) @@ -32,6 +32,7 @@ <li>JIRA:XSTR-305: Field alias inheritance (by David Blevins).</li> <li>XStream failed to initialize in environments without AWT or SQL classes.</li> <li>JIRA:XSTR-420: XPath of references are not XmlFriendly encoded.</li> + <li>JIRA:XSTR-431: Direct support of enhanced mode for SAP JVM (thanks to Norbert Kuck by SAP).</li> </ul> <h2>Minor changes</h2> Modified: trunk/xstream-distribution/src/content/faq.html (1270 => 1271) --- trunk/xstream-distribution/src/content/faq.html 2007-10-07 15:56:58 UTC (rev 1270) +++ trunk/xstream-distribution/src/content/faq.html 2007-10-11 17:13:51 UTC (rev 1271) @@ -38,7 +38,9 @@ <h2>Which JVMs allow XStream to operate in enhanced mode?</h2> <p>Currently on the Sun, Apple, HP, IBM and Blackdown 1.4 JVMs and onwards. - Support for BEA JRockit starting with R25.1.0. For all other JVMs, XStream should be used in pure Java mode.</p> + Also for Hitachi and SAP from 1.5 and onwards. + Support for BEA JRockit starting with R25.1.0. + For all other JVMs, XStream should be used in pure Java mode.</p> <h2>What are the advantages of using enhanced mode over pure Java mode?</h2> To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

Previous Message by Thread: click to view message preview

[jira] Created: (XSTR-441) xstream over http

xstream over http ------------------ Key: XSTR-441 URL: http://jira.codehaus.org/browse/XSTR-441 Project: XStream Issue Type: Bug Components: IO Affects Versions: 1.2.2 Reporter: Will Johnson I'm trying to do some basic xstream over http and everything I try results in the following error when parsing via xstream.fromXML(inputStream) Caused by: org.xml.sax.SAXParseException: Premature end of file. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) code: HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setDoInput(true); // allow input stream conn.setDoOutput(true); // allow output stream conn.setUseCaches(false); // don't allow caching conn.setRequestProperty("Content-Type", CONTENT_TYPE_XML_UTF8); conn.setRequestMethod("POST"); OutputStream out = conn.getOutputStream(); xmlSerializer.toXML(o, out); out.flush(); InputStream is = conn.getInputStream(); Object ret = xmlSerializer.fromXML(is); out.close(); is.close(); if I run a sample client against the exact same code but use Strings and a reader it works fine so this would seem to be my problem (likely) or an xstream problem. (this works) Reader reader = new InputStreamReader(conn.getInputStream(), "UTF-8"); while ((line=reader.readLine()) != null) { sb.append(line); if (reader.ready()) { sb.append(LINE_SEP); } } Object obj = xstream.fromXML(sb.toString()); I tried the same style of approach using commons.httpclient and had the same result. XStream is configured via: xstream = new XStream(new DomDriver("UTF-8")); xstream.setMode(XStream.NO_REFERENCES); addAliases(); // adds a bunch of class name aliases xstream.registerConverter(new NonCachingStringConverter()); // pretty self explanatory and the full stack trace is as follows.... com.thoughtworks.xstream.io.StreamException: : Premature end of file. at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:65) at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:51) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:789) at (my company's code) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74) at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.xml.sax.SAXParseException: Premature end of file. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source) at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:58) one interesting note is that running without the DOM Driver produces a different error Caused by: java.io.EOFException: input contained no data at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2983) at org.xmlpull.mxp1.MXParser.more(MXParser.java:3026) at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1410) at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395) at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093) at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:52) ... 33 more -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira <hr/> <p> To unsubscribe from this list please visit: </p> <p> <a href="http://xircles.codehaus.org/manage_email">http://xircles.codehaus.org/manage_email</a>

Next Message by Thread: click to view message preview

[1271] trunk/xstream-distribution/src/content: Support for SAP JVM (XSTR-431).

Revision 1271 Author joehni Date 2007-10-11 12:13:51 -0500 (Thu, 11 Oct 2007) Log Message Support for SAP JVM (XSTR-431). Modified Paths trunk/xstream-distribution/src/content/changes.html trunk/xstream-distribution/src/content/faq.html Diff Modified: trunk/xstream-distribution/src/content/changes.html (1270 => 1271) --- trunk/xstream-distribution/src/content/changes.html 2007-10-07 15:56:58 UTC (rev 1270) +++ trunk/xstream-distribution/src/content/changes.html 2007-10-11 17:13:51 UTC (rev 1271) @@ -32,6 +32,7 @@ <li>JIRA:XSTR-305: Field alias inheritance (by David Blevins).</li> <li>XStream failed to initialize in environments without AWT or SQL classes.</li> <li>JIRA:XSTR-420: XPath of references are not XmlFriendly encoded.</li> + <li>JIRA:XSTR-431: Direct support of enhanced mode for SAP JVM (thanks to Norbert Kuck by SAP).</li> </ul> <h2>Minor changes</h2> Modified: trunk/xstream-distribution/src/content/faq.html (1270 => 1271) --- trunk/xstream-distribution/src/content/faq.html 2007-10-07 15:56:58 UTC (rev 1270) +++ trunk/xstream-distribution/src/content/faq.html 2007-10-11 17:13:51 UTC (rev 1271) @@ -38,7 +38,9 @@ <h2>Which JVMs allow XStream to operate in enhanced mode?</h2> <p>Currently on the Sun, Apple, HP, IBM and Blackdown 1.4 JVMs and onwards. - Support for BEA JRockit starting with R25.1.0. For all other JVMs, XStream should be used in pure Java mode.</p> + Also for Hitachi and SAP from 1.5 and onwards. + Support for BEA JRockit starting with R25.1.0. + For all other JVMs, XStream should be used in pure Java mode.</p> <h2>What are the advantages of using enhanced mode over pure Java mode?</h2> To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by