20

我无法正确获取此持久性文件...我在用作指南的书中找不到更多信息。我正在使用 MySQL 数据库。

<?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="a11_DA_g5_PU" transaction-type="JTA">
        <jta-data-source>a11_DA_g5</jta-data-source>
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>entities.Book</class>
        <class>entities.Author</class>
        <class>entities.Customer</class>
        <class>entities.Membership</class>
        <properties>
          <property name="eclipselink.target-database" value="DERBY"/>
          <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
          <property name="javax.persistence.jdbc.url" value="jdbc:mysql://studev.groept.be:3306/a11_DA_g5"/>
          <property name="javax.persistence.jdbc.user" value="a11_DA_g5"/>
          <property name="javax.persistence.jdbc.password" value="passwordhere"/>
          <property name="eclipselink.ddl-generation" value="create-tables"/>
        </properties>
      </persistence-unit>
    </persistence>

编辑

严重:DPL8015:存档 [EJBModule_jar] 中部署描述符文件 META-INF/persistence.xml 中的部署描述符无效。第 6 行第 15 列 -- cvc-complex-type.2.4.a:发现以元素“提供者”开头的无效内容。'{"http://java.sun.com/xml/ns/persistence":shared-cache-mode, "http://java.sun.com/xml/ns/persistence":validation-mode 之一, “http://java.sun.com/xml/ns/persistence”:properties}' 是预期的。

严重:DPL8005:部署描述符解析失败:cvc-complex-type.2.4.a:发现以元素“提供者”开头的无效内容。'{"http://java.sun.com/xml/ns/persistence":shared-cache-mode, "http://java.sun.com/xml/ns/persistence":validation-mode 之一, “http://java.sun.com/xml/ns/persistence”:properties}' 是预期的。

严重:部署应用程序时出现异常 [VaadinTestApp]

严重:org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:发现以元素“提供者”开头的无效内容。'{"http://java.sun.com/xml/ns/persistence":shared-cache-mode, "http://java.sun.com/xml/ns/persistence":validation-mode 之一, “http://java.sun.com/xml/ns/persistence”:properties}' 是预期的。java.io.IOException:org.xml.sax.SAXParseException:cvc-complex-type.2.4.a:发现以元素“提供者”开头的无效内容。'{"http://java.sun.com/xml/ns/persistence":shared-cache-mode, "http://java.sun.com/xml/ns/persistence":validation-mode 之一, “http://java.sun.com/xml/ns/persistence”:properties}' 是预期的。

4

2 回答 2

49

内部元素的顺序<persistence-unit>很重要,<jta-data-source>应该遵循<provider>

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
<jta-data-source>a11_DA_g5</jta-data-source>         
于 2012-06-18T14:28:21.853 回答
9

正如XSD所说,<provider>元素必须在<jta-data-source>元素之前。

于 2012-06-18T14:30:25.567 回答