gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 03:33:04 25 4
gpt4 key购买 nike

我将一些带有 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com