-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate with gwt and dozer
PostPosted: Tue Apr 14, 2009 8:33 am 
Newbie

Joined: Tue Apr 14, 2009 8:03 am
Posts: 2
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.dtd
Message: 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.dtd
Message: The markup declarations contained or pointed to by the document type declaration must be well-formed.



Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 11:12 am 
Newbie

Joined: Tue Apr 14, 2009 8:03 am
Posts: 2
I changed the xml file.

Code:
<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE mapping PUBLIC "-//DOZER//DTD MAPPINGS//EN"
  "http://dozer.sourceforge.net/schema/beanmapping.xsd">
<mappings>
   <mapping>
      <class-a>org.zuuli.client.hibernate.Benutzer</class-a>
      <class-b>org.zuuli.server.hibernate.Benutzer</class-b>
      <field>
         <a>id</a>
         <b>id</b>
      </field>
      <field>
         <a>nick</a>
         <b>nick</b>
      </field>
   </mapping>
</mappings>


Now the mistake is on line 2.


Code:
17:15:33,453 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:    2
URI:     http://dozer.sourceforge.net/schema/beanmapping.xsd
Message: The markup declarations contained or pointed to by the document type declaration must be well-formed.
15.04.2009 17:15:33 com.google.appengine.tools.development.ApiProxyLocalImpl log
SCHWERWIEGEND: [1239808533453000] 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:    2
URI:     http://dozer.sourceforge.net/schema/beanmapping.xsd
Message: The markup declarations contained or pointed to by the document type declaration must be well-formed.
   at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:360)
   at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:546)
   at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:166)
   at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
   at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
   at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
   at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
   at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
   at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
   at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
   at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
   at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
   at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
   at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
   at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
   at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:306)
   at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
   at org.mortbay.jetty.Server.handle(Server.java:313)
   at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
   at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:844)
   at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:644)
   at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:205)
   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
   at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
   at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)


Anybody an idea?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 11:19 am 
Newbie

Joined: Wed Apr 15, 2009 9:11 am
Posts: 2
Hi,

Im using gilead, an open source library : http://noon.gilead.free.fr/gilead/

No problem to use POJO on client and server


Top
 Profile  
 
 Post subject: Re: Hibernate with gwt and dozer
PostPosted: Wed Jun 03, 2009 3:29 am 
Newbie

Joined: Wed Jun 03, 2009 3:25 am
Posts: 2
Hi
I am also facing the same error. Please give me solution if you find.


Top
 Profile  
 
 Post subject: Re: Hibernate with gwt and dozer
PostPosted: Wed Jun 03, 2009 3:30 am 
Newbie

Joined: Wed Jun 03, 2009 3:25 am
Posts: 2
i am trying to map two objects with each other...using dozer mapping apis.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.