h2database / h2database/h2database

How can I recovery the H2 database and why got this exception?

Open
#4,315 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.6k
Forks
1.3k
Avg merge
1d 2h
Merged PRs (30d)
9

Description

Hello all, I am trying to recover h2 database for nexus 3.70.1

Setup:
Nexus Version: 3.70.1
H2 Version: 2.2.224
java Version: 11

Steps followed to recover H2 database
Step1

Scale Down the Pod and go into debug container

Step2

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

After above command. nexus.h2.sql file will be generated
/nexus-data/db/nexus.h2.sql
/nexus-data/db/nexus.h2.log

Step3

mv /nexus-data/db/nexus.mv.db /nexus-data/db/nexus.mv.db.broken

Setp4
java -cp /plza/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

Step5
Come out of debug pod and scale up the pod.

Error i got

` ... 48 common frames omitted
2025-12-08 11:15:09,079+0100 ERROR [FelixStartLevel] *SYSTEM org.sonatype.nexus.extender.NexusContextListener - Failed to start nexus
org.sonatype.nexus.datastore.api.DataAccessException:

Error querying database. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'ROLES' from result set. Cause: java.sql.SQLException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.util.HashSet<java.lang.Object> from String value (token JsonToken.VALUE_STRING)

at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 1]

The error may exist in org/sonatype/nexus/internal/security/model/CUserRoleMappingDAO.xml
The error may involve org.sonatype.nexus.internal.security.model.CUserRoleMappingDAO.read
The error occurred while handling results
SQL: SELECT * FROM user_role_mapping WHERE user_id = ? AND source = ?;
Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'ROLES' from result set. Cause: java.sql.SQLException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type java.util.HashSet<java.lang.Object> from String value (token JsonToken.VALUE_STRING)

at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION disabled); line: 1, column: 1]
at org.sonatype.nexus.datastore.mybatis.DataAccessSqlSession.unwrapMyBatisException(DataAccessSqlSession.java:125)
at org.sonatype.nexus.datastore.mybatis.DataAccessSqlSession.selectList(DataAccessSqlSession.java:76)`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the H2 Recover and RunScript commands against the Nexus 3.70.1 recovery procedure, then inspect the reported ROLES deserialization failure. The payload names org/sonatype/nexus/internal/security/model/CUserRoleMappingDAO.xml and DataAccessSqlSession.java; done means identifying whether the failure is caused by recovery output or belongs in Nexus rather than H2.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.