首页 文章

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

提问于
浏览
1

我使用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“version =”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() {}
        //

..

1 回答

  • 0

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

相关问题