nexus-public icon indicating copy to clipboard operation
nexus-public copied to clipboard

Nexus migration for OrientDB to H2 for 3.70.1-02 fails as nexus-db-migrator is version 3.70.1-03

Open ashleyw-gh opened this issue 1 year ago • 42 comments

hi,

We have Nexus OSS deployed using docker using the latest 3.70 tag;

services:
  nexus:
    container_name: nexus
    restart: unless-stopped
    image: sonatype/nexus3:3.70.1
    user: nexus
    environment:
      - TZ=Pacific/Auckland
    volumes:
      - /home/ubuntu/nexus-data:/nexus-data
    ports:
      - 8081:8081

when Nexus starts up it shows as version OSS 3.70.1-02

We create a backup job for the OrientDB Nexus>create task>type: Admin - Export databases for backup taskname: backup backup location: /nexus-data/backup run task

so now we connect to the container and attempt to migrate the database to h2;

# docker exec -it nexus /bin/bash
$ cd /opt/sonatype/nexus
$ ./bin/nexus stop
$ cd /nexus-data/db
$ cp /nexus-data/backup/* .
$ curl -s -L -O https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.1-03.jar
$ java -Xmx2G -Xms2G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.1-03.jar --migration_type=h2 --healthcheck --debug
08:40:47 [main] WARN  c.s.n.d.migrator.MigratorApplication - Please ensure any Nexus Repository instance has been gracefully shut down before proceeding.
08:40:47 [main] INFO  c.s.n.d.migrator.MigratorApplication - Do you want to continue [y/n]?
y
The migration files in /nexus-data/db do not match the expected requirements: The backup versions are inconsistent.

As seen above the migration fails presumable as the migration tool is expecting the Nexus version to be 3.70.1-03 and not 3.70.1-02 but there is no docker tag for version 3.70.1-03. What is the solution here? We want to track the latest OSS release, but can only do that when we are using the H2 DB by the looks of things.

thanks.

ashleyw-gh avatar Aug 13 '24 20:08 ashleyw-gh

Hey, we have same issue

ddimych avatar Aug 15 '24 09:08 ddimych

@ashleyw-gh I followed your instructions and ended up with a different result:

13:01:46 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner                                                                                                                                                    
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776)                                                                                                                             
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: com.sonatype.nexus.db.migrator.exception.InvalidMigrationFilesException: 
The migration files in /nexus-data/db do not match the expected requirements: 
Existing database files found.

What files should be in /nexus-data/db before running the migration tool?

bash-4.4$ pwd
/nexus-data/db
bash-4.4$ ls -l
total 63924
drwxr-xr-x 2 nexus nexus     4096 Apr 16 10:02 OSystem
drwxr-xr-x 2 nexus nexus     4096 Aug 16 12:58 analytics
-rw-r--r-- 1 nexus nexus  7936132 Aug 16 13:00 analytics-2024-08-16-12-57-25-3.70.1-02.bak
drwxr-xr-x 2 nexus nexus    12288 Aug 16 12:58 component
-rw-r--r-- 1 nexus nexus   502559 Aug 16 13:00 component-2024-08-16-12-57-25-3.70.1-02.bak
drwxr-xr-x 2 nexus nexus    12288 Aug 16 12:58 config
-rw-r--r-- 1 nexus nexus   232393 Aug 16 13:00 config-2024-08-16-12-57-25-3.70.1-02.bak
-rw-r--r-- 1 nexus nexus        2 Aug 16 12:57 frozen.marker
drwxr-xr-x 2 nexus nexus     4096 Aug 16 13:01 logs
-rw-r--r-- 1 nexus nexus       93 Jun  6 15:08 model.properties
-rw-r--r-- 1 nexus nexus 56574550 Aug 16 13:01 nexus-db-migrator-3.70.1-03.jar
-rw-r--r-- 1 nexus nexus    16384 Aug 16 13:01 nexus.mv.db
drwxr-xr-x 2 nexus nexus     4096 Aug 16 12:57 security
-rw-r--r-- 1 nexus nexus   136473 Aug 16 13:00 security-2024-08-16-12-57-25-3.70.1-02.bak
bash-4.4$

delanym avatar Aug 16 '24 13:08 delanym

@ashleyw-gh I followed your instructions and ended up with a different result:

13:01:46 [main] ERROR o.s.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner                                                                                                                                                    
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776)                                                                                                                             
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: com.sonatype.nexus.db.migrator.exception.InvalidMigrationFilesException: 
The migration files in /nexus-data/db do not match the expected requirements: 
Existing database files found.

What files should be in /nexus-data/db before running the migration tool?

bash-4.4$ pwd
/nexus-data/db
bash-4.4$ ls -l
total 63924
drwxr-xr-x 2 nexus nexus     4096 Apr 16 10:02 OSystem
drwxr-xr-x 2 nexus nexus     4096 Aug 16 12:58 analytics
-rw-r--r-- 1 nexus nexus  7936132 Aug 16 13:00 analytics-2024-08-16-12-57-25-3.70.1-02.bak
drwxr-xr-x 2 nexus nexus    12288 Aug 16 12:58 component
-rw-r--r-- 1 nexus nexus   502559 Aug 16 13:00 component-2024-08-16-12-57-25-3.70.1-02.bak
drwxr-xr-x 2 nexus nexus    12288 Aug 16 12:58 config
-rw-r--r-- 1 nexus nexus   232393 Aug 16 13:00 config-2024-08-16-12-57-25-3.70.1-02.bak
-rw-r--r-- 1 nexus nexus        2 Aug 16 12:57 frozen.marker
drwxr-xr-x 2 nexus nexus     4096 Aug 16 13:01 logs
-rw-r--r-- 1 nexus nexus       93 Jun  6 15:08 model.properties
-rw-r--r-- 1 nexus nexus 56574550 Aug 16 13:01 nexus-db-migrator-3.70.1-03.jar
-rw-r--r-- 1 nexus nexus    16384 Aug 16 13:01 nexus.mv.db
drwxr-xr-x 2 nexus nexus     4096 Aug 16 12:57 security
-rw-r--r-- 1 nexus nexus   136473 Aug 16 13:00 security-2024-08-16-12-57-25-3.70.1-02.bak
bash-4.4$

I faced the same issue and had to decompile the jar to determine what they meant. You are not supposed to have your backups within your db folder. Move them (all files with .bak extension) out into their own folder and it should work. The migrator might trash this same folder on its own, so you might have to clean it manually after you run it.

Oh, and if anyone else randomly sees this message and wonders what the hell they mean with the migration step 6. Perform a full backup using normal backup procedures:

  1. Downgrade to 3.69.0
  2. Create a manual backup task whose location shall show at an empty folder in your volume (/opt/sonatype/sonatype-work/nexus3/penis). Run it, and if it succeeds, remove the task again.
  3. Upgrade back to latest
  4. Configure Postgres accordingly, otherwise it is stuck in a boot loop and you won't be able to properly use the console (as yo get kicked out)
  5. Follow the remaining steps, the commands from OP helped me with that

If you get lucky as I am, this is the step where you get greeted with Migration to an external database requires Nexus Repository Manager Pro🙃 Fortunately migration to H2 worked just fine at this stage.

MrEAlderson avatar Aug 18 '24 11:08 MrEAlderson

thanks @MrEAlderson, it was exactly as you suggested. When I ran the migrator from the /nexus-data/backup directory then it worked as expected so nice work! I moved the nexus.mv.db to the /nexus-data/db afterwards then reconfigured the nexus.properties file to have the; nexus.datastore.enabled=true and Nexus came up as expected, and I was then able to migrate it to the latest nexus release. for anyone else struggling with this, my build notes are below;

  1. Start off with the latest relese that supports OrientDB (3.70.1);
# vi /home/ubuntu/docker-compose.yml
services:
  nexus:
    container_name: nexus
    restart: unless-stopped
    image: sonatype/nexus3:3.70.1
    user: nexus
    environment:
      - TZ=Pacific/Auckland
    volumes:
      - /home/ubuntu/nexus-data:/nexus-data
    ports:
      - 8081:8081
  1. Bring container up;
# cd /home/ubuntu
# docker-compose up -d
  1. Create backup task for OrientDB and run it Nexus>create task>type: Admin - Export databases for backup taskname: backup backup location: /nexus-data/backup
  2. Pop inside the container, check the backup files are located as expected and run the migrator and copy the migrated file to the /nexus-data/db folder and exit the container.
# docker exec -it nexus /bin/bash
$ /opt/sonatype/nexus/bin/nexus stop
$ cd /nexus-data/backup
$ ls -l
-rw-r--r-- 1 nexus nexus 14862329 Aug 19 00:26 analytics-2024-08-19-12-26-21-3.70.1-02.bak
-rw-r--r-- 1 nexus nexus 56446663 Aug 19 00:26 component-2024-08-19-12-26-21-3.70.1-02.bak
-rw-r--r-- 1 nexus nexus   201734 Aug 19 00:26 config-2024-08-19-12-26-21-3.70.1-02.bak
-rw-r--r-- 1 nexus nexus   127789 Aug 19 00:26 security-2024-08-19-12-26-21-3.70.1-02.bak
$ curl -s -L -O https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.1-03.jar
$ java -Xmx2G -Xms2G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.1-03.jar --migration_type=h2
12:29:47 [main] WARN  c.s.n.d.migrator.MigratorApplication - Please ensure any Nexus Repository instance has been gracefully shut down before proceeding.
12:29:47 [main] INFO  c.s.n.d.migrator.MigratorApplication - Do you want to continue [y/n]?
y
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - Migration job finished at Mon Aug 19 12:30:35 NZST 2024
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - Migration job took 23 seconds to execute
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - 86289 records were processed
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - 7 records were filtered
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - 0 records were skipped
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - 86282 records were migrated
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - Created 'Rebuild repository browse' and 'Rebuild repository search' tasks. They will automatically one-time run after starting your Nexus Repository instance.
12:30:35 [main] INFO  c.s.n.d.m.l.ProvidingJobInfoListener - Migrated the following formats: [APT, COCOAPODS, CONAN, CONDA, DOCKER, GITLFS, GO, HELM, MAVEN2, NPM, NUGET, P2, PYPI, R, RAW, RUBYGEMS, YUM]
$ /opt/sonatype/nexus/bin/nexus stop
$ ls -l nexus.mv.db
-rw-r--r-- 1 nexus nexus 117149696 Aug 19 00:30 nexus.mv.db
$ cp nexus.mv.db /nexus-data/db
$ exit
  1. Bring down container and modify Nexus to use H2 database
# docker-compose down
# vi /home/ubuntu/nexus-data/etc/nexus.properties
nexus.datastore.enabled=true
# docker-compose up -d
  1. Confirm Nexus still up and running on the 3.70.1 release except using H2 database.
# docker logs nexus|grep H2
2024-08-19 12:36:59,436+1200 INFO  [FelixStartLevel] *SYSTEM org.sonatype.nexus.datastore.DataStoreConfigurationDefaultSource - Loaded 'nexus' data store configuration defaults (Embedded H2)
2024-08-19 12:37:00,109+1200 INFO  [FelixStartLevel] *SYSTEM org.sonatype.nexus.datastore.mybatis.MyBatisDataStore - nexus - MyBatis databaseId: H2
  1. Modify docker-compose.yml file to track the 3.71.0 tag
# vi /home/ubuntu/docker-compose.yml
services:
  nexus:
    container_name: nexus
    restart: unless-stopped
    image: sonatype/nexus3:3.71.0
    user: nexus
    environment:
      - TZ=Pacific/Auckland
    volumes:
      - /home/ubuntu/nexus-data:/nexus-data
    ports:
      - 8081:8081
  1. Bring container up to match docker-compose file
# docker-compose up -d
  1. Have a calming cup of tea and wonder why Sonatype didn't just include automatic db migration from OrientDB to H2 for those people using the OSS edition. Guess you get what you pay for!

ashleyw-gh avatar Aug 18 '24 23:08 ashleyw-gh

Hello,

I'm running a standalone instance. Not in docker. The migration fails for me with the a bunch of exceptions (instructions). The root exception is:

Caused by: java.util.jar.JarException: file:/path/to/nexus-db-migrator-3.70.1-03.jar has unsigned entries - META-INF/spring-configuration-metadata.json.

Here are the steps that I did:

  1. Create backup task for OrientDB and run it Nexus>create task>type: Admin - Export databases for backup taskname: backup backup location: /home/oracle/tmp/nexus-backup
  2. Ran the backup task
  3. cd /home/oracle/tmp/nexus-backup
  4. ls -ltr total 10096 -rw-r--r-- 1 oracle oinstall 151016 Aug 19 10:47 security-2024-08-19-10-47-09-3.70.1-02.bak -rw-r--r-- 1 oracle oinstall 279786 Aug 19 10:47 config-2024-08-19-10-47-09-3.70.1-02.bak -rw-r--r-- 1 oracle oinstall 1455470 Aug 19 10:47 component-2024-08-19-10-47-09-3.70.1-02.bak -rw-r--r-- 1 oracle oinstall 7759717 Aug 19 10:47 analytics-2024-08-19-10-47-09-3.70.1-02.bak
  5. sudo systemctl stop nexus
  6. curl -s -L -O https://download.sonatype.com/nexus/nxrm3-migrator/nexus-db-migrator-3.70.1-03.jar
  7. java -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.1-03.jar --migration_type=h2

This results in:

10:50:26 [main] WARN c.s.n.d.migrator.MigratorApplication - Please ensure any Nexus Repository instance has been gracefully shut down before proceeding. 10:50:26 [main] INFO c.s.n.d.migrator.MigratorApplication - Do you want to continue [y/n]? y 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - --content_migration parameter is absent. Setting it to true. 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - Force parameter wasn't found. Setting it to false by default. 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - ------------------------------------------------------------ 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - Java version: Oracle Corporation 11.0.23 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - JVM arguments: -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - Migrator arguments: --migration_type=h2 --content_migration=true --export_json=false --force=false 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - ------------------------------------------------------------ 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - Starting MigratorApplication v3.70.1-03 using Java 11.0.23 on artifacts.cmic.ca with PID 1091981 (/home/oracle/tmp/nexus-backup/nexus-db-migrator-3.70.1-03.jar started by oracle in /home/oracle/tmp/nexus-backup) 10:50:39 [main] INFO c.s.n.d.migrator.MigratorApplication - No active profile set, falling back to 1 default profile: "default" 10:50:41 [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchConfig': Unsatisfied dependency expressed through method 'setProcessorConfig' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processorConfig' defined in URL [jar:file:/home/oracle/tmp/nexus-backup/nexus-db-migrator-3.70.1-03.jar!/com/sonatype/nexus/db/migrator/config/ProcessorConfig.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cipherHandler' defined in class path resource [com/sonatype/nexus/db/migrator/config/CipherConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.sonatype.nexus.db.migrator.utils.CipherHandler]: Factory method 'cipherHandler' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pbeCipher' defined in class path resource [com/sonatype/nexus/db/migrator/config/CipherConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonatype.nexus.crypto.PbeCipherFactory$PbeCipher]: Factory method 'pbeCipher' threw exception; nested exception is java.lang.SecurityException: JCE cannot authenticate the provider BC 10:50:41 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 10:50:41 [main] ERROR o.s.boot.SpringApplication - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchConfig': Unsatisfied dependency expressed through method 'setProcessorConfig' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'processorConfig' defined in URL [jar:file:/home/oracle/tmp/nexus-backup/nexus-db-migrator-3.70.1-03.jar!/com/sonatype/nexus/db/migrator/config/ProcessorConfig.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cipherHandler' defined in class path resource [com/sonatype/nexus/db/migrator/config/CipherConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.sonatype.nexus.db.migrator.utils.CipherHandler]: Factory method 'cipherHandler' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pbeCipher' defined in class path resource [com/sonatype/nexus/db/migrator/config/CipherConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sonatype.nexus.crypto.PbeCipherFactory$PbeCipher]: Factory method 'pbeCipher' threw exception; nested exception is java.lang.SecurityException: JCE cannot authenticate the provider BC at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:768) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:720) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ... ... ... ... Caused by: java.util.jar.JarException: file:/home/oracle/tmp/nexus-backup/nexus-db-migrator-3.70.1-03.jar has unsigned entries - META-INF/spring-configuration-metadata.json at java.base/javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:463) at java.base/javax.crypto.JarVerifier.verifyJars(JarVerifier.java:318) at java.base/javax.crypto.JarVerifier.verify(JarVerifier.java:261) at java.base/javax.crypto.ProviderVerifier.verify(ProviderVerifier.java:129) at java.base/javax.crypto.JceSecurity.verifyProvider(JceSecurity.java:191) at java.base/javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:217) at java.base/javax.crypto.JceSecurity.getInstance(JceSecurity.java:141) ... 86 common frames omitted

Here are the info on the java process:

java --version java 11.0.23 2024-04-16 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.23+7-LTS-222) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.23+7-LTS-222, mixed mode)

Any help would be greatly appreciated.

majdi21 avatar Aug 19 '24 14:08 majdi21

Try to run this java command:

java --add-exports=java.base/sun.nio.ch=ALL-UNNAMED -Xmx16G -Xms16G -XX:+UseG1GC -XX:MaxDirectMemorySize=28672M -jar nexus-db-migrator-3.70.1-03.jar

This command at least lets me run the healthcheck with Java 17 (might also work with Java 11).

kcadmin-github avatar Aug 21 '24 07:08 kcadmin-github

Bit frightening that Nexus 3.69.0 was still using a version of OrientDB (2.2.37) from Sep 14, 2018

delanym avatar Aug 21 '24 07:08 delanym

@kcadmin-github I tried your command but I got the same results ...

majdi21 avatar Aug 21 '24 17:08 majdi21

@ashleyw-gh thank you, you saved my day: everything works for us with your detailed procedure.

guerricmerleHUG avatar Aug 21 '24 18:08 guerricmerleHUG

@majdi21 , just quickly googling "JCE cannot authenticate the provider BC" indicates to me there might be something wrong with your JRE/JDK configuration. Its for all these types of environmental issues, that you might have more joy switching to a docker container deployment at the same version as your existing configuration and just using your existing data - and it would also let you avoid that Oracle JDK licensing while you are at it!

ashleyw-gh avatar Aug 21 '24 20:08 ashleyw-gh

also just a heads up guys, Even though I was able to migrate the db from OrientDB to H2, there was now a secondary issue of primary key violation 500 errors in the logs when developers try to upload to the repository and it matched this; https://github.com/sonatype/nexus-public/issues/449 I think this migration is becoming more trouble than its worth!

ashleyw-gh avatar Aug 22 '24 00:08 ashleyw-gh

@majdi21 It should work fine with a more recent version of the JDK. 11.0.24 should probably work, but I have not tested that. We had the same problem with JDK8/17/21 releases from the beginning of the year. Switching to any recent release of either JDK should be fine.

moddx avatar Aug 22 '24 07:08 moddx

@ashleyw-gh @moddx I updated to JDK 11.0.24 but still have the same problem ... Searching online for "JCE cannot authenticate the provider BC", I got results that point to this being related to org.bouncycastle.jce.provider.BouncyCastleProvider. I'll keep digging into it.

If anybody has any ideas, please let me know.

@ashleyw-gh yeah, I hear you. I should switch this to use the docker container deployment ... But I guess I need the migration anyway to move my artifacts, no?

majdi21 avatar Aug 22 '24 13:08 majdi21

@ashleyw-gh @moddx I updated to JDK 11.0.24 but still have the same problem ...

I only tried with temurin builds of the JDK tbf, but I dont think that matters much. I just downloaded the tar from adoptium.net, extracted it and ran my-jdk17/bin/java -jar ... directly, to execute the migration tool.

moddx avatar Aug 22 '24 14:08 moddx

That temurin JDK absolutely does matter - I was able to repro the issue using Oracle JDK 8_411 and 11.0.24, and wasn't able to get past it until I tried running the migration tool with Teumrin's latest JDK 11, which finally worked.

csandwith avatar Aug 22 '24 21:08 csandwith

@ashleyw-gh thank you, you saved my day: everything works for us with your detailed procedure.

you may need to reset the auto increment values on the tables if you haven't already - see; https://github.com/sonatype/nexus-public/issues/449#issuecomment-2307334907 If you don't do this you may find that even though it all looks fine, the devs may not be able to uploads new artifacts/snapshots etc. If we'd have known about all these quirks we would have just held back on the upgrade by a few weeks to let the dust settle.

ashleyw-gh avatar Aug 23 '24 22:08 ashleyw-gh

Successfully upgraded docker-based Nexus 3.70.0-02 to 3.71.0-06 with OpenJDK11.0.24 To fix auto-increment values I have download H2 installer from http://www.h2database.com/html/download.html and start aforementioned script

#!/bin/bash

h2sql() { echo "> $@" >&2 java -cp /data/nexus-data/backup/h2/bin/h2-2.3.232.jar org.h2.tools.Shell -url jdbc:h2:/data/nexus-data/db/nexus -sql "$@" }

schema=$(h2sql "SCRIPT NODATA") echo "$schema" | while read line; do if [[ $line =~ ^CREATE\ CACHED\ TABLE\ \"PUBLIC\"\.\"([^\"]+)\" ]]; then tbl="${BASH_REMATCH[1]}" elif [[ $line =~ ^\"([^\"]+)\"\ .*\ GENERATED\ BY\ DEFAULT ]]; then col="${BASH_REMATCH[1]}" h2sql "ALTER TABLE $tbl ALTER COLUMN $col RESTART WITH SELECT max($col) + 1 FROM $tbl" fi done

Than enabled option nexus.datastore.enabled=true in nexus.properties and successfully started app

ddimych avatar Aug 25 '24 13:08 ddimych

Hey all, apologies for the friction. We're getting this onto a team's plate to investigate, we'll report back here when we have some more information.

mrprescott avatar Aug 27 '24 20:08 mrprescott

OrientDB 2.x isn't supported above java 11 and the migrator needs to read that database to do the migration, so if you're trying to migrate with java 17 things will probably not work.

Blacktiger avatar Aug 27 '24 20:08 Blacktiger

@Blacktiger from my own experience the migrator runs just fine with Java 17.

moddx avatar Aug 27 '24 20:08 moddx

@Blacktiger from my own experience the migrator runs just fine with Java 17.

Interesting, did you have to use additional parameters to make it work @moddx?

Blacktiger avatar Aug 27 '24 21:08 Blacktiger

Only one or two --add-opens for com.sun modules. Can check tomorrow if anyone's interested, but it's also not that hard to derive from the error message. You can always try with the health check of the migrator first.

moddx avatar Aug 27 '24 21:08 moddx

@ashleyw-gh Ignoring all previous comments: In the steps you take you are running the migration in the active db directory, not in your backup/migration directory location ...

In the instructions (https://help.sonatype.com/en/orient-3-70-java-8-or-11.html#migrating-from-orientdb-to-h2-252166) a 'clean working location' is mentioned, this is where the backup files must be and where the migration tool must be run.

vx-github avatar Aug 28 '24 11:08 vx-github

Hello,

Just an update. It turned out my whole problem was because I was using the Oracle JDK. When I switched to OpenJDK, the migrator worked fine.

Regards!

majdi21 avatar Aug 28 '24 15:08 majdi21

Closing ticket as problem resolved with help of community.

ashleyw-gh avatar Aug 28 '24 17:08 ashleyw-gh

After upgrading to version 3.71.0, I encountered this error when creating and opening a repository. I wonder if anyone has encountered it before Suppressed: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "org.sonatype.nexus.repository.content.facet. ContentFacetSupport.contentRepositoryId()" is null at org.sonaty

Little-orange-cat-QAQ avatar Aug 29 '24 06:08 Little-orange-cat-QAQ

@Little-orange-cat-QAQ, did you accidentally skip step 5. of https://github.com/sonatype/nexus-public/issues/451#issuecomment-2295431367

nexus.datastore.enabled=true

After that you may still hit https://github.com/sonatype/nexus-public/issues/449 and need the workaround form there.

hg77 avatar Sep 02 '24 13:09 hg77

I'm also using Nexus 3.70.1 and nexus-db-migrator-3.70.1-03.jar, but the migration fails:

13:34:42 [main] ERROR o.s.batch.core.step.AbstractStep - Encountered an error executing step checkModelVersionsStep in job migrationFromOrientNoExportJSONJob
com.sonatype.nexus.db.migrator.exception.WrongSchemaVersionException: Occurring schema versions that are not supported:
Upgrade ModelVersions{config='1.10', security='1.4', component='1.16', healthCheck='1.1', userToken='1.4', tags='1.1'}
Supported schema versions:
Upgrade ModelVersions{config='1.10', security='1.4', component='1.16', healthCheck='1.1', userToken='1.5', tags='1.1'}
Your OrientDB schemas are not supported by the current migrator version. Please update your Nexus Repository to the 3.70.1 version and use latest migrator version.

What's weird: There are only the databases analytics, component, config, and security. There is no database userToken.

The documentation is somewhat inconsistent: While the upgrade pages [1] and [2] indicate that the migration should be performed on the backup files, the legacy database migration guide suggests that the migration should be done from the db directory:

grafik grafik

The note regarding "Migrating a Docker Image to H2" is also misleading: You can't stop Nexus within a container running the official Docker image, as Nexus is the init process. /opt/sonatype/nexus/bin/nexus stop doesn't work. You have to stop the container and perform the migration on the host or within another container (e.g. using image eclipse-temurin:8-jre).

chkpnt avatar Sep 02 '24 14:09 chkpnt

I'm also using Nexus 3.70.1 and nexus-db-migrator-3.70.1-03.jar, but the migration fails:

13:34:42 [main] ERROR o.s.batch.core.step.AbstractStep - Encountered an error executing step checkModelVersionsStep in job migrationFromOrientNoExportJSONJob
com.sonatype.nexus.db.migrator.exception.WrongSchemaVersionException: Occurring schema versions that are not supported:
Upgrade ModelVersions{config='1.10', security='1.4', component='1.16', healthCheck='1.1', userToken='1.4', tags='1.1'}
Supported schema versions:
Upgrade ModelVersions{config='1.10', security='1.4', component='1.16', healthCheck='1.1', userToken='1.5', tags='1.1'}
Your OrientDB schemas are not supported by the current migrator version. Please update your Nexus Repository to the 3.70.1 version and use latest migrator version.

The documentation is somewhat inconsistent: While the upgrade pages [1] and [2] indicate that the migration should be performed on the backup files, the legacy database migration guide suggests that the migration should be done from the db directory:

grafik grafik

The note regarding "Migrating a Docker Image to H2" is also misleading: You can't stop Nexus within a container running the official Docker image, as Nexus is the init process. /opt/sonatype/nexus/bin/nexus stop doesn't work. You have to stop the container and perform the migration on the host or within another container (e.g. using image eclipse-temurin:8-jre).

We got the same problem with unsupported userToken='1.4'. I have discovered, this component are only supported by Pro version. We used Pro to evaluate its features and disabled it by enabling oss version feature with nexus.loadAsOSS=true To mitigate this issue, we have disabled OSS feature and started Pro version - it upgraded userToken to 1.5. Than enabled OSS version again and successfully migrated from OrientDB to H2

ddimych avatar Sep 02 '24 14:09 ddimych

Uh, yes, I've evaluated the pro version at some point in the past, too! Thanks for the hint!

chkpnt avatar Sep 02 '24 14:09 chkpnt