我正在为嵌入式 H2 数据库开发一个带有 Datanucleus 和 JDO 的桌面应用程序。当我从 Eclipse 运行它时一切正常,但是当我尝试从中制作可执行 jar 时它停止工作。我收到以下错误:
org.datanucleus.exceptions.NucleusUserException:已指定持久性进程使用名称为“jdo”的 ClassLoaderResolver,但 DataNucleus 插件机制尚未发现此问题。请检查您的 CLASSPATH 和插件规范。
当然它表明我没有正确配置一些东西 - 我错过了什么?如果我遗漏了一些大的东西,它根本就不起作用,所以我假设它是一个有缺陷的可执行 jar。我在其他应用程序中看到过这个错误,比如 JPOX,它已被修复,但没有给出任何解决方案。
整个错误堆栈跟踪:
Exception in thread "main" javax.jdo.JDOFatalInternalException: Unexpected exception caught.
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1193)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:808)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:701)
at db.PersistenceManagerFilter.init(PersistenceManagerFilter.java:44)
at Main.main(Main.java:26)
NestedThrowablesStackTrace:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.jdo.JDOHelper$16.run(JDOHelper.java:1965)
at java.security.AccessController.doPrivileged(Native Method)
at javax.jdo.JDOHelper.invoke(JDOHelper.java:1960)
at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1166)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:808)
at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:701)
at db.PersistenceManagerFilter.init(PersistenceManagerFilter.java:44)
at Main.main(Main.java:26)
Caused by: org.datanucleus.exceptions.NucleusUserException: Persistence process has been specified to use a ClassLoaderResolver of name "jdo" yet this has not been found by the DataNucleus plugin mechanism. Please check your CLASSPATH and plugin specification.
at org.datanucleus.NucleusContext.<init>(NucleusContext.java:233)
at org.datanucleus.NucleusContext.<init>(NucleusContext.java:196)
at org.datanucleus.NucleusContext.<init>(NucleusContext.java:174)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:364)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:294)
at org.datanucleus.api.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:195)
... 12 more
它指向的行是 PersistenceManagerFilter init 方法:
pmf = JDOHelper.getPersistenceManagerFactory(getProperties());
属性文件如下所示:
javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.api.jdo.JDOPersistenceManagerFactory
datanucleus.ConnectionDriverName=org.h2.Driver
datanucleus.ConnectionURL=jdbc:h2:datanucleus
datanucleus.ConnectionUserName=sa
datanucleus.ConnectionPassword=
我拥有来自 maven 的所有依赖项,目标是使用依赖项进行部署。依赖关系如 datanucleus 页面http://www.datanucleus.org/products/datanucleus/jdo/maven.html所述
有任何想法吗?