java.lang.IllegalArgumentException: No serializer found for class org.springframework.data.mongodb.crossstore.MongoChangeSetPersister and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.company.User["itdChangeSetPersister"])

Spring JIRA | Ludovic Praud | 4 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    We got this stacktrace when trying to serialize our User @Entity to Json using Jackson through playframework. {code} java.lang.RuntimeException: java.lang.IllegalArgumentException: No serializer found for class org.springframework.data.mongodb.crossstore.MongoChangeSetPersister and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.company.User["itdChangeSetPersister"]) at play.libs.Json.toJson(Json.java:21) {code} I have listed getDeclaredFields and getDeclaredMethods of our User entity. It appears that there are some fields which are added by AOP. {code} User.class.getDeclaredFields[] public org.springframework.data.crossstore.ChangeSet com.company.User.changeSet public org.springframework.data.crossstore.ChangeSetPersister com.company.User.itdChangeSetPersister public org.springframework.data.crossstore.ChangeSetBackedTransactionSynchronization com.company.User.itdTransactionSynchronization private static final org.aspectj.lang.JoinPoint$StaticPart com.company.User.ajc$tjp_0 private static final org.aspectj.lang.JoinPoint$StaticPart com.company.User.ajc$tjp_1 User.class.getDeclaredMethods[] public org.springframework.data.crossstore.ChangeSet com.company.User.ajc$interFieldGet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$changeSet() public void com.company.User.ajc$interFieldSet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$changeSet(org.springframework.data.crossstore.ChangeSet) public org.springframework.data.crossstore.ChangeSetPersister com.company.User.ajc$interFieldGet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdChangeSetPersister() public void com.company.User.ajc$interFieldSet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdChangeSetPersister(org.springframework.data.crossstore.ChangeSetPersister) public org.springframework.data.crossstore.ChangeSetBackedTransactionSynchronization com.company.User.ajc$interFieldGet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdTransactionSynchronization() public void com.company.User.ajc$interFieldSet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdTransactionSynchronization(org.springframework.data.crossstore.ChangeSetBackedTransactionSynchronization) public org.springframework.data.crossstore.ChangeSet com.company.User.getChangeSet() public java.lang.Object com.company.User.get_persistent_id() public void com.company.User.itdPostLoad() public void com.company.User.itdPostPersist() public void com.company.User.itdPostRemove() public void com.company.User.itdPostUpdate() public void com.company.User.itdPreUpdate() public void com.company.User.setChangeSet(org.springframework.data.crossstore.ChangeSet) private static void com.company.User.ajc$preClinit() {code} Field such as {{public org.springframework.data.crossstore.ChangeSetPersister}} should not be public but private and maybe transient by default, as we don't want them to be serialized by Json beans tools and we don't want to be aware of their existence. As workaround, we will try to ignore these fields in our Json config. somehow related to org.springframework.data.mongodb.crossstore.MongoDocumentBacking

    Spring JIRA | 4 years ago | Ludovic Praud
    java.lang.IllegalArgumentException: No serializer found for class org.springframework.data.mongodb.crossstore.MongoChangeSetPersister and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.company.User["itdChangeSetPersister"])
  2. 0

    We got this stacktrace when trying to serialize our User @Entity to Json using Jackson through playframework. {code} java.lang.RuntimeException: java.lang.IllegalArgumentException: No serializer found for class org.springframework.data.mongodb.crossstore.MongoChangeSetPersister and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.company.User["itdChangeSetPersister"]) at play.libs.Json.toJson(Json.java:21) {code} I have listed getDeclaredFields and getDeclaredMethods of our User entity. It appears that there are some fields which are added by AOP. {code} User.class.getDeclaredFields[] public org.springframework.data.crossstore.ChangeSet com.company.User.changeSet public org.springframework.data.crossstore.ChangeSetPersister com.company.User.itdChangeSetPersister public org.springframework.data.crossstore.ChangeSetBackedTransactionSynchronization com.company.User.itdTransactionSynchronization private static final org.aspectj.lang.JoinPoint$StaticPart com.company.User.ajc$tjp_0 private static final org.aspectj.lang.JoinPoint$StaticPart com.company.User.ajc$tjp_1 User.class.getDeclaredMethods[] public org.springframework.data.crossstore.ChangeSet com.company.User.ajc$interFieldGet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$changeSet() public void com.company.User.ajc$interFieldSet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$changeSet(org.springframework.data.crossstore.ChangeSet) public org.springframework.data.crossstore.ChangeSetPersister com.company.User.ajc$interFieldGet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdChangeSetPersister() public void com.company.User.ajc$interFieldSet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdChangeSetPersister(org.springframework.data.crossstore.ChangeSetPersister) public org.springframework.data.crossstore.ChangeSetBackedTransactionSynchronization com.company.User.ajc$interFieldGet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdTransactionSynchronization() public void com.company.User.ajc$interFieldSet$org_springframework_data_mongodb_crossstore_MongoDocumentBacking$org_springframework_data_mongodb_crossstore_DocumentBacked$itdTransactionSynchronization(org.springframework.data.crossstore.ChangeSetBackedTransactionSynchronization) public org.springframework.data.crossstore.ChangeSet com.company.User.getChangeSet() public java.lang.Object com.company.User.get_persistent_id() public void com.company.User.itdPostLoad() public void com.company.User.itdPostPersist() public void com.company.User.itdPostRemove() public void com.company.User.itdPostUpdate() public void com.company.User.itdPreUpdate() public void com.company.User.setChangeSet(org.springframework.data.crossstore.ChangeSet) private static void com.company.User.ajc$preClinit() {code} Field such as {{public org.springframework.data.crossstore.ChangeSetPersister}} should not be public but private and maybe transient by default, as we don't want them to be serialized by Json beans tools and we don't want to be aware of their existence. As workaround, we will try to ignore these fields in our Json config. somehow related to org.springframework.data.mongodb.crossstore.MongoDocumentBacking

    Spring JIRA | 4 years ago | Ludovic Praud
    java.lang.IllegalArgumentException: No serializer found for class org.springframework.data.mongodb.crossstore.MongoChangeSetPersister and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.company.User["itdChangeSetPersister"])

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      No serializer found for class org.springframework.data.mongodb.crossstore.MongoChangeSetPersister and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: com.company.User["itdChangeSetPersister"])

      at play.libs.Json.toJson()
    2. Play
      Json.toJson
      1. play.libs.Json.toJson(Json.java:21)
      1 frame