Skip to content

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

@Glenrodrigues

Description

@Glenrodrigues

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)`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions