I have tried following Migrating to a New Database
I am getting the following error when attempting to migrate to PostgreSQL. I am running this inside the Nexus 3 Pro Docker container by running the following commands.
docker-compose stop nexus
docker-compose run nexus bash
cd /nexus-data/db
curl https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/nxrm3-migrator/nexus-db-migrator-3.34.0-01.jar --output nexus-db-migrator-3.34.0-01.jar
java -Xmx4G -Xms4G -XX:MaxDirectMemorySize=4014M -jar nexus-db-migrator-3.34.0-01.jar --migration_type=postgres --db_url="jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=REDACTED” --debug
Failed to get driver instance for jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=<masked>
Full debug enabled output (I tried without debug first and got the same error)
bash-4.4$ java -Xmx4G -Xms4G -XX:MaxDirectMemorySize=4014M -jar nexus-db-migrator-3.34.0-01.jar --migration_type=postgres --db_url="jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=REDACTED” --debug
18:00:55 [main] INFO c.s.n.d.migrator.MigratorApplication - --content_migration parameter is absent. Setting it to true.
18:00:55 [main] INFO c.s.n.d.migrator.MigratorApplication - ------------------------------------------------------------
18:00:55 [main] INFO c.s.n.d.migrator.MigratorApplication - Java version: Red Hat, Inc. 1.8.0_282
18:00:55 [main] INFO c.s.n.d.migrator.MigratorApplication - JVM arguments: -Xmx4G -Xms4G -XX:MaxDirectMemorySize=4014M
18:00:55 [main] INFO c.s.n.d.migrator.MigratorApplication - Migrator arguments: --migration_type=postgres --db_url=jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=**** --debug --content_migration=true
18:00:55 [main] INFO c.s.n.d.migrator.MigratorApplication - ------------------------------------------------------------
18:00:56 [main] DEBUG o.s.b.c.l.ClasspathLoggingApplicationListener - Application started with classpath: [file:/nexus-data/db/nexus-db-migrator-3.34.0-01.jar]
18:00:56 [main] INFO c.s.n.d.migrator.MigratorApplication - Starting MigratorApplication v3.34.0-01 on 65f064d9db48 with PID 106 (/nexus-data/db/nexus-db-migrator-3.34.0-01.jar started by nexus in /nexus-data/db)
18:00:56 [main] INFO c.s.n.d.migrator.MigratorApplication - No active profile set, falling back to default profiles: default
18:00:56 [main] DEBUG o.s.boot.SpringApplication - Loading source class com.sonatype.nexus.db.migrator.MigratorApplication
18:00:56 [main] DEBUG o.s.b.c.c.ConfigFileApplicationListener - Loaded config file 'jar:file:/nexus-data/db/nexus-db-migrator-3.34.0-01.jar!/application.properties' (classpath:/application.properties)
18:00:57 [main] INFO o.s.s.c.ThreadPoolTaskScheduler - Initializing ExecutorService 'taskScheduler'
18:00:58 [main] WARN o.s.c.a.AnnotationConfigApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=<masked>
18:00:58 [main] INFO o.s.s.c.ThreadPoolTaskScheduler - Shutting down ExecutorService 'taskScheduler'
18:00:58 [main] DEBUG o.s.b.c.l.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/nexus-data/db/nexus-db-migrator-3.34.0-01.jar]
18:00:58 [main] DEBUG o.s.b.a.l.ConditionEvaluationReportLoggingListener -
============================
CONDITIONS EVALUATION REPORT
============================
<REMOVED>
18:00:58 [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=<masked>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.sonatype.nexus.db.migrator.MigratorApplication.main(MigratorApplication.java:62)
Caused by: org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=<masked>
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:59)
at org.springframework.boot.jdbc.AbstractDataSourceInitializer.initialize(AbstractDataSourceInitializer.java:71)
at org.springframework.boot.jdbc.AbstractDataSourceInitializer.afterPropertiesSet(AbstractDataSourceInitializer.java:55)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
... 15 common frames omitted
Caused by: java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc\:postgresql\://postgres\:5432/nexus3?user=nexus3&password=<masked>
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:114)
at com.zaxxer.hikari.pool.PoolBase.initializeDataSource(PoolBase.java:325)
at com.zaxxer.hikari.pool.PoolBase.<init>(PoolBase.java:114)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:108)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:158)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:116)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:79)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:47)
... 19 common frames omitted
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:315)
at com.zaxxer.hikari.util.DriverDataSource.<init>(DriverDataSource.java:106)
... 27 common frames omitted
docker-compose.yml
ersion: "3"
services:
# HTTPS proxy (not jwilder as it did not support the needed /v2 Docker redirect)
nginx-proxy:
image: nginx:latest
container_name: nginx-proxy
restart: always
ports:
- "80:80"
- "443:443"
volumes:
# Config
- /root/nexus3/default.conf:/etc/nginx/conf.d/default.conf
# Keep the dhparams (Should generate on the first run)
- dhparam:/etc/nginx/dhparam
# Fix the upload size issue
- /root/nexus3/my_custom_proxy_settings.conf:/etc/nginx/conf.d/my_custom_proxy_settings.conf:ro
# Push the certs to nginx
- /root/nexus3/certs:/etc/nginx/certs:ro
depends_on:
- nexus
# Artifact storage
nexus:
image: sonatype/nexus3:latest
container_name: nexus
restart: always
stop_grace_period: 2m
volumes:
- nexus-data:/nexus-data
- /mnt/nexus_mvn_mirror_repo_data:/nexus-mvn-mirror-repo-data
- /mnt/nexus_docker_repo_data:/nexus-docker-repo-data
- /mnt/nexus_mvn_repo_data:/nexus-mvn-repo-data
depends_on:
- postgres
# PostgreSQL Database
postgres:
image: postgres:latest
container_name: postgresql
restart: always
environment:
POSTGRES_USER: nexus3
POSTGRES_PASSWORD: REDACTED
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
nexus-data:
dhparam:
pgdata: