jpa - 自 Java 10.0 NullPointer 在搜索持久性时 - JPA eclipselink 2.6.5

标签 jpa eclipselink persistence java-10

我将一些带有 eclipselink 2.6.5 的 EJB 实体用于 Rest 服务(TomEE 服务器中的 Jersy)。

使用 jdk-1.8 它工作正常,但是使用新的 jdk-10.0 现在我在搜索持久性时遇到了 NullPointerException。

我的 JPA 环境是否有错误或不匹配?

谢谢

史蒂芬

Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.6.5.v20170607-b3d05bd): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: jdk.internal.loader.ClassLoaders$AppClassLoader@41906a77
    Internal Exception: java.lang.NullPointerException
        at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:115)
        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
        at de.company.test.simulation.session.MySimulationService.<init>(MySimulationService.java:50)
        at de.company.test.simulation.controller.MyController.<init>(MyController.java:81)
        at de.company.test.simulation.MySimulationLauncher.main(MySimulationLauncher.java:156)
    Caused by: java.lang.NullPointerException
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2030)
        at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:100)
        at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:104)

我的persitence.xml

http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" 版本="2.1">

<persistence-unit name="myUnitName" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>de.company.test.simulation.entities.ProjectEntity</class>

    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://mysql.mediatransfer.de/dbName?useUnicode=true&useJDBCCompliantTimezoneS‌​hift=true&useLegacyDatetimeCode=false&serverTimezone=UTC" />
        <property name="javax.persistence.jdbc.user" value="userName" />
        <property name="javax.persistence.jdbc.password" value="****" />

        <!-- EclipseLink should create the database schema automatically -->
        <property name="eclipselink.ddl-generation" value="none" />
        <property name="eclipselink.ddl-generation.output-mode" value="database" />
        <property name="eclipselink.logging.level" value="SEVERE" />
    </properties>
</persistence-unit>

下面是我的 Web 应用程序 ProjectEntity 中实体的示例。 这在 Java 1.8 中对我来说很好用。


    @Entity(name = "ProjectEntity")
    @Table(name = "project")
    public class ProjectEntity implements Serializable {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "id", nullable = false, unique = true, updatable = false)
        private Integer id; 
        @Column(name = "project_name", nullable = false, length = 256)
        @NotNull
        private String projectName; 
        public ProjectEntity() {}
        //

..

最佳答案

在我遇到同样的问题后,升级到 EclipseLink 2.7.3 为我解决了这个问题。

关于jpa - 自 Java 10.0 NullPointer 在搜索持久性时 - JPA eclipselink 2.6.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51245097/

相关文章:

java - 在 JPA 中使用可嵌入 ID 持久化 OneToMany

google-app-engine - GAE JPA DataNucleus 一对多对象创建

mysql - JPA 与 EclipseLink ManyToMany 关系不起作用

ios - 保存局部变量的值

java - 如何测试持久层(轻量级)

java - 获取嵌套实体数据导致 stackoverflow 错误

java - 使用 persistence.xml 时将 Hibernate 4.0 与 Tomcat 7 结合使用时出现 JndiException

java - JPA : weird Cascade delete behaviour, 一对多。使用两个单独的 DAO 时发生 FK 违规

EclipseLink 中的 JPA 静态元模型类在访问属性时抛出 NullPointerException

c++ - 支持多种持久化策略的类库