I'm facing the same issue and was suspecting a class loading issue. I
thought I was inviting trouble when I would place the same Hibernate
annotated class in both the server side code and the GWT client side,
but until upgrading GWT 2.0 to GWT 2.4, I did not experience this
ClassCastException problem.
As Alexander has experienced, things work fine when I deploy the .war
to an external server, and only see problems running in the DevMode.
I see different classes not being cast-able depending on my
hibernate.cfg.xml.
I'm still trying to sort out how the switch from GWT 2.0 to 2.4 is a
factor because I made several changes, but I am glad to hear that I'm
not the only one thinking this is a classloader issue.
On Nov 18, 9:54 am, Thomas Broyer t.bro...@gmail.com wrote:
On Friday, November 18, 2011 2:21:33 PM UTC+1, Alexander Lochschmied wrote:
It only becomes:
Caused by: java.lang.ClassCastException:
org.hibernate.dialect.MySQL5Dialect cannot be cast to
org.hibernate.dialect.Dialect
We haven playing with those JARs as there may be incompatibilities (JPA 1
vs 2) I think. Currently we do *not *reference them
(hibernate-jpa-2.0-api, hibernate-validator and validation-api).
Could it be a class loading issue?
It's very likely the case yes; generally because the MySQL5Dialect comes
from the parent classloader of the one containing the Dialect class. Could
it be that some of your dependencies are not in the WEB-INF/lib?
IMO, when using Maven, you should really make at least 2 projects: one for
the server and one for the client (you can possibly make server depend on
client, but I'd rather make a third project shared that both client and
server depend on); and you launch the server using the jetty-maven-plugin
or whatever, and then run the DevMode in -noserver mode for the client-side
code.
The problem is that there's no scope=client and scope=server in Maven,
so everything in scope=compile or scope=runtime will be copied to your
webapp's WEB-INF/lib, as expected, but will *also* be in the classpath of
the DevMode, because there's no way to know whether your client-side code
needs them or not; that leads to having all server classes twice on the
classpath of the webapp (because it's a child classloader of the DevMode's
one).
--
You received this message because you are subscribed to the Google Groups
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.