Nexus3 H2 Database Recovery Issue – Error on Startup After Recovery

Hello Team,

I am performing the recovery of my h2 db in nexus3. Here are the steps and current setup.

Environment:

  • Nexus Version: 3.70.1
  • H2 Version: 2.2.224
  • Java Version: 11
  • Deployment: OpenShift (Pod with PVC mounted)

Steps Performed for H2 DB Recovery

  1. Scaled down Nexus pod and opened a debug container.

  2. Ran H2 Recover tool:
    Shell

java -cp /sonatype/nexus/system/com/h2database/h2/2.2.224/h2-2.2.224.jar
org.h2.tools.Recover
-dir /nexus-data/db
-db nexus

→ Generated files: /nexus-data/db/nexus.h2.sql and nexus.h2.log.

  1. Renamed broken DB:
    Shell
    mv /nexus-data/db/nexus.mv.db /nexus-data/db/nexus.mv.db.broken

  2. Ran H2 RunScript to rebuild DB:
    Shell
    java -cp /sonatype/nexus/system/com/h2database/h2/2.2.224/h2-2.2.224.jar
    org.h2.tools.RunScript
    -url “jdbc:h2:/nexus-data/db/nexus”
    -user sa -password “”
    -script /nexus-data/db/nexus.h2.sql

  3. Scaled Nexus pod back up.


Issue Observed

On startup, Nexus fails with:

org.sonatype.nexus.datastore.api.DataAccessException:
Error querying database. Cause: org.apache.ibatis.executor.result.ResultMapException:
Cannot deserialize value of type `java.util.HashSet<java.lang.Object>` from String value
(token JsonToken.VALUE_STRING)
...
SQL: SELECT * FROM user_role_mapping WHERE user_id = ? AND source = ?;

Expected Outcome

Nexus should start successfully after H2 recovery.

Actual Outcome

Startup fails due to JSON deserialization error in ROLES column of user_role_mapping table.


Questions for Support

  • Is this error caused by data corruption during recovery?
  • Is there an official Sonatype-supported procedure for H2 DB recovery in Nexus 3.70.1?
  • Should we apply any schema or data fixes (e.g., JSON column repair) before restarting Nexus?

Please help on what could be the solution or better approach to fix this issues.

Thanks

We do not recommend using H2 in Kubernetes as it does not guarantee graceful shutdown which can lead to database corruption.

If you’re a pro customer you can file a support ticket and our support team may be able to help recover.