Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda