I am currently trying to use GWT and hibernate.
I have tested my RPC example without any hibernate code and it all
works fine.
But when I call some hibernate code that I have already testing in a
servlet
ie:
...
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import net.sf.hibernate.cfg.Configuration;
public class MyServiceImpl extends RemoteServiceServlet implements
MyService
{
public String myMethod (String s)
{
try {
Configuration cfg = new Configuration(); //This is the line
that is causing the error
...
return "a test string";
I get the following error :
com.google.gwt.user.client.rpc.InvocationException: The call failed on
the server; see server log for details.
Can anyone point me to an example of hibernate or JDBC with GWT or in
the right direction.
Thanks
Mark
When running in hosted mode, you must ensure that all needed jars are
included in the running environment (in eclipse by setting up the
'Run...'-Environment, or by adding the jars to the launch-script).
The GWT-Development Shell should provide information about Exceptions.
Of course, you also need the hinernate.cfg.xml (if you use one) in your
classpath. For hosted mode, this can be achieved by putting it inside
the 'bin' directory.
When running in productive mode inside a servlet container, you have to
place all jars and the hibernate.cfg.xml into the usual directories
(WEB-INF/lib for jars and lib/classes for hibernate.cfg.xml).
Please let me now, if this could help you to locate the error.
There is one thing, i found useful with hibernate and GWT: You can use
the Hibernate-Objects on your client-side GWT code by addind their
source to your GWT project and replacing 'implements Serializable' by
'implements IsSerializable'.
For information on how to add non-gwt sources to your project, refer to
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/2a7d78d1599713c6/bb17c06ce9c34b5a
For testing purposes one should use mock objects and only introduce
hibernate into the question when integrating, when it becomes obvious
that hibernate msut be available to the server. One needs to then use
the value object - dto pattern to pass values between both tiers.
mP
Thanks for the quick reply.
I have tried it both in hosted mode and running inside tomcat with the
same error.
The strange thing is that I am getting no error messages in the
GWT-Development Shell .
I'll let you know how I get on
Thanks
Mark
All I have to do now is to get it working using hibernate instead and I
will be a happy man.
Thanks
Mark
1) Hibernate puts java.sql.Timestamp instances into java.util.Date
persistent fields on retrieval from the database. These have to be
replaced with java.util.Date's before the instance can be sent to the
client app.
2) java.util.List fields end up as HibernatePersistentBag (or something
similar). These also have to be replaced with ArrayList instances
before the instance can be RPCed to the client.
3) I am using the EJB 3 persistence API but I cannot use the
annotations in my persistent classes as the GWT compiler is 1.4 only.
So I have to use an orm.xml file which is a pain.
4) The persistent classes cannot implement java.io.Serializable. This
mnight be a problem if they need to go to other sorts of clients (e.g.
Swing app) or whatever.
Cheers
David
Thanks for the tips.
I'm going to stick with trying to get the hibernate \ GWT working for
the time being.
If time beings to run short I might start coding the service using JDBC
which I got to work.
Instead of java.io.Serializable I set the persistant class to implement
implements com.google.gwt.user.client.rpc.IsSerializable.
I think I must be doing something fundamentally wong because even the
simple line :
SessionFactory session = sessionFactory.getCurrentSession();
causes the com.google.gwt.user.client.rpc.InvocationException: The call
failed on the server; see server log for details.
I can't find any logs in the tomcat folder and I have tried getting the
StackTrace from the onFailure method but I have no found anything
useful from this so far.
I'll let you know how I get on.
Thanks again.
Mark
package description
com.sp.schedacasa here I put SchedaCasa.gwt.xml
com.sp.schedacasa.server here I put SchedaCasaServiceImpl.java and
HibernateSessionFactory.java
com.sp.schedacasa.server.db.tabelle here I put hibernate.cfg.xml,
tabelname.hbm.xml and all my DAO files
com.sp.schedacasa.public generate by GWT compiler
com.sp.schedacasa.client the normal java class to implement widget
dataprovider async service ecc...
I'm sorry for my bad english hope that my post will help you.
For any problem contact me
Regards
Rinaldo
Try wrapping your server side code in a try { .. } catch (Throwable t)
{ t.printStackTrace(System.out); }.
You might be getting a NoSuchMethodError due to a missing jar or
something like that.
Cheers
David
A big thanks for all your help. I'll be able to use this in my project
now.
Thanks for the tip david. It was down to a couple of missing jars.
Thanks again.
Mark
you cannot use IsSerializable "instead of" Serializable for the
Hibernate classes. As far as Hibernate is concerned, your persistent
classes must implement Serializable or a sub-interface of Serializable.
GWT's IsSerializable is a totally different Interface.