I am just wondering if there are any plans to upgrade the JDK 11 to JDK 17. Has anyone in the community attempted to upgrade to JDK 17? If so, could you share your experiences and any challenges you encountered?
I believe I’ve answered this before. The short answer is: you should be able to use JDK 17 just fine right now if you need or want to use it for various reasons.
The long answer is that requiring a JDK 17 upgrade is a different story. This could be done, but would require some changes like from java ee to jakarta to use the future versions of libraries like jetty to jakarta.
I run into the following error with JDK 17, do you have any suguestion?
23:53:20.253 ERROR main .moqui.i.e.EntityDatasourceFactoryImpl Error connecting to DataSource transactional (h2), try 1 of 5: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @130161f7
23:53:25.257 INFO main .moqui.i.c.TransactionInternalBitronix Initializing DataSource transactional_DS (h2) with properties: [user:sa, url:jdbc:h2:/Users/weizhang/Projects/Moqui/moqui-framework-clean/runtime/db/h2/moqui;lock_timeout=30000]
23:53:25.261 ERROR main .moqui.i.e.EntityDatasourceFactoryImpl Error connecting to DataSource transactional (h2), try 2 of 5: java.lang.ExceptionInInitializerError: Exception bitronix.tm.internal.BitronixRuntimeException: error initializing JdbcProxyFactory [in thread "main"]
23:53:25.401 WARN c-jmx-worker b.tm.u.ManagementRegistrar Cannot execute ManagementRegisterCommand on object with name bitronix.tm:type=JDBC,UniqueName=transactional_DS,Id=0
javax.management.InstanceAlreadyExistsException: bitronix.tm:type=JDBC,UniqueName=transactional_DS,Id=0
at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:436) ~[?:?]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1865) ~[?:?]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:960) ~[?:?]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:895) ~[?:?]
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:320) ~[?:?]
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:523) ~[?:?]
at bitronix.tm.utils.ManagementRegistrar$ManagementRegisterCommand.runCommand(ManagementRegistrar.java:211) ~[moqui_temp10222920444365039530WEB-INF_lib_btm-3.0.0-20161020.jar.:3.0.0-SNAPSHOT]
at bitronix.tm.utils.ManagementRegistrar$ManagementCommand.run(ManagementRegistrar.java:254) [moqui_temp10222920444365039530WEB-INF_lib_btm-3.0.0-20161020.jar.:3.0.0-SNAPSHOT]
at bitronix.tm.utils.ManagementRegistrar.normalizeAndRunQueuedCommands(ManagementRegistrar.java:178) [moqui_temp10222920444365039530WEB-INF_lib_btm-3.0.0-20161020.jar.:3.0.0-SNAPSHOT]
at bitronix.tm.utils.ManagementRegistrar$1.run(ManagementRegistrar.java:78) [moqui_temp10222920444365039530WEB-INF_lib_btm-3.0.0-20161020.jar.:3.0.0-SNAPSHOT]
It could just be a problem with the H2 database so you could temporarily setup a postgres database using a postgres jdbc driver. I have a script for setting up the postgres driver here: moqui-runtime/lib/getJdbc.sh at acetousk · acetousk/moqui-runtime · GitHub
It pretty much uncharted territory, so it may be difficult to get setup.
Since Java 9, the module system can restrict reflective access to certain internal APIs. You can bypass this by adding JVM arguments to open the necessary packages.
Add the following JVM arguments to your startup script or IDE run configuration:
--add-opens java.base/java.lang=ALL-UNNAMED
Thanks Michael, it’s really helpful!
Of course. Happy to help