I am required to upgrade a java application from java 8 to java 17. Somewhere in its source code, it uses apache solr version 6.2.1. specifically, we use EmbeddedSolrServer to cache some data in memory when the application runs.
Q. As I upgrade to java 17, it can not access the home directory specified as argument to core container in the code.
In Gradle build file for JvmArgs parameter - I tried to add the following --add-opens and --add-exports to enable access to jdk classes, but no progress :
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED
--add-exports java.base/jdk.internal.ref=ALL-UNNAMED
--add-exports java.base/sun.nio.ch=ALL-UNNAMED
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED
--add-exports java.sql/java.sql=ALL-UNNAMED
--add-exports java.base/java.net=ALL-UNNAMED
--add-exports java.base/java.nio=ALL-UNNAMED
--add-exports java.base/sun.net.www.protocol=ALL-UNNAMED
--add-exports java.base/java.lang=ALL-UNNAMED
--add-exports java.base/java.lang.reflect=ALL-UNNAMED
--add-exports java.base/java.lang.module=ALL-UNNAMED
--add-exports java.base/java.io=ALL-UNNAMED
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED
--add-opens java.base/jdk.internal.math=ALL-UNNAMED
--add-opens java.base/jdk.internal.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/sun.net.www.protocol=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.lang.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED
--add-opens java.rmi/sun.rmi.registry=ALL-UNNAMED
--add-opens java.rmi/sun.rmi.server=ALL-UNNAMED
--add-opens java.sql/java.sql=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/sun.net.www.protocol=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.lang.module=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED
--add-opens java.base/jdk.internal.math=ALL-UNNAMED
--add-opens java.base/jdk.internal.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
--add-opens java.base/java.nio=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/sun.nio.ch=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/sun.net.www.protocol=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
--add-opens java.base/java.lang.module=ALL-UNNAMED
--add-opens java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
Could somebody please help to solve this?
Below is the exception I get when I build my application:
Exception in thread "main" org.apache.solr.common.SolrException: SolrCore 'invoiceconfig' is not available due to init failure: JVM Error creating core [invoiceconfig]: null
at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:1095)
at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:146)
at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
at org.apache.solr.client.solrj.SolrClient.ping(SolrClient.java:926)
at com.drwp.invoicing.repository.impl.solr.EmbeddedSolrServerRegistry.lambda$getServer$0(EmbeddedSolrServerRegistry.java:67)
at com.drwp.invoicing.util.ObjectUtil.using(ObjectUtil.java:31)
at com.drwp.invoicing.repository.impl.solr.EmbeddedSolrServerRegistry.lambda$getServer$1(EmbeddedSolrServerRegistry.java:65)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at com.drwp.invoicing.repository.impl.solr.EmbeddedSolrServerRegistry.getServer(EmbeddedSolrServerRegistry.java:65)
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092)
at com.drwp.invoicing.repository.impl.solr.EmbeddedSolrServerRegistry.loadAllCores(EmbeddedSolrServerRegistry.java:79)
at com.drwp.invoicing.util.SolrUtil.createRegistryAndLoadAllCores(SolrUtil.java:64)
at com.drwp.invoicing.MisMain.main(MisMain.java:133)
Caused by: org.apache.solr.common.SolrException: JVM Error creating core [invoiceconfig]: null
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:856)
at org.apache.solr.core.CoreContainer.lambda$load$0(CoreContainer.java:494)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:229)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ExceptionInInitializerError
at org.apache.solr.core.MMapDirectoryFactory.init(MMapDirectoryFactory.java:51)
at org.apache.solr.core.SolrCore.initDirectoryFactory(SolrCore.java:528)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:724)
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:688)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:838)
... 6 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public jdk.internal.ref.Cleaner java.nio.DirectByteBuffer.cleaner() accessible: module java.base does not "opens java.nio" to unnamed module @7ea37dbf
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at org.apache.lucene.store.MMapDirectory.unmapHackImpl(MMapDirectory.java:345)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.apache.lucene.store.MMapDirectory.<clinit>(MMapDirectory.java:326)
... 11 more