标记为启用JTA的Wildfly数据源无法自动创建架构

时间:2017-04-05 10:57:47

标签: jpa database-schema jta wildfly-10

当数据源标有jta=true时,我有一个无法在Wildfly10中创建数据库架构的JPA单元。任何想法我怎么能解决这个问题?

堆栈跟踪:

javax.persistence.PersistenceException: Could not set provided connection [org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7@12f9ae77] to auto-commit mode (needed for schema generation)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator$ConnectionProviderJdbcConnectionAccess.<init>(JpaSchemaGenerator.java:644)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator$ConnectionProviderJdbcConnectionAccess.<init>(JpaSchemaGenerator.java:620)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.determineAppropriateJdbcConnectionContext(JpaSchemaGenerator.java:402)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.access$100(JpaSchemaGenerator.java:55)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator$GenerationProcess.execute(JpaSchemaGenerator.java:113)
at org.hibernate.jpa.internal.schemagen.JpaSchemaGenerator.performGeneration(JpaSchemaGenerator.java:65)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:885)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
..

Wildfly数据来源:

<datasource jta="true" jndi-name="java:/xxx" pool-name="xxx" enabled="true" use-ccm="true">
  <connection-url>jdbc:mariadb:failover://xxx/xxx</connection-url>
  <driver-class>org.mariadb.jdbc.Driver</driver-class>
  <driver>mariadb-java-client-1.5.8.jar</driver>
  ..
</datasource>

持久性XML:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="xxx" transaction-type="JTA">
    <jta-data-source>java:/xxx</jta-data-source>
    <class>xxx</class>
    <properties>
      <property name="javax.persistence.schema-generation.database.action" value="create" />
      <property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
    </properties>
  </persistence-unit>
</persistence>

0 个答案:

没有答案