【发布时间】:2016-01-19 12:31:23
【问题描述】:
我正在尝试使用 IntelliJ IDEA 配置 JavaEE 项目。
我的配置:
- IDE Intellij (Jetbrains)
- Glassfish(EJB 容器)
- JPA 实体(休眠提供程序)
- 带有 WAMP 的数据库(在 persistence.xml 中配置)
不幸的是,当我启动我的项目时,会显示 404 页面: EJBTransactionRolledbackException。
我不明白这个异常或这个问题......也许这是我的文件 persistence.xml :
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="PU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.user" value="root" />
<property name="hibernate.connection.password" value="root" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/supbartering" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
我将它用于:
@PersistenceContext(unitName = "PU")
private EntityManager mEntityManager;
这是我第一次将 Intellij 与 JEE 项目和 GlassFish 服务器一起使用,但我无法实现良好的配置。
【问题讨论】:
-
你能发布你的完整例外吗?
-
您是否使用
transaction-type="JTA"而不是“JPA”进行了测试?检查:stackoverflow.com/questions/27713599/… -
@Baderous,它已经是 JTA 了:s ...错误 =)。
-
当有 JPA 标准的连接属性时,为什么要使用 Hibernate 特定的连接属性?没有意义。如果使用 JTA,则需要一个 jtaDataSource 而不是 connectionURL/user/password
-
@NeilStockton 谢谢。你能用 JTA 和 jtaDataSource 发布一个解释响应吗?我不知道我必须把 URL、用户、密码...和 jtaDataSource 放在哪里
标签: java xml jpa intellij-idea glassfish