如何在 Hibernate 中使用 TomEE [英] How to use TomEE with Hibernate
问题描述
我创建了一个非常简单的应用程序,带有持久化上下文(休眠作为提供者)来从数据库中读取一些值.我将 Eclipse 与 Maven 结合使用.
I have created very simple app with persistence context (hibernate as provider) to read some value from database. I use Eclipse with Maven.
首先,我明白
Caused by: org.apache.openejb.OpenEJBException: java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider:
并根据这个话题http://openejb.979440.n4.nabble.com/problem-with-hibernate-persistence-provider-td980429.html我排除了 hibernate-jpa-2.0-api.现在,我的依赖项看起来
and according to this topic http://openejb.979440.n4.nabble.com/problem-with-hibernate-persistence-provider-td980429.html I excluded hibernate-jpa-2.0-api. Now, my dependencies look
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.3.Final</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
</exclusion>
</exclusions>
</dependency>
现在,我不知道为什么...
Now, I don't know why...
Caused by: java.lang.ClassNotFoundException: org.hibernate.transaction.TransactionManagerLookup
但是 TransactionManagerLookup 在休眠核心.请问,谁能告诉我,在TomEE中使用pom.xml应该怎么看hibernate?
But TransactionManagerLookup is in hibernate-core. Please, can anybody tell me, how should look pom.xml to use hibernate in TomEE?
推荐答案
试试这个:
添加:
/lib/antlr-2.7.7.jar /lib/dom4j-1.6.1.jar /lib/ehcache-core-2.5.1.jar /lib/ehcache-terracotta-2.5.1.jar /lib/hibernate-commons-annotations-4.0.1.Final.jar /lib/hibernate-core-4.1.4.Final.jar /lib/hibernate-ehcache-4.1.4.Final.jar /lib/hibernate-entitymanager-4.1.4.Final.jar /lib/hibernate-validator-4.3.0.Final.jar /lib/jboss-logging-3.1.0.GA.jar /lib/terracotta-toolkit-1.4-runtime-4.1.0.jar
ehcache jars 可能是可选的,但没有尝试过没有它们.
The ehcache jars might be optional, but haven't tried without them.
删除(可选):
/lib/asm-3.2.jar /lib/bval-core-0.4.jar /lib/bval-jsr303-0.4.jar /lib/commons-lang-2.6.jar /lib/openjpa-2.2.0.jar /lib/serp-1.13.1.jar
这篇关于如何在 Hibernate 中使用 TomEE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!