Overview
From nexus 3.69.0 and above, Database migrator supports Java 17. When executing the DB migrator we may see below exception.
10:46:55 [main] INFO o.s.batch.core.job.SimpleStepHandler - Executing step: [checkModelVersionsStep]
10:46:55 [main] ERROR o.s.batch.core.step.AbstractStep - Encountered an error executing step checkModelVersionsStep in job migrationFromOrientNoExportJSONJob
java.lang.ExceptionInInitializerError: null
at com.orientechnologies.orient.core.engine.local.OEngineLocalPaginated.startup(OEngineLocalPaginated.java:64)
at com.orientechnologies.orient.core.Orient.startEngine(Orient.java:930)
at com.orientechnologies.orient.core.Orient.loadStorage(Orient.java:523)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:173)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:154)
at com.sonatype.nexus.db.migrator.tasklet.ModelVersionsChecker.execute(ModelVersionsChecker.java:47)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:407)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:331)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:273)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:82)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:375)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:145)
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:258)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:208)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:152)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:68)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:68)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:139)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:320)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:149)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:140)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:128)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:220)
at jdk.proxy2/jdk.proxy2.$Proxy63.run(Unknown Source)
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.execute(JobLauncherApplicationRunner.java:199)
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.executeLocalJobs(JobLauncherApplicationRunner.java:173)
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.launchJobFromProperties(JobLauncherApplicationRunner.java:160)
at org.springframework.boot.autoconfigure.batch.JobLauncherApplicationRunner.run(JobLauncherApplicationRunner.java:155)
at com.sonatype.nexus.db.migrator.config.MigratorJobLauncherApplicationRunner.run(MigratorJobLauncherApplicationRunner.java:38)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:773)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:763)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at com.sonatype.nexus.db.migrator.MigratorApplication.main(MigratorApplication.java:117)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make public abstract jdk.internal.ref.Cleaner sun.nio.ch.DirectBuffer.cleaner() accessible: module java.base does not "exports sun.nio.ch" to unnamed module @7b3e2a8
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 com.orientechnologies.common.directmemory.OByteBufferPool.<clinit>(OByteBufferPool.java:188)
... 48 common frames omitted
10:46:55 [main] INFO o.s.batch.core.step.AbstractStep - Step: [checkModelVersionsStep] executed in 247ms
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Migration job finished at Sat Jul 13 10:46:55 EDT 2024
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Migration job took 1 seconds to execute
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 0 records were processed
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 0 records were filtered
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 0 records were skipped
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - 0 records were migrated
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - ------------------------------------------------------------
10:46:55 [main] INFO c.s.n.d.m.l.ProvidingJobInfoListener - Migration job finished with status FAILED.
Solution:
Add below JVM Option to the Java command for completing the migration.
$ /usr/lib/jvm/java-17-openjdk-arm64/bin/java --add-exports java.base/sun.nio.ch=ALL-UNNAMED -jar nexus-db-migrator-3.70.0-02.jar --migration_type=postgres --db_url="jdbc:postgresql://pql-host:5432/nexusdb?user=<psql_usr>&password=<psql_password>"
Note : Existing extracted database directories needs to be removed, before re-running the DB migrator.
$ rm -rf component security config analytics