0

I am getting an error org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception caused by org.springframework.dao.InvalidDataAccessApiUsageException: Incompartible types found. Expected class java.lang.String for descriptionAbstract with name *_description_abstract, but found class java.util.ArrayList; nested exception is java.lang.IllegalArgumentException: Incompartible types found. Expected class java.lang.String for descriptionAbstract with name *_description_abstract, but found class java.util.ArrayList But I have descriptionAbstract as String

package com.myproject.platform.model;
import java.util.List;
import com.myproject.constant.DocumentStatus;
import com.google.gson.annotations.SerializedName;
public class DocumentDto {
    @SerializedName("document_id")
    private String documentId;
    @SerializedName("description_abstract")
    private String descriptionAbstract;
    public DocumentDto() {
    }
    public String getDocumentId() {
        return documentId;
    }
    public String getDescriptionAbstract() {
        return descriptionAbstract;
    }
    public static class Builder {
        private String documentId;
        private String descriptionAbstract;
        public Builder documentId(String documentId) {
            this.documentId = documentId;
            return this;
        }
        public Builder descriptionAbstract(String descriptionAbstract) {
            this.descriptionAbstract = descriptionAbstract;
            return this;
        }
        public DocumentDto build() {
            return new DocumentDto(this);
        }
    }
    private DocumentDto(Builder builder) {
        this.documentId = builder.documentId;
        this.descriptionAbstract = builder.descriptionAbstract;
    }
}

If someone can point out what the issue is or need other files to see please let me know

ab AL
  • 31
  • 1
  • 9

1 Answers1

0

Expected class java.lang.String for descriptionAbstract with name *_description_abstract, but found class java.util.ArrayList Your java code expects this field in message to be type of String but message you received has this field as list. Java cannot create String from list and thats why it causes an Exception. Look if this message is correct format (maybe it was produces incorrectly) or change you field from String to ArrayList.

  • Thank you for your reply. I don't know from where I can see this message received field. Every other place where `descriptionAbstract` is mentioned it is of type String. And regarding your other suggestion I can not chenge the type from String to ArrayList because there are alot of fields that are of either type String or integer. – ab AL May 30 '21 at 11:35
  • If you are sure that it should be a String then i highly suggest to look at this https://stackoverflow.com/questions/10709533/is-it-possible-to-view-rabbitmq-message-contents-directly-from-the-command-line for example and try to look how this message looks on queue cause there is a missmatch between app that creates this message and youur app – Maciej Niedźwiedź May 30 '21 at 11:59