POJO Kafka Consumer Fails with JsonSmartJsonProvider 'java.lang.String' Error
search cancel

POJO Kafka Consumer Fails with JsonSmartJsonProvider 'java.lang.String' Error

book

Article ID: 434282

calendar_today

Updated On:

Products

Autosys Workload Automation

Issue/Introduction

When running an AutoSys POJO job configured as a Kafka consumer, the job fails with the following error in the agent logs:

Process Header Key JSONPathExpected to find an object with property ['key'] in path $ but found 'java.lang.String'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.

Environment

r24.0 (Agent), r24.1.01 (Scheduler) 

Cause

The error is caused by the presence of JSONPath parameters in the job definition for Kafka headers that contain simple string values instead of JSON objects. When kafka.HeaderKeyJsonPath or kafka.HeaderValueJsonPath are defined, the JsonSmartJsonProvider attempts to parse the header as a JSON structure. If the header is a standard string, the parsing fails because a string is not a valid JSON object at the root level

Resolution

To resolve this issue, modify the job definition (JIL) to remove the JSONPath evaluation for headers and use Regex matching instead.

  1. Identify the failing job: Locate the POJO Kafka consumer job definition.
  2. Edit the JIL: Remove the following j2ee_parameter lines if they are present and targeting simple string headers:
    • j2ee_parameter: kafka.HeaderKeyJsonPath=...
    • j2ee_parameter: kafka.HeaderValueJsonPath=...
  3. Ensure Regex is configured: Use the standard Regex parameters for header matching, which do not require the header to be a JSON object:
    • j2ee_parameter: kafka.HeaderKeyRegex=[your_regex]
    • j2ee_parameter: kafka.HeaderValueRegex=[your_regex]
  4. Update the job: Re-insert the modified JIL into the AutoSys database.
  5. Restart the job: Execute the job to verify that the error no longer persists.

Additional Information

For more information on configuring POJO job attributes for Kafka, refer to the official documentation:

AutosysPOJOJobs