Steps to handle the error org.codehaus.jackson.map.exc.UnrecognizedPropertyException

Could you please assist me? I am encountering the following exception when trying to cast a JSON string to a custom Java object.

org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "acknowledgedby" (Class com.xchange.model.XchangeOutboundMessage), not marked as ignorable
 at [Source: java.io.StringReader@3452296e; line: 1, column: 34] (through reference chain: com.xchange.model.XchangeOutboundMessage["acknowledgedby"])

I have come across several links on StackOverflow recommending the @JsonIgnore annotation for the model's fields, but I cannot ignore this particular field.

public List getOutBoundMessageList(){
        List list=new ArrayList();
        ObjectMapper mapper = new ObjectMapper();
        XchangeOutboundMessage xchangeOutboundMessage=null;
        String json1=null;
        try {

            cluster = Cluster.builder().addContactPoint(contactPoints).build();

            session = cluster.connect(keySpaceName);

            cassandraOps = new CassandraTemplate(session);
            String queryString="Select JSON * from XchangeOutboundMessage";
            ResultSet result = session.execute(queryString);
            int i=0;
            String json1=null;
            for(Row row:result) {
                json1 = row.getString(i);
                xchangeOutboundMessage = mapper.readValue(json1, XchangeOutboundMessage.class);
                list.add(xchangeOutboundMessage);
                i++;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}

The error is occurring in the model class field and its corresponding getter and setter methods.

private String acknowledgedBy;
public String getAcknowledgedBy() {
        return acknowledgedBy;
    }
    public void setAcknowledgedBy(String acknowledgedBy) {
        this.acknowledgedBy = acknowledgedBy;
    }

Answer №1

An exception is being thrown due to Jack's mapper being case sensitive. By default, Cassandra converts all column names to lowercase, causing a mismatch between your field name (acknowledgedBy) and Cassandra's column name (acknowledgedby).

To resolve this issue, you can configure the Jackson mapper to match keys in a case-insensitive manner.

mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering an issue with GSON while attempting to convert an array of objects with

I'm trying to make a HTTP request using Retrofit that should return an array of objects, but unfortunately I'm encountering the following errors: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was ...

The search text box is mysteriously absent from each column in the datatables

I am utilizing jQuery Datatables to construct a table with data retrieved from MySQL. This is how my table appears: LOT_LOCATION, Zone Attribute, LOTID, Design_ID, Board_ID1, QA_WORK_REQUEST_NO, QA_CONTACT_NAME, QA_PROCESS_NAME, CURRENT_QTY, Date, Temp ...

Receive JSON data with camel-case in a Web API 2.0 using a model in pascal-case style

My attempt to execute a PUT call on my Web API involves configuring the WebApiConfig.cs file to send data back to my Web project in camel case format. config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesCont ...

Are there alternative, more dependable methods for executing a click command on an element in Headless Chrome using Selenium?

For the past two days, I have been struggling with a frustrating issue involving the click() command in Headless Chrome. Specifically, I have been trying to click on an Anchor (a) element with a href tag, and despite trying various suggestions found in dif ...

Utilizing a Spring Kafka listener to consume JSON data and automatically determine the corresponding domain object

I have a project where I need to process various types of JSON messages that will be published. Unfortunately, I cannot modify the publisher's code to include any headers. However, I am interested in utilizing @KafkaHandler to manage these different J ...

Tips for interfacing with Angular ColorPicker elements using Selenium WebDriver

Is there a way to automate interactions with Angular ColorPicker components using Selenium WebDriver? Since there is no text field input for hex codes, it relies solely on mouse clicks. For reference, you can check out this example: https://www.primeface ...

What is the purpose of parsing my array if they appear identical in the console?

While working on a D3 component, I came across an interesting question. Why do different arrays require different data treatment even if they all contain the same information? In the first case, I have a 'hardcoded' array that looks like this: ...

Effortless glide while dragging sliders with JavaScript

In the code below, an Object is looped through to display the object key in HTML as a sliding bar. jQuery(function($) { $('#threshold').change(updateThreshold); function updateThreshold () { var thresholdIndex = parseInt($(&apos ...

html line breaks $.parseJSON

Within my website, I am currently utilizing a TinyMCE window. The method involves PHP fetching an entry from the database, decoding it as JSON, and then having in-page JavaScript parse it. However, issues arise when there are elements like style='colo ...

What could be the reason why the editMessageText function in the Telegram API does not seem to work when the message contains a Custom Keyboard

Currently, I am working on developing a Telegram Bot that relies on POST/GET JSON queries with a custom Keyboard feature. One of the functionalities I need to implement is the ability to modify the text of messages sent by the bot using the editMessageText ...

Sorting of alphanumeric columns may not always be accurate

I am encountering an issue with sorting a list of invoice numbers that consist of both letters and digits. Despite expecting Invoice no - 192685 to appear before Invoice no - 19s100619916001 when sorting in descending order, the actual result is the opposi ...

Tips for extracting key/value pairs from a column containing JSON data in PostgreSQL

How can I extract values from a json column in my database? The values in this particular column are structured like the example below: column1 --------------------------------------------- "[{'name': 'Kate', 'po ...

Tips for effortlessly moving rows between Grid views using drag and drop functionality

driver.findElement(By.xpath(".//*[@id='tbplayers']/tbody/tr[2]/td[3]")).click(); WebElement dragme = driver.findElement(By.xpath(".//*[@id='tbplayers']/tbody/tr[2]/td[3]")); WebElement drop = driver.findElement(By.xpath(".//*[@id=&ap ...

Easier method for creating json body for reqwest post requests

I've implemented a post call that adds one line in register, and while it is functional, the code is cumbersome to write and read. Here's how it currently appears: static CLIENT: Lazy<Client> = Lazy::new(|| Client::new()); static GENER ...

Transforming Errors to JSON

Can an Exception object be converted into Json in Java 7? For example: try { //something } catch(Exception ex) { Gson gson = new Gson(); System.out.println(gson.toJson(ex)); } ...

Unsure about the approach to handle this PHP/JSON object in Javascript/jQuery

From my understanding, I have generated a JSON object using PHP's json_encode function and displayed it using echo. As a result, I can directly access this object in JavaScript as an object. Here is an example: .done(function(response) { var ...

Error when deserializing JSON: "Starting value 'W' is not valid"

Looking to develop a basic console game, but encountering an error while deserializing JSON. The specific issue reads: System.Text.Json.JsonException: "'W' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0." Below ...

Retrieving the XML data instead of JSON from a RESTful API

I have been practicing with the REST API to enhance my skills in Groovy-REST. Currently, I am able to extract specific JSON data from the REST response using SOAP UI 5.0 and generate a simple output from it. Interestingly, SOAP UI also provides an XML ver ...

Executing OPENJSON in a SQL Server 2016 stored procedure

After following the example provided in this forum post: Click here, I encountered an issue with my syntax. The code successfully retrieves the data from a source but fails to populate the table due to errors in my implementation of the OPENJSON function. ...

The proper way to send a string array parameter to an MVC WebApi controller

Starting my journey with AngularJS, I'm faced with the challenge of passing a JSON object that includes an array of strings to an MVC WebApi GET method. However, no matter what I try, I cannot seem to get the WebAPI controller to receive the correct v ...