无法使用java 9(10)运行旧代码

时间:2018-03-25 10:01:29

标签: java java-9 datanucleus java-10

我有一个可执行jar,它是用java 6编译的,在这个项目中,datanucleus用作ORM(旧版本,1.1.6)。

使用java 6,7,8可以运行jar,但9(10)运行不正常:运行它我在各种类中获得了很多或类似错误:

javax.jdo.JDOFatalUserException: A property named javax.jdo.PersistenceManagerFactoryClass must be specified, or a jar file with a META-INF/services/javax.jdo.PersistenceManagerFactory entry must be in the classpath, or a property named javax.jdo.option.PersistenceUnitName must be specified.
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:856) ~[jdo2-api-2.3-eb.jar:na]
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:698) ~[jdo2-api-2.3-eb.jar:na]
        at app.services.DatabaseService.inizializza(DatabaseService.java:193) ~[MyJar.jar:na]
        at app.startup.DatabaseLoader.load(DatabaseLoader.java:49) ~[MyJar.jar:na]
        at app.startup.Startup.inizializzaDatabasePrincipale(Startup.java:148) [MyJar.jar:na]
        at app.startup.Startup.start(Startup.java:47) [MyJar.jar:na]
        at app.Test.main(Test.java:81) [MyJar.jar:na]
Caused by: javax.jdo.JDOException: Exception during population of metadata for MyClass1
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.initialiseProperties(JDOPersistenceManagerFactory.java:429) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:260) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:173) ~[datanucleus-core-1.1.6.jar:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
        at javax.jdo.JDOHelper$16.run(JDOHelper.java:1956) ~[jdo2-api-2.3-eb.jar:na]
        at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
        at javax.jdo.JDOHelper.invoke(JDOHelper.java:1951) ~[jdo2-api-2.3-eb.jar:na]
        at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1159) ~[jdo2-api-2.3-eb.jar:na]
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:839) ~[jdo2-api-2.3-eb.jar:na]
        ... 6 common frames omitted
Caused by: org.datanucleus.exceptions.NucleusUserException: Exception during population of metadata for app.dati.MyClass1
        at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2331) ~[datanucleus-core-1.1.6.jar:na]
        at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
        at org.datanucleus.metadata.MetaDataManager.populateAbstractClassMetaData(MetaDataManager.java:2316) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.metadata.MetaDataManager.populateFileMetaData(MetaDataManager.java:2153) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.metadata.MetaDataManager.initialiseFileMetaDataForUse(MetaDataManager.java:864) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:794) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.initialiseProperties(JDOPersistenceManagerFactory.java:425) ~[datanucleus-core-1.1.6.jar:na]
        ... 17 common frames omitted
Caused by: java.lang.NullPointerException: null
        at java.base/java.util.Arrays.binarySearch(Unknown Source) ~[na:na]
        at org.datanucleus.store.types.TypeManager.isDefaultEmbeddedType(TypeManager.java:225) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.metadata.AbstractMemberMetaData.populate(AbstractMemberMetaData.java:477) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.metadata.ClassMetaData.populateMemberMetaData(ClassMetaData.java:543) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:206) ~[datanucleus-core-1.1.6.jar:na]
        at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2322) ~[datanucleus-core-1.1.6.jar:na]
        ... 23 common frames omitted
javax.jdo.JDOFatalUserException: A property named javax.jdo.PersistenceManagerFactoryClass must be specified, or a jar file with a META-INF/services/javax.jdo.PersistenceManagerFactory entry must be in the classpath, or a property named javax.jdo.option.PersistenceUnitName must be specified.
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:856)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:698)
        at app.services.DatabaseService.inizializza(DatabaseService.java:193)
        at app.startup.DatabaseLoader.load(DatabaseLoader.java:49)
        at app.startup.Startup.inizializzaDatabasePrincipale(Startup.java:148)
        at app.startup.Startup.start(Startup.java:47)
        at app.Test.main(Test.java:81)
NestedThrowablesStackTrace:
javax.jdo.JDOException: Exception during population of metadata for app.dati.MyClass1
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.initialiseProperties(JDOPersistenceManagerFactory.java:429)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:260)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:173)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at javax.jdo.JDOHelper$16.run(JDOHelper.java:1956)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javax.jdo.JDOHelper.invoke(JDOHelper.java:1951)
        at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1159)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:839)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:698)
        at app.services.DatabaseService.inizializza(DatabaseService.java:193)
        at app.startup.DatabaseLoader.load(DatabaseLoader.java:49)
        at app.startup.Startup.inizializzaDatabasePrincipale(Startup.java:148)
        at app.startup.Startup.start(Startup.java:47)
        at app.Test.main(Test.java:81)
NestedThrowablesStackTrace:
Exception during population of metadata for app.dati.MyClass1
org.datanucleus.exceptions.NucleusUserException: Exception during population of metadata for app.dati.MyClass1
        at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2331)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at org.datanucleus.metadata.MetaDataManager.populateAbstractClassMetaData(MetaDataManager.java:2316)
        at org.datanucleus.metadata.MetaDataManager.populateFileMetaData(MetaDataManager.java:2153)
        at org.datanucleus.metadata.MetaDataManager.initialiseFileMetaDataForUse(MetaDataManager.java:864)
        at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:794)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.initialiseProperties(JDOPersistenceManagerFactory.java:425)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:260)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:173)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at javax.jdo.JDOHelper$16.run(JDOHelper.java:1956)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javax.jdo.JDOHelper.invoke(JDOHelper.java:1951)
        at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1159)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:839)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:698)
        at app.services.DatabaseService.inizializza(DatabaseService.java:193)
        at app.startup.DatabaseLoader.load(DatabaseLoader.java:49)
        at app.startup.Startup.inizializzaDatabasePrincipale(Startup.java:148)
        at app.startup.Startup.start(Startup.java:47)
        at app.Test.main(Test.java:81)
Caused by: java.lang.NullPointerException
        at java.base/java.util.Arrays.binarySearch(Unknown Source)
        at org.datanucleus.store.types.TypeManager.isDefaultEmbeddedType(TypeManager.java:225)
        at org.datanucleus.metadata.AbstractMemberMetaData.populate(AbstractMemberMetaData.java:477)
        at org.datanucleus.metadata.ClassMetaData.populateMemberMetaData(ClassMetaData.java:543)
        at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:206)
        at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2322)
        ... 23 more
Nested Throwables StackTrace:
java.lang.NullPointerException
        at java.base/java.util.Arrays.binarySearch(Unknown Source)
        at org.datanucleus.store.types.TypeManager.isDefaultEmbeddedType(TypeManager.java:225)
        at org.datanucleus.metadata.AbstractMemberMetaData.populate(AbstractMemberMetaData.java:477)
        at org.datanucleus.metadata.ClassMetaData.populateMemberMetaData(ClassMetaData.java:543)
        at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:206)
        at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2322)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at org.datanucleus.metadata.MetaDataManager.populateAbstractClassMetaData(MetaDataManager.java:2316)
        at org.datanucleus.metadata.MetaDataManager.populateFileMetaData(MetaDataManager.java:2153)
        at org.datanucleus.metadata.MetaDataManager.initialiseFileMetaDataForUse(MetaDataManager.java:864)
        at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:794)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.initialiseProperties(JDOPersistenceManagerFactory.java:425)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.<init>(JDOPersistenceManagerFactory.java:260)
        at org.datanucleus.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:173)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at javax.jdo.JDOHelper$16.run(JDOHelper.java:1956)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javax.jdo.JDOHelper.invoke(JDOHelper.java:1951)
        at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1159)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:839)
        at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:698)
        at app.services.DatabaseService.inizializza(DatabaseService.java:193)
        at app.startup.DatabaseLoader.load(DatabaseLoader.java:49)
        at app.startup.Startup.inizializzaDatabasePrincipale(Startup.java:148)
        at app.startup.Startup.start(Startup.java:47)
        at app.Test.main(Test.java:81)

MyClass我收到错误的所有类都是通过datanucleus enhancer增强的类。

读了一下我尝试了这个:

java --illegal-access=permit --add-opens java.base/java.lang=ALL-UNNAMED -jar MyJar.jar

但结果相同。

我只是想用java 9运行这个可执行jar,而不是用java 9重新编译代码。

我知道从一个错误信息中给出答案但是有人有一些提示是很困难的吗? 代码很旧,使用的库也很旧,但它在java 8上运行正常,它在java 9上发生了变化,导致了问题。

更新: 根据要求使用完整的堆栈跟踪进行更新

0 个答案:

没有答案