Tuesday, October 1, 2013

Problem with GWT+Hibernate

hi folks,, 
i have a problem with integration of gwt & hibernate,,, 
when i use RPC without Hibernate & dataObj Movement over the network..it's work(for Object Like Inreger,String),, 
but when i add the hibernate to the project & want to move a myOwn Class Object over the net to the server for Saving it to the DB,,it's make a error,, 
this is my Error: 

ERROR: Unable to find type 'com.mySampleApplication.client.MySampleApplication' 
ERROR: Hint: Previous compiler errors may have made this type unavailable 
ERROR: Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly 
ERROR: Failed to load module 'MySampleApplication' from user agent 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/28.0.1500.71 Chrome/28.0.1500.71 Safari/537.36' at localhost:49745
 

this is Structure of My Project,,: 

https://www.dropbox.com/s/tgcpz8luyivcgxt/gwt%2Bhibernate.png 

this is my gwt Configuration File: 

  1. <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN"  
  2.         "http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/core/src/gwt-module.dtd">  
  3. <module rename-to="MySampleApplication">  
  4.   
  5.     <!-- Inherit the core Web Toolkit stuff.                  -->  
  6.     <inherits name='com.google.gwt.user.User'/>  
  7.   
  8.     <!-- Specify the app entry point class.                   -->  
  9.     <entry-point class='com.mySampleApplication.client.MySampleApplication'/>  
  10.   
  11.     <source path="com.mySampleApplication.client"/>  
  12.   
  13.     <!-- Specify the app servlets.                   -->  
  14.     <servlet path='/MySampleApplicationService' class='com.mySampleApplication.server.MySampleApplicationServiceImpl'/>  
  15.   
  16. </module>  

I have Entity CLass With name Student : 
  1. @Entity  
  2. @Table(name="STUDENT")  
  3. public class Student implements Serializable{  
  4.   
  5.     @Id  
  6.     @GeneratedValue  
  7.     Integer id;  
  8.     @Column  
  9.     String name;  
  10.     @Column  
  11.     String family;  
  12. //setter & getter  
  13. //constructor with 2 Argument,,& no Argument  
  14. } 
i Have Student Manager: 
  1. public class StudentManage{  
  2. private static SessionFactory factory;  
  3.     public StudentManage()  
  4.     {  
  5.         try{  
  6.   
  7.             factory = new AnnotationConfiguration().  
  8.                     addAnnotatedClass(Student.class).  
  9.                     configure("hibernate.cfg.gwt.xml").buildSessionFactory();  
  10.   
  11.         }catch (Throwable ex) {  
  12.             System.err.println("Failed to create sessionFactory object." + ex);  
  13.             throw new ExceptionInInitializerError(ex);  
  14.         }  
  15.     }  
  16.   
  17.     public void save(Student stu)throws Exception  
  18.     {  
  19.         Session session = factory.openSession();  
  20.         Transaction tx=session.beginTransaction();  
  21.         session.saveOrUpdate(stu);  
  22.         tx.commit();  
  23.         session.close();  
  24.     }  
  25. }  
this is implementation of My Service in the Server : 
  1. public class MySampleApplicationServiceImpl extends RemoteServiceServlet implements MySampleApplicationService {  
  2. @Override  
  3.     public String setStu(Student stu) {  
  4.   
  5.         //System.out.println("In the set");  
  6.         StudentManage studentManage=new StudentManage();  
  7.   
  8.         try {  
  9.             studentManage.save(stu);  
  10.         } catch (Exception e) {  
  11.             e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.  
  12.         }  
  13.         return "Data Saved in DB";  
  14.     }  
  15. }  

And this is my own Code for the Client Side to send the Object to the Server,, 
  1. public void onModuleLoad() {  
  2. button.addClickHandler(new ClickHandler() {  
  3.             @Override  
  4.             public void onClick(ClickEvent event) {  
  5.                 System.out.println("int the ClickEvent");  
  6.                 MySampleApplicationService.App.getInstance().setStu(stu, new AsyncCallback<String>() {  
  7.   
  8.                     @Override  
  9.                     public void onFailure(Throwable caught) {  
  10.                         Window.alert("Error");  
  11.   
  12.                     }  
  13.   
  14.                     @Override  
  15.                     public void onSuccess(String result) {  
  16.                         Window.alert("Data is in the DB..." + result);  
  17.                     }  
  18.                 });  
  19.             }  
  20.         });  
  21. }  

i'm wating for your Solutions,,

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment