Hey
I have made a gwt application with hibernate but I cant send the object from the client to server and from server to client now.
I searched for a solution and found dozer, but i cant use it because I havent found a good example :(.
Can anybody helps me?
This are my object on client!
Code:
package org.zuuli.client.hibernate;
import java.io.Serializable;
public class Benutzer implements Serializable {
private static final long serialVersionUID = 8195964455843286834L;
private int id;
private String nick;
public Benutzer() {
}
@Override
public String toString() {
// TODO Auto-generated method stub
return super.toString();
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public String getNick() {
return nick;
}
public void setNick(String nick) {
this.nick = nick;
}
}
And this is the object on server!
Code:
package org.zuuli.server.hibernate;
import java.io.Serializable;
import javax.persistence.*;
@Entity
public class Benutzer implements Serializable{
private static final long serialVersionUID = 8195964455843286834L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@SequenceGenerator(name = "benutzer_gen", sequenceName = "benutzer_id_seq")
private int id;
private String nick;
public Benutzer() {
}
@Override
public String toString() {
// TODO Auto-generated method stub
return super.toString();
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public String getNick() {
return nick;
}
public void setNick(String nick) {
this.nick = nick;
}
}
The dozer-mapping.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mappings PUBLIC "-//DOZER//DTD MAPPINGS//EN" "http://dozer.sourceforge.net/dtd/dozerbeanmapping.dtd">
<mappings>
<mapping>
<class-a>org.zuuli.client.hibernate.Benutzer</class-a>
<class-b>org.zuuli.client.hibernate.Benutzer</class-b>
<field>
<a>id</a>
<b>id</b>
</field>
<field>
<a>nick</a>
<b>nick</b>
</field>
</mapping>
</mappings>
And How I trie to convert the client object into a server object!
Code:
public static void registriereBenutzer(org.zuuli.client.hibernate.Benutzer benutzer){
List<String> myMappingFiles = new ArrayList<String>();
myMappingFiles.add("dozer-mapping.xml");
DozerBeanMapper mapper = new DozerBeanMapper();
mapper.setMappingFiles(myMappingFiles);
Benutzer bb = (Benutzer) mapper.map(benutzer, Benutzer.class);
System.out.println("Test: " + bb.getNick());
Session session = InitSessionFactory.getInstance().getCurrentSession();
Transaction tx = session.beginTransaction();
session.save(bb);
tx.commit();
}
I get this exception on the construct Benutzer bb = (Benutzer) mapper.map(benutzer, Benutzer.class);
Quote:
14:32:13,703 ERROR MappingFileReader:63 - Error while loading dozer mapping file url: [file:/C:/Dokumente und Einstellungen/aser/workspace/IHK_Pruefer/war/WEB-INF/classes/dozer-mapping.xml] : org.xml.sax.SAXException: Parsing Fatal Error
Line: 1
URI:
http://dozer.sourceforge.net/dtd/dozerbeanmapping.dtdMessage: The markup declarations contained or pointed to by the document type declaration must be well-formed.
14.04.2009 14:32:13 com.google.appengine.tools.development.ApiProxyLocalImpl log
SCHWERWIEGEND: [1239712333703000] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String org.zuuli.client.rpc.UebertrageDatenServer.greetServer(java.lang.String,org.zuuli.client.hibernate.Benutzer)' threw an unexpected exception: org.dozer.MappingException: org.xml.sax.SAXException: Parsing Fatal Error
Line: 1
URI:
http://dozer.sourceforge.net/dtd/dozerbeanmapping.dtdMessage: The markup declarations contained or pointed to by the document type declaration must be well-formed.