XStream and Google App Engine
Asked Answered
D

1

0

Hi I saw a XStream implementation for Google App Engine however I am still getting a

"Cannot construct [class] as it does no have a no-args constructor"

@Test
public void testNoNoArgs() {
    Car car = new Car(1, "Blue");
    XStream xstream = new XStreamGae();
    String s = xstream.toXML(car);
    Car c = (Car) xstream.fromXML(s);
}

The complete stack trace is here: http://pastebin.com/TGF6N17W

The XStream related dependency in my application are:

    <dependency>
        <groupId>com.thoughtworks.xstream</groupId>
        <artifactId>xstream</artifactId>
        <version>1.4.2</version>
    </dependency>
    <dependency>
        <groupId>xpp3</groupId>
        <artifactId>xpp3_min</artifactId>
        <version>1.1.4c</version>
    </dependency>
    <!-- XStreamGae Dependencies -->
    <dependency>
        <groupId>net.sf.kxml</groupId>
        <artifactId>kxml2-min</artifactId>
        <version>2.3.0</version>
    </dependency>       
    <dependency>
        <groupId>xmlpull</groupId>
        <artifactId>xmlpull</artifactId>
        <version>1.1.3.1</version>
    </dependency>

The XStreamGae class can be found here:

http://www.wappworks.com/2011/11/11/using-xstream-with-google-app-engine/

Is there a work-around to make this work-around work?

Donnadonnamarie answered 4/4, 2013 at 5:13 Comment(1)
BTW, the App Engine version I am using is SDK version 1.7.5Donnadonnamarie
S
1

Obviously your class Car should have a no-arg constructor:

public Car(){}
Scintillate answered 4/4, 2013 at 14:6 Comment(2)
Yah, but why the Google Gson library is able to serialize with no no-args. I believe this is a issue relating to SecurityManager where GAE SDK allows Gson with certain security privilege while other marshalling frameworks like XStream don't is there a work-around for this?Donnadonnamarie
Afaik Gson also needs no-args constructor: sites.google.com/site/gson/gson-user-guide. Btw, if you have no constructor defined, then Java internally provides a default no-args constructor.Scintillate

© 2022 - 2024 — McMap. All rights reserved.