【问题标题】:RunTimeException What's the cause?RunTimeException 是什么原因?
【发布时间】:2014-04-14 18:53:15
【问题描述】:

我尝试构建这个 jpa 项目,但遇到了同样的错误。 我更新了,改变了一切,仍然一无所获。我错过了什么?我只在库中使用 EclipseLink (JPA 2.0)。 NetBeans IDE 7.2。

An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.RuntimeException: Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element {http://xmlns.jcp.org/xml/ns/persistence}persistence was not found in the project
    at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:407)
    .
    .
    .

    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:541)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
Caused by: Exception [EclipseLink-25008] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: A descriptor with default root element {http://xmlns.jcp.org/xml/ns/persistence}persistence was not found in the project
    at org.eclipse.persistence.exceptions.XMLMarshalException.noDescriptorWithMatchingRootElement(XMLMarshalException.java:129)
    .
    .
    .

    at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.<init>(PersistenceUnitReader.java:71)
    at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:376)
    ... 49 more
C:\Users\drhorvath57\Desktop\nyomt\PizzaJPA\PizzaJPA\nbproject\build-impl.xml:926: The following error occurred while executing this line:
C:\Users\drhorvath57\Desktop\nyomt\PizzaJPA\PizzaJPA\nbproject\build-impl.xml:268: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)

persistence.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="PizzaJPAPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>logic.entity.Pizza</class>
    <class>logic.entity.Topping</class>
    <class>logic.entity.Combination</class>
    <properties>
      <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/PizzaJPA"/>
      <property name="javax.persistence.jdbc.password" value="APP"/>
      <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
      <property name="javax.persistence.jdbc.user" value="APP"/>
      <property name="eclipselink.ddl-generation" value="create-tables"/>
    </properties>
  </persistence-unit>
</persistence>

【问题讨论】:

    标签: java xml hibernate jpa runtimeexception


    【解决方案1】:

    您要么丢失了 persistence.xml,要么格式错误。如果您不确定如何创建文件,请查看example in eclipselink's site

    ****编辑****

    如果您使用的是 Netbeans,您应该查看您的 IDE 文档,了解如何生成 persistence.xml 文件,而不是自己创建。

    【讨论】:

    • 我试过了,但还是没有。有趣的是,它在开始时有效,但现在拒绝构建。
    【解决方案2】:

    我看到您正在使用带有schema version 2.1 的persistence.xml 文件,但是使用的是JPA API 2.0 版。因此,更新到更新的 API 或更改您的 persistence.xml 文件以符合 JPA 2.0 版本。

    【讨论】:

      猜你喜欢
      • 2017-04-10
      • 2016-08-28
      • 2016-09-01
      • 2011-12-04
      • 2012-07-08
      • 2011-08-29
      • 1970-01-01
      • 2016-11-18
      • 1970-01-01
      相关资源
      最近更新 更多