This project used to work in Java 8 and NetBeans 8, but after upgrading my project to use Java 19 with NetBeans 16 I now see this error:
Exception in thread "AWT-EventQueue-0" Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: jdk.internal.loader.ClassLoaders$AppClassLoader@c387f44
Internal Exception: java.lang.NullPointerException: Cannot invoke "org.eclipse.persistence.internal.sessions.AbstractSession.getName()" because "this.session" is null
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 jdiskmark.EM.getEntityManager(EM.java:22)
at jdiskmark.DiskRun.findAll(DiskRun.java:146)
at jdiskmark.App.loadSavedRuns(App.java:219)
at jdiskmark.App.init(App.java:124)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.persistence.internal.sessions.AbstractSession.getName()" because "this.session" is null
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:2027)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:100)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:104)
Here is the throwing line:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("jDiskMarkPU");
em = emf.createEntityManager();
My persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="jDiskMarkPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:derbyDB;create=true"/>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
<property name="eclipselink.ddl-generation" value="create-or-extend-tables"/>
</properties>
</persistence-unit>
</persistence>
javax.persistence_2.1.1v201509150925.jar
project source is here: https://gitlab.com/jamesmarkchan/jDiskMark
I swapped in v4.0 of eclipselink.jar and that appears to resolve the null pointer thanks to hint from @Chris.
Currently seeing
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: No Persistence provider for EntityManager named jDiskMarkPU
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at jdiskmark.EM.getEntityManager(EM.java:22)
at jdiskmark.DiskRun.findAll(DiskRun.java:146)
at jdiskmark.App.loadSavedRuns(App.java:219)
at jdiskmark.App.init(App.java:124)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
I'm not sure if I need to update my META-INF/persistence.xml definition or if the libraries need to be upgraded. In the EclipseLink 4.0.1 download there are some libraries that I tried linking, but it did not resolve my PU issue.
The former libraries I had which I believe I need to replace
These are the libraries I tried linking in place of them.
But it seems that javax.persistence_2.1.1 is not substituted by the libraries provided by the EclipseLink package so I'm not sure which library I should use to replace it or am I mainly just needing to update my persistence.xml definition?
Certain I did not need to but I did switch to jdk 21 w NetBeans 20 to take advantage of the current LTS release.
Libraries that needed to be updated for my legacy ant build:
updated persistence.xml
also class definitions have been relocated to jakarta.persistence