Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
Javers MongoRepository throwing IllegalArgumentException for Boolean JsonPrimitive

I'm trying to setup Javers using a MongoDB repository. I'm using version 2.9.1 for both javers-core and javers-persistence-mongo.

However, when I try to commit an entity with a Boolean field, the following exception is thrown:

java.lang.IllegalArgumentException: unsupported JsonElement type - JsonPrimitive
    at org.javers.repository.mongo.DocumentConverter.fromJsonElement(DocumentConverter.java:71) ~[javers-persistence-mongo-2.9.1.jar:?]
    at org.javers.repository.mongo.DocumentConverter.toDocument(DocumentConverter.java:20) ~[javers-persistence-mongo-2.9.1.jar:?]
    at org.javers.repository.mongo.DocumentConverter.fromJsonElement(DocumentConverter.java:39) ~[javers-persistence-mongo-2.9.1.jar:?]
    at org.javers.repository.mongo.DocumentConverter.toDocument(DocumentConverter.java:20) ~[javers-persistence-mongo-2.9.1.jar:?]
    at org.javers.repository.mongo.MongoRepository.writeToDBObject(MongoRepository.java:200) ~[javers-persistence-mongo-2.9.1.jar:?]
    at org.javers.repository.mongo.MongoRepository.persistSnapshots(MongoRepository.java:217) ~[javers-persistence-mongo-2.9.1.jar:?]
    at org.javers.repository.mongo.MongoRepository.persist(MongoRepository.java:74) ~[javers-persistence-mongo-2.9.1.jar:?]
    at org.javers.repository.api.JaversExtendedRepository.persist(JaversExtendedRepository.java:109) ~[javers-core-2.9.1.jar:?]
    at org.javers.core.JaversCore.commit(JaversCore.java:83) ~[javers-core-2.9.1.jar:?]
    at org.javers.core.JaversCore.commit(JaversCore.java:65) ~[javers-core-2.9.1.jar:?]

Looking into the private static Object fromJsonElement(JsonElement jsonElement) method in javers-persistence-mongo-2.9.1/DocumentConverter, there are only conversion methods for the JsonPrimitives String and Number (not Boolean).

Am I missing some configuration here?

MWE:

  public static void main(final String[] args) {
    final TestEntity testEntity = new TestEntity();
    testEntity.id = 12345L;
    testEntity.testBoolean = true;

    final MongoClient mongoClient = new MongoClient(...);
    final Javers javers = JaversBuilder.javers()
        .registerJaversRepository(new MongoRepository(mongoClient.getDatabase(...))).build();

    javers.commit("testAuthor", testEntity); // Throws IllegalArgumentException
  }

  @Entity
  static class TestEntity {

    @Id
    Long id;

    Boolean testBoolean;
  }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is a bug introduced in 2.9.1. Watch bug fixing progress in this issue https://github.com/javers/javers/issues/494

(edited) Fixed in 2.9.2

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!