jpa - Eclispelink PersistenceUnitLoadingException

标签 jpa jpa-2.0 eclipselink

我在下面的 Eclispelink 2.4.1 中遇到了 PersistenceUnitLoadingException,堆栈跟踪说明了什么?

code window

Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@45a877
Internal Exception: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@45a877
Internal Exception: java.lang.NullPointerException
    at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:118)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at com.mypkg.Main.<clinit>(Main.java:12)
Caused by: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@45a877
Internal Exception: java.lang.NullPointerException
    at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:321)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:272)
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:150)
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:135)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:76)
    ... 3 more
Caused by: java.lang.NullPointerException
    at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:79)
    at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.init(DirectoryArchive.java:96)
    at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:74)
    at org.eclipse.persistence.internal.jpa.deployment.DirectoryArchive.<init>(DirectoryArchive.java:54)
    at org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl.createArchive(ArchiveFactoryImpl.java:89)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.findPersistenceArchives(PersistenceUnitProcessor.java:297)
    ... 7 more
Could not find the main class: com.mypkg.Main.  Program will exit.

@编辑

我有下面 Eclipse 下的项目结构,它与作为持久性提供程序的 Hibernate 配合得很好。

bin
  |_META-INF
  |        |_persistence.xml
  |_com
      |_mypkg
            |_Main.class
            |_MyEntity.class

最佳答案

升级到 eclipselink 到以下版本为我解决了这个问题:

<dependency>
    <groupId>org.eclipse.persistence</groupId>
    <artifactId>org.eclipse.persistence.jpa</artifactId>
    <version>2.7.3</version>
</dependency>

关于jpa - Eclispelink PersistenceUnitLoadingException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13404422/

相关文章:

postgresql - 如何向 jpa/hibernate 查询提供 LocalDateTime?

在一个实体中 hibernate 多个自然 id

java - 在 OneToMany 和 ManyToMany 映射中获取 StackOverflow

java - 为什么使用 JPA/Eclipselink/Texo 进行批量插入比使用纯 JDBC 插入慢得多(!)?

java - 如何在JPA中有效地截断多对多表?

java - Spring boot中的PostgreSQL继承命名问题

java - Hibernate 5 和类型化条件查询 (JPA2)

eclipselink - EclipseLink 中的 IdClass 有哪些要求?

java - 如何在不更改代码的情况下更改tomcat中eclipselink的日志级别?

从 java 8 迁移到 java 11 时出现 JPA/eclipselink 错误