XStream and Google App Engine

二次信任 提交于 2019-12-12 03:03:38

问题


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?


回答1:


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

public Car(){}


来源:https://stackoverflow.com/questions/15802986/xstream-and-google-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!