Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xstream no-args constructor error

I'm getting the following error when it tries to create an instance of 'Transacao'

`Error: Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor : Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor `

---- Debugging information ----

message : Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor 

cause-exception : com.thoughtworks.xstream.converters.reflection.ObjectAccessException 

cause-message : Cannot construct br.com.cbmp.ecommerce.resposta.Transacao as it does not have a no-args constructor `

class : br.com.cbmp.ecommerce.resposta.Transacao 

required-type : br.com.cbmp.ecommerce.resposta.Transacao 

path : /transacao

I am aware that there's a bug with XStream 1.3.1 and JDK7, but I'm currently using XStream 1.3.1 and JDK6. Any ideas why this error is still happening?

Thanks

like image 426
luishenrique.ln Avatar asked Mar 08 '12 16:03

luishenrique.ln


1 Answers

3 solutions:

  1. Provide a no-args constructor (obvious)
  2. Make this object implement Serializable.
  3. Upgrade to xstream 1.4.4*

I use solution #2 all the time.

*I verified 1.2.2 doesn't work and 1.4.4 does work, haven't tried any versions in-between

like image 90
JRL Avatar answered Sep 27 '22 19:09

JRL