Argh this is driving me nuts!
If I run my GWT project from a jar, it works correctly.
If I run it from eclipse, it fails with said error, cannot cast PostgreSQLDialect to Dialect.
But I have searched all of eclipse for a jar containing org.hibernate.dialect, and there's nothing!
I also deleted my project and rechecked it out of subversion, and the problem persisted.
Even better, as a test I did the following:
Code:
Object o = EntityManager.class.getClassLoader().loadClass("org.hibernate.dialect.PostgreSQLDialect").newInstance();
Class klass = o.getClass();
System.out.println(klass.getResource("/" + klass.getName().replace(".", "/") + ".class").toExternalForm());
klass = Dialect.class;
System.out.println(klass.getResource("/" + klass.getName().replace(".", "/") + ".class").toExternalForm());
Dialect d = (Dialect)o;
This results in:
Code:
jar:file:/home/{blah}/war/WEB-INF/lib/hibernate-core-4.0.1.Final.jar!/org/hibernate/dialect/PostgreSQLDialect.class
jar:file:/home/{blah}/war/WEB-INF/lib/hibernate-core-4.0.1.Final.jar!/org/hibernate/dialect/Dialect.class
Caused by: java.lang.ClassCastException: org.hibernate.dialect.PostgreSQLDialect cannot be cast to org.hibernate.dialect.Dialect
If anyone has any ideas, would love to hear them!