Bom dia!
Eu tenho duas aplicação uma em java desktop e outra em Java Web
e quero fazer um post do meu desktop para a web via Rest do Vraptor.
Objeto que estou fazendo o post (mesmo no web e desktop):
package br.com.coliseu.model;
// Generated 24/08/2012 21:53:13 by Hibernate Tools 3.4.0.CR1
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
* Versaotabelas generated by hbm2java
*/
@Entity
@Table(name = "versaotabelas", schema = "coliseuarena")
@XStreamAlias("versaotabelas")
public class Versaotabelas implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -3553821381592680404L;
private long idversaotabelas;
private Filial filial;
private String nometb;
private String descricao;
private Integer versao;
private LocalDateTime dttimealter;
public Versaotabelas() {
}
public Versaotabelas(long idversaotabelas) {
this.idversaotabelas = idversaotabelas;
}
public Versaotabelas(long idversaotabelas, Filial filial, String nomeobj,
String descricao, Integer versao, LocalDateTime dttimealter) {
this.idversaotabelas = idversaotabelas;
this.filial = filial;
this.nometb = nomeobj;
this.descricao = descricao;
this.versao = versao;
this.dttimealter = dttimealter;
}
@Id
@Column(name = "idversaotabelas", unique = true)
public long getIdversaotabelas() {
return this.idversaotabelas;
}
public void setIdversaotabelas(long idversaotabelas) {
this.idversaotabelas = idversaotabelas;
}
@Column(name = "nomeobj", length = 40)
public String getNomeobj() {
return this.nometb;
}
public void setNomeobj(String nomeobj) {
this.nometb = nomeobj;
}
@Column(name = "descricao", length = 40)
public String getDescricao() {
return this.descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
@Column(name = "versao")
public Integer getVersao() {
return this.versao;
}
public void setVersao(Integer versao) {
this.versao = versao;
}
@ManyToOne
@JoinColumn(name = "estab")
public Filial getFilial() {
return filial;
}
public void setFilial(Filial filial) {
this.filial = filial;
}
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
@Column(name = "dttimealter")
public LocalDateTime getDttimealter() {
return dttimealter;
}
public void setDttimealter(LocalDateTime dttimealter) {
this.dttimealter = dttimealter;
}
}
Parte do java desktop (ele chama apliacação web e tal mas quando vai deserializar o objeto da pau)
restfulie = Restfulie.custom();
restfulie.getMediaTypes().register(new XmlMediaType().withTypes(Grupo.class, Produto.class, Item.class, Versaotabelas.class));
....
VersaoTabelasTemp.versaoItem = respositoryVersaotabelas.dateItem(2);
//pego a data
LocalDateTime date = VersaoTabelasTemp.versaoItem;
Versaotabelas versaotabelas = new Versaotabelas();
versaotabelas.setDttimealter(date);
Response response = restfulie.at("http://localhost:8080/CP/comunicador/atualizaItem").accept("application/xml").as("application/xml").post(versaotabelas);
Apl web:
@Post
@Path("atualizaItem")
@Consumes
public void atualizaItem(Versaotabelas versaotabelas) {
try {
sessionUser.setEstab(2);
List<Item> itemProduto = repositoryItem.atualizaItem(versaotabelas.getDttimealter());
...
CustomXStreamXMLDeserializer (Aqui que esta dando o erro)
package br.com.coliseu.util;
import br.com.caelum.vraptor.deserialization.XStreamXMLDeserializer;
import br.com.caelum.vraptor.http.ParameterNameProvider;
import br.com.caelum.vraptor.ioc.ApplicationScoped;
import br.com.caelum.vraptor.ioc.Component;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
@ApplicationScoped
@Component
public class CustomXStreamXMLDeserializer extends XStreamXMLDeserializer {
public CustomXStreamXMLDeserializer(ParameterNameProvider provider) {
super(provider, null);
}
/**
* Extension point to configure your xstream instance.
* @return the configured xstream instance
*/
@Override
protected XStream getXStream() {
XStream xStream = new XStream(new DomDriver());
xStream.alias("versaotabelas", br.com.coliseu.model.Versaotabelas.class);
return xStream;
}
}
Erro:
11:14:26,118 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CP].[default]] (http--127.0.0.1-8080-1) Servlet.service() for servlet default threw exception: com.thoughtworks.xstream.io.StreamException: : Element type "org.joda.time.chrono.ISOChronology" must be followed by either attribute specifications, ">" or "/>".
at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:86) [xstream-1.3.1.jar:]
....
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 297; Element type "org.joda.time.chrono.ISOChronology" must be followed by either attribute specifications, ">" or "/>".
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:244)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:285)
at com.thoughtworks.xstream.io.xml.DomDriver.createReader(DomDriver.java:79) [xstream-1.3.1.jar:]
... 47 more
Aguém sabe como eu resolvo isso?