Question

I'm having a bit of a weird issue here, basically, im using hibernate together with gwt, maven and the gwt maven plugin.

However, hibernate fails during initialization with the following message:

[ERROR] Initial SessionFactory creation failed.org.hibernate.HibernateException: could not instantiate QueryTranslatorFactory: org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory

Googling around shows me that this is apparently related to hibernate.jar being on the classpath twice.

I don't entirely understand how the GWT plugin configures its classpath. I tried setting hibernate-core to scope->provided , this makes it not include it in the /lib directory of the package, but, it still passes puts it in the classpath when running jetty?

This is output from mvn gwt:run -X

C:\Program Files\Java\jdk1.6.0_27\jre\bin\java -Xmx512m -classpath C:\Develop\Git-repositories\PromoCMS\promocms\src\man\java;
C:\Develop\Git-repositories\PromoCMS\promocms\src\main\resources;
C:\Develop\Git-repositories\PromoCMS\promocms\target\promocms-1.0-SNAPSHOT\WEB-INF\classes;
C:\Users\secretusershyy\.m2\repository\com\google\gwt\gwt-servlet\2.4.0\gwt-servet-2.4.0.jar;
C:\Users\secretusershyy\.m2\repository\com\google\gwt\gwt-user\2.4.0\gwt-user-2.4.0.jar;
C:\Users\secretusershyy\.m\repository\org\hsqldb\hsqldb\2.2.6\hsqldb-2.2.6.jar;
C:\Users\secretusershyy\.m2\repository\org\hibernate\hibernate-core\4..1.Final\hibernate-core-4.0.1.Final.jar;
C:\Users\secretusershyy\.m2\repository\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar;
C:\Users\secretusershyy\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;
C:\Users\secretusershyy.m2\repository\org\jboss\spec\javax\transaction\jboss-transaction-api_1.1_spec\1.0.0.Final\jboss-transaction-api_1.1_spc-1.0.0.Final.jar;
C:\Users\secretusershyy\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;
C:\Users\secretusershyy\.m2\repositoy\xml-apis\xml-apis\1.0.b2\xml-apis-1.0.b2.jar;
C:\Users\secretusershyy\.m2\repository\org\hibernate\javax\persistence\hiberate-jpa-2.0-api\1.0.1.Final\hibernate-jpa-2.0-api-1.0.1.Final.jar;
C:\Users\secretusershyy\.m2\repository\org\jboss\logging\boss-logging\3.1.0.CR2\jboss-logging-3.1.0.CR2.jar;
C:\Users\secretusershyy\.m2\repository\org\javassist\javassist\3.15.0-GAjavassist-3.15.0-GA.jar;
C:\Users\secretusershyy\.m2\repository\org\hibernate\common\hibernate-commons-annotations\4.0.1.Finl\hibernate-commons-annotations-4.0.1.Final.jar;
C:\Users\secretusershyy\.m2\repository\org\slf4j\slf4j-api\1.6.4\slf4j-api-.6.4.jar;
C:\Users\secretusershyy\.m2\repository\log4j\log4j\1.2.16\log4j-1.2.16.jar;C:\Users\secretusershyy\.m2\repository\com\google\gwt\gwt-user\2.4.0\gwt-user-2.4.0.jar;
C:\Users\secretusershyy\.m2\repository\javax\validation\validation-api\1.0.0.GAvalidation-api-1.0.0.GA.jar;
C:\Users\secretusershyy\.m2\repository\javax\validation\validation-api\1.0.0.GA\validation-api-1.0.0.GA-sources.jar;

C:\Users\secretusershyy\.m2\repository\com\google\gwt\gwt-dev\2.4.0\gwt-dev-2.4.0.jar com.google.gwt.de.DevMode -war C:\Develop\Git-repositories\PromoCMS\promocms\target\promocms-1.0-SNAPSHOT -gen C:\Develop\Git-repositoris\PromoCMS\promocms\target\.generated -logLevel INFO -port 8888 -startupUrl PromoCMS.html mrkt.promocms.gwt.PromoCMS

Any help on this one would be appreciated if anybody have managed to get GWT , maven and hibernate to play nice together.

UPDATE I think I'm going the wrong way about this, meaning, I don't think it is due to duplicate jar files on the class path anyway.

Basically, I added hibernate-core 4.0.1 as a dependency, if I downgrade to 3.6.0 , it works fine.

Was it helpful?

Solution

Depending on your choice of HQL parser implementation. Change the property name as follows:

<property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>

or

    <property name="hibernate.query.factory_class">org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory</property>

See 6th point in Whats's new? section for Hibernate 4.0 link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top