Nexus3 H2 Database Recovery Issue – Error on Startup After Recovery - Sonatype Nexus Repository - Sonatype Community

Nexus3 H2 Database Recovery Issue – Error on Startup After Recovery

post by Bhaskarrao_Krishnarao_Puppala on Dec 24, 2025

Hello Team,

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

Environment:


Steps Performed for H2 DB Recovery

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

  2. Ran H2 Recover tool:

   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:
   mv /nexus-data/db/nexus.mv.db /nexus-data/db/nexus.mv.db.broken
  1. Ran H2 RunScript to rebuild DB:
   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
  1. 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

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

Thanks

post by mpiggott on Jan 5

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.

post by Bhaskarrao_Krishnarao_Puppala on Jan 16

Hello @mpiggott

Thank you for the clarification regarding the risks of using the H2 database in Kubernetes environments. I understand that H2 does not guarantee graceful shutdown and can lead to corruption, and I appreciate the guidance.

However, this instance contains important repository metadata that we need to recover. I would be grateful if you could please help us with any possible recovery options. Even if the H2 database is in a corrupted state, any assistance, tools, or procedures you can provide to extract or repair as much data as possible would be extremely valuable.

We are fully aware of the limitations and do not expect guaranteed results just any expert guidance your team can offer.

Please let me know the next steps or any information you need from my side.

Thank you for your time and support.

post by mpiggott on Jan 16

I think you’ll want to take a look at the H2 documentation for their recovery tool