gwt-maven-插件和休眠

发布于 2024-12-28 14:22:11 字数 3236 浏览 1 评论 0原文

我在这里遇到了一些奇怪的问题,基本上,我将 hibernate 与 gwt、maven 和 gwt maven 插件一起使用。

但是,hibernate 在初始化期间失败,并显示以下消息:

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

谷歌搜索显示,这显然与 hibernate.jar 在类路径中出现两次有关。

我不完全理解 GWT 插件如何配置其类路径。我尝试将 hibernate-core 设置为 scope->provided ,这使得它不将其包含在包的 /lib 目录中,但是,在运行 jetty 时它仍然通过将其放入类路径中?

这是 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

如果有人设法让 GWT 、 maven 和 hibernate 能够很好地协同工作,那么对此的任何帮助将不胜感激。

更新 我认为我在这方面走错了路,也就是说,我不认为这是由于类路径上存在重复的 jar 文件造成的。

基本上,我添加了 hibernate-core 4.0.1 作为依赖项,如果我降级到 3.6.0 ,它可以正常工作。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软糯酥胸 2025-01-04 14:22:11

取决于您选择的 HQL 解析器实现。按如下方式更改属性名称:

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

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

参见“新增内容”中的第 6 点? Hibernate 4.0 部分链接

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文