0

I'm building a desktop application with an Apache Derby database. When I run the application from Netbeans, it works fine, but when I run the application's executable jar file, I get a "java.lang.ExceptionInInitializerError" "Caused by: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager."

The jar file was created by right-clicking the project in Netbeans, and clicking "Clean and Build".

I've looked at the the following resources, but the information wasn't applicable:

This is my first time using Derby, so it's probably something simple that I'm missing.

Stack trace:

java.lang.ExceptionInInitializerError
    at myProject.Main.start(Main.java:70)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: Attempting to execute an operation on a closed EntityManager.
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpenWithSetRollbackOnly(EntityManagerImpl.java:1923)
    at org.eclipse.persistence.internal.jpa.QueryImpl.getSingleResult(QueryImpl.java:508)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:400)
    at graphics.view.Read.<clinit>(Read.java:50)
    ... 10 more
Logan Grier
  • 21
  • 1
  • 3

1 Answers1

0

As it turns out, I made a (very) silly mistake in my code. I closed the EntityManager that I made the query on in the line before I called getSingleResult() on my query. I'm not quite sure why the program worked when I ran it from Netbeans, but the problem is solved now.

Logan Grier
  • 21
  • 1
  • 3