I use for a Rest Service (Jersy in a TomEE Server) some EJB entities with eclipselink 2.6.5.
With jdk-1.8 it works fine, but with new jdk-10.0 now I got a NullPointerException while searching for persistence.
Is there an error or mismatch in my JPA environment?
Thank you
Steffen
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)
my 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&useJDBCCompliantTimezoneShift=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>
And here is an example for an entity in my web application, ProjectEntity. This works fine for me in 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() {} // ..