XStream no in enhanced mode?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

XStream no in enhanced mode?

Xybrek
Hello,

I'm getting this error when trying to "deserialize":

Cannot construct MyClass as it does not have a no-args constructor.

Looking at the docs, it means that Xtream is not running in enhanced mode?

However, in the same JVM and using the same class the Google Gson
library can serialize and deserialize objects without problem:

MyClass c;
c = (MyClass) new Gson().fromJson(json, MyClass.class);

So why Xstream can't do to XML what Gson can do for JSON? Is this easy
to patch in the Xstream code or is this a limitation that is not easy to
get around with?

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Jörg Schaible-3
Hi,

Xybrek wrote:

> Hello,
>
> I'm getting this error when trying to "deserialize":
>
> Cannot construct MyClass as it does not have a no-args constructor.
>
> Looking at the docs, it means that Xtream is not running in enhanced mode?
>
> However, in the same JVM and using the same class the Google Gson
> library can serialize and deserialize objects without problem:
>
> MyClass c;
> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>
> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
> to patch in the Xstream code or is this a limitation that is not easy to
> get around with?

XStream will normally run always in enhanced mode. Which version of XStream
you're using, which Java version and vendor? Is it a special environment
(e.g. app server or applet)? How did you initialize XStream?

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Xybrek
On 04/03/2013 04:28 PM, Jörg Schaible wrote:

> Hi,
>
> Xybrek wrote:
>
>> Hello,
>>
>> I'm getting this error when trying to "deserialize":
>>
>> Cannot construct MyClass as it does not have a no-args constructor.
>>
>> Looking at the docs, it means that Xtream is not running in enhanced mode?
>>
>> However, in the same JVM and using the same class the Google Gson
>> library can serialize and deserialize objects without problem:
>>
>> MyClass c;
>> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>>
>> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
>> to patch in the Xstream code or is this a limitation that is not easy to
>> get around with?
>
> XStream will normally run always in enhanced mode. Which version of XStream
> you're using, which Java version and vendor? Is it a special environment
> (e.g. app server or applet)? How did you initialize XStream?
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>

Hi Jorg,

I just did a simple:

XStream xstream = new XStream();

I'm using JDK 1.7 64-bit (from Oracle), just running a JUnit test.

What makes me think is that why Gson can deserialize a no-args
constructor in the same JVM and same JUnit test

-Xybrek


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Jörg Schaible-3
Hi,

Xybek wrote:

> On 04/03/2013 04:28 PM, Jörg Schaible wrote:
>> Hi,
>>
>> Xybrek wrote:
>>
>>> Hello,
>>>
>>> I'm getting this error when trying to "deserialize":
>>>
>>> Cannot construct MyClass as it does not have a no-args constructor.
>>>
>>> Looking at the docs, it means that Xtream is not running in enhanced
>>> mode?
>>>
>>> However, in the same JVM and using the same class the Google Gson
>>> library can serialize and deserialize objects without problem:
>>>
>>> MyClass c;
>>> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>>>
>>> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
>>> to patch in the Xstream code or is this a limitation that is not easy to
>>> get around with?
>>
>> XStream will normally run always in enhanced mode. Which version of
>> XStream you're using, which Java version and vendor? Is it a special
>> environment (e.g. app server or applet)? How did you initialize XStream?
>
> Hi Jorg,
>
> I just did a simple:
>
> XStream xstream = new XStream();

I thought you tried to process JSON? Did you actually read XStream's JSON
tutorial?

> I'm using JDK 1.7 64-bit (from Oracle), just running a JUnit test.

Which version of XStream?

> What makes me think is that why Gson can deserialize a no-args
> constructor in the same JVM and same JUnit test

Can't say, because in XStream's ~1500 unit tests it does this more than
once.

Can you post the complete exception including stack trace?

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Xybrek
On 04/03/2013 11:20 PM, Jörg Schaible wrote:

> Hi,
>
> Xybek wrote:
>
>> On 04/03/2013 04:28 PM, Jörg Schaible wrote:
>>> Hi,
>>>
>>> Xybrek wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm getting this error when trying to "deserialize":
>>>>
>>>> Cannot construct MyClass as it does not have a no-args constructor.
>>>>
>>>> Looking at the docs, it means that Xtream is not running in enhanced
>>>> mode?
>>>>
>>>> However, in the same JVM and using the same class the Google Gson
>>>> library can serialize and deserialize objects without problem:
>>>>
>>>> MyClass c;
>>>> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>>>>
>>>> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
>>>> to patch in the Xstream code or is this a limitation that is not easy to
>>>> get around with?
>>>
>>> XStream will normally run always in enhanced mode. Which version of
>>> XStream you're using, which Java version and vendor? Is it a special
>>> environment (e.g. app server or applet)? How did you initialize XStream?
>>
>> Hi Jorg,
>>
>> I just did a simple:
>>
>> XStream xstream = new XStream();
>
> I thought you tried to process JSON? Did you actually read XStream's JSON
> tutorial?
>
>> I'm using JDK 1.7 64-bit (from Oracle), just running a JUnit test.
>
> Which version of XStream?
>
>> What makes me think is that why Gson can deserialize a no-args
>> constructor in the same JVM and same JUnit test
>
> Can't say, because in XStream's ~1500 unit tests it does this more than
> once.
>
> Can you post the complete exception including stack trace?
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>

Hi Jorg,

Yes, I did process JSON string but this is for the Gson library I use. I
was just asking why Google Gson library can serialize and deserialize
object instances in the same JVM and JUnit test where XStream fails to
do so, throwing exception that the class have no-args constructor.

BTW, I am running in the Google Appengine environment (v 1,7.5)

Also I have a question whether XStream can deal with Object graphs?


-Kybrek


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Xybrek
In reply to this post by Jörg Schaible-3
On 04/03/2013 11:20 PM, Jörg Schaible wrote:

> Hi,
>
> Xybek wrote:
>
>> On 04/03/2013 04:28 PM, Jörg Schaible wrote:
>>> Hi,
>>>
>>> Xybrek wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm getting this error when trying to "deserialize":
>>>>
>>>> Cannot construct MyClass as it does not have a no-args constructor.
>>>>
>>>> Looking at the docs, it means that Xtream is not running in enhanced
>>>> mode?
>>>>
>>>> However, in the same JVM and using the same class the Google Gson
>>>> library can serialize and deserialize objects without problem:
>>>>
>>>> MyClass c;
>>>> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>>>>
>>>> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
>>>> to patch in the Xstream code or is this a limitation that is not easy to
>>>> get around with?
>>>
>>> XStream will normally run always in enhanced mode. Which version of
>>> XStream you're using, which Java version and vendor? Is it a special
>>> environment (e.g. app server or applet)? How did you initialize XStream?
>>
>> Hi Jorg,
>>
>> I just did a simple:
>>
>> XStream xstream = new XStream();
>
> I thought you tried to process JSON? Did you actually read XStream's JSON
> tutorial?
>
>> I'm using JDK 1.7 64-bit (from Oracle), just running a JUnit test.
>
> Which version of XStream?
>
>> What makes me think is that why Gson can deserialize a no-args
>> constructor in the same JVM and same JUnit test
>
> Can't say, because in XStream's ~1500 unit tests it does this more than
> once.
>
> Can you post the complete exception including stack trace?
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>

Hi Jorg,

Yes, I did process JSON string but this is for the Gson library I use. I
was just asking why Google Gson library can serialize and deserialize
object instances in the same JVM and JUnit test where XStream fails to
do so, throwing exception that the class have no-args constructor.

BTW, I am running in the Google Appengine environment (v 1,7.5)

Also I have a question whether XStream can deal with Object graphs?


-Xybrek


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Xybrek
In reply to this post by Jörg Schaible-3
On 04/03/2013 11:20 PM, Jörg Schaible wrote:

> Hi,
>
> Xybek wrote:
>
>> On 04/03/2013 04:28 PM, Jörg Schaible wrote:
>>> Hi,
>>>
>>> Xybrek wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm getting this error when trying to "deserialize":
>>>>
>>>> Cannot construct MyClass as it does not have a no-args constructor.
>>>>
>>>> Looking at the docs, it means that Xtream is not running in enhanced
>>>> mode?
>>>>
>>>> However, in the same JVM and using the same class the Google Gson
>>>> library can serialize and deserialize objects without problem:
>>>>
>>>> MyClass c;
>>>> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>>>>
>>>> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
>>>> to patch in the Xstream code or is this a limitation that is not easy to
>>>> get around with?
>>>
>>> XStream will normally run always in enhanced mode. Which version of
>>> XStream you're using, which Java version and vendor? Is it a special
>>> environment (e.g. app server or applet)? How did you initialize XStream?
>>
>> Hi Jorg,
>>
>> I just did a simple:
>>
>> XStream xstream = new XStream();
>
> I thought you tried to process JSON? Did you actually read XStream's JSON
> tutorial?
>
>> I'm using JDK 1.7 64-bit (from Oracle), just running a JUnit test.
>
> Which version of XStream?
>
>> What makes me think is that why Gson can deserialize a no-args
>> constructor in the same JVM and same JUnit test
>
> Can't say, because in XStream's ~1500 unit tests it does this more than
> once.
>
> Can you post the complete exception including stack trace?
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>

ps. I think the XML marshalling is what I like the most than
representing Object as JSON, I just pointed out that I tried Gson and
that it process JSON strings comparing to XStream. The XML processing is
what I need, and hopefully deal with Object graphs.

-Xybrek


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Jörg Schaible-2
In reply to this post by Xybrek
Hi,

Xybek wrote:

[snip]
 
> Hi Jorg,
>
> Yes, I did process JSON string but this is for the Gson library I use. I
> was just asking why Google Gson library can serialize and deserialize
> object instances in the same JVM and JUnit test where XStream fails to
> do so, throwing exception that the class have no-args constructor.
>
> BTW, I am running in the Google Appengine environment (v 1,7.5)

Then you run under a SecurityManager and the Google App engine dose not give
XStream the appropriate rights to use enhanced mode. Actually this is normal
in GAE and AFACIS you cannot modify this policy. Obviously GAE knows about
Gson and that lib has appropriate rights.

> Also I have a question whether XStream can deal with Object graphs?

http://xstream.codehaus.org/graphs.html

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Mentallurg
In reply to this post by Xybrek

For XML, the enhanced mode without default constructor is supported for some
JVMs only.

                if ( canUseSun14ReflectionProvider() ) {
                    String cls =
"com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider";
                    reflectionProvider = (ReflectionProvider)
loadClass(cls).newInstance();
                } else {
                    reflectionProvider = new PureJavaReflectionProvider();
                }

The list of supported JVMs contains Sun, IBM etc., but not Oracle. You wrote
you use Oracle JVM 1.7. Xstream believes it is not supported and just uses
the pure mode, not the enhanced mode.

A workaround:
System.setProperty("java.vm.vendor", "Sun");

A better solution:
Use a newer version of Xstream, where it is already fixed, like 1.4.1 or
newer.











Xybek wrote:

>
> Hello,
>
> I'm getting this error when trying to "deserialize":
>
> Cannot construct MyClass as it does not have a no-args constructor.
>
> Looking at the docs, it means that Xtream is not running in enhanced mode?
>
> However, in the same JVM and using the same class the Google Gson
> library can serialize and deserialize objects without problem:
>
> MyClass c;
> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>
> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
> to patch in the Xstream code or is this a limitation that is not easy to
> get around with?
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
>

--
View this message in context: http://old.nabble.com/XStream-no-in-enhanced-mode--tp35247159p35385084.html
Sent from the xstream - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Mentallurg
In reply to this post by Xybrek

For XML, the enhanced mode without default constructor is supported for some
JVMs only.

                if ( canUseSun14ReflectionProvider() ) {
                    String cls =
"com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider";
                    reflectionProvider = (ReflectionProvider)
loadClass(cls).newInstance();
                } else {
                    reflectionProvider = new PureJavaReflectionProvider();
                }

The list of supported JVMs contains Sun, IBM etc., but not Oracle. You wrote
you use Oracle JVM 1.7. Xstream believes it is not supported and just uses
the pure mode, not the enhanced mode.

A workaround:
System.setProperty("java.vm.vendor", "Sun");

A better solution:
Use a newer version of Xstream, where it is already fixed, like 1.4.1 or
newer.











Xybek wrote:

>
> Hello,
>
> I'm getting this error when trying to "deserialize":
>
> Cannot construct MyClass as it does not have a no-args constructor.
>
> Looking at the docs, it means that Xtream is not running in enhanced mode?
>
> However, in the same JVM and using the same class the Google Gson
> library can serialize and deserialize objects without problem:
>
> MyClass c;
> c = (MyClass) new Gson().fromJson(json, MyClass.class);
>
> So why Xstream can't do to XML what Gson can do for JSON? Is this easy
> to patch in the Xstream code or is this a limitation that is not easy to
> get around with?
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
>

--
View this message in context: http://old.nabble.com/XStream-no-in-enhanced-mode--tp35247159p35385086.html
Sent from the xstream - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Mentallurg
In reply to this post by Xybrek

For XML, the enhanced mode without default constructor is supported for some
JVMs only.

                if ( canUseSun14ReflectionProvider() ) {
                    String cls =
"com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider";
                    reflectionProvider = (ReflectionProvider)
loadClass(cls).newInstance();
                } else {
                    reflectionProvider = new PureJavaReflectionProvider();
                }

The list of supported JVMs contains Sun, IBM etc., but not Oracle.
You wrote you use Oracle JVM 1.7. Xstream believes it is not supported
and just uses the pure mode, not the enhanced mode.

A workaround:
System.setProperty("java.vm.vendor", "Sun");

A better solution:
Use a newer version of Xstream, where it is already fixed, like 1.4.1 or
newer.

--
View this message in context: http://old.nabble.com/XStream-no-in-enhanced-mode--tp35247159p35385090.html
Sent from the xstream - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Mentallurg
In reply to this post by Xybrek

For XML, the enhanced mode without default constructor is supported for some
JVMs only.

                if ( canUseSun14ReflectionProvider() ) {
                    String cls =
"com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider";
                    reflectionProvider = (ReflectionProvider)
loadClass(cls).newInstance();
                } else {
                    reflectionProvider = new PureJavaReflectionProvider();
                }

The list of supported JVMs contains Sun, IBM etc., but not Oracle.
You wrote you use Oracle JVM 1.7. Xstream believes it is not supported
and just uses the pure mode, not the enhanced mode.

A workaround:
System.setProperty("java.vm.vendor", "Sun");

A better solution:
Use a newer version of Xstream, where it is already fixed, like 1.4.1 or
newer.

--
View this message in context: http://old.nabble.com/XStream-no-in-enhanced-mode--tp35247159p35385097.html
Sent from the xstream - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Mentallurg
In reply to this post by Xybrek

For XML, the enhanced mode without default constructor is supported for some
JVMs only.

The list of supported JVMs contains Sun, IBM etc., but not Oracle.
You wrote you use Oracle JVM 1.7. Xstream believes it is not supported
and just uses the pure mode, not the enhanced mode.

A workaround:
System.setProperty("java.vm.vendor", "Sun");

A better solution:
Use a newer version of Xstream, where it is already fixed, like 1.4.1 or
newer.

--
View this message in context: http://old.nabble.com/XStream-no-in-enhanced-mode--tp35247159p35385098.html
Sent from the xstream - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream no in enhanced mode?

Mentallurg
In reply to this post by Xybrek

test
--
View this message in context: http://old.nabble.com/XStream-no-in-enhanced-mode--tp35247159p35385100.html
Sent from the xstream - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email