【发布时间】:2017-12-19 21:34:50
【问题描述】:
我正在使用 Apache Derby 数据库构建桌面应用程序。当我从 Netbeans 运行应用程序时,它工作正常,但是当我运行应用程序的可执行 jar 文件时,我得到一个“java.lang.ExceptionInInitializerError”“Caused by: java.lang.IllegalStateException: Attempting to perform an operation on a closed实体管理器。”
jar 文件是通过右键单击 Netbeans 中的项目,然后单击“清理并构建”来创建的。
我查看了以下资源,但信息不适用:
这是我第一次使用 Derby,所以我可能缺少一些简单的东西。
堆栈跟踪:
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
【问题讨论】:
-
这里发生了什么:
Main.java:70 -
它为程序创建主 gui 对象。在此过程中,它会多次调用数据库。
标签: java netbeans eclipselink