question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrade to 2.11.3 (form 2.11.2) causes Configured `PolymorphicTypeValidator` (of type `com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator`) denied resolution

See original GitHub issue

Describe the bug After upgrading to 2.11.3 from 2.11.2, I receive the following exception:

Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'org.jobrunr.jobs.context.JobDashboardLogger$JobDashboardLogLines' as a subtype of `java.lang.Object`: Configured `PolymorphicTypeValidator` (of type `com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator`) denied resolution
 at [Source: (String)"{"version":0,"jobSignature":"System.out.println(String)","jobName":"an enqueued job","jobDetails":{"className":"java.lang.System","staticFieldName":"out","methodName":"println","jobParameters":[{"className":"java.lang.String","object":"a test"}]},"id":"4a322d0d-a90b-4835-b583-62dd7977a45e","jobHistory":[{"@class":"org.jobrunr.jobs.states.EnqueuedState","state":"ENQUEUED","createdAt":"2020-10-10T18:30:37.525349Z"},{"@class":"org.jobrunr.jobs.states.ProcessingState","state":"PROCESSING","createdAt"[truncated 769 chars]; line: 1, column: 723] (through reference chain: org.jobrunr.jobs.Job["metadata"]->java.util.concurrent.ConcurrentHashMap["jobRunrDashboardLog-2"])
	at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:43)
	at com.fasterxml.jackson.databind.DeserializationContext.invalidTypeIdException(DeserializationContext.java:1784)
	at com.fasterxml.jackson.databind.DatabindContext._throwSubtypeClassNotAllowed(DatabindContext.java:287)
	at com.fasterxml.jackson.databind.DatabindContext.resolveAndValidateSubType(DatabindContext.java:244)
	at com.fasterxml.jackson.databind.jsontype.impl.ClassNameIdResolver._typeFromId(ClassNameIdResolver.java:72)
	at com.fasterxml.jackson.databind.jsontype.impl.ClassNameIdResolver.typeFromId(ClassNameIdResolver.java:66)

Version information Which Jackson version(s) was this for? 2.11.3 (2.11.2 worked).

To Reproduce If you have a way to reproduce this with:

  1. Clone repository https://github.com/jobrunr/jobrunr
  2. Run tests in core/src/test/java/org/jobrunr/utils/mapper -> all tests green
  3. In platform/build.gradle update the jackson dependency from 2.11.2 to 2.11.3.
  4. Comment lines to throw exception about incompatible Jackson version in org.jobrunr.utils.mapper.jackson.JacksonJsonMapper (lines 30-32)
  5. Run tests in core/src/test/java/org/jobrunr/utils/mapper -> Jackson related tests are red

Json that fails during deserialization

{
  "version": 0,
  "jobSignature": "System.out.println(String)",
  "jobName": "an enqueued job",
  "jobDetails": {
    "className": "java.lang.System",
    "staticFieldName": "out",
    "methodName": "println",
    "jobParameters": [
      {
        "className": "java.lang.String",
        "object": "a test"
      }
    ]
  },
  "id": "6d9e0857-fd22-4b12-9fe2-19549d53b5bf",
  "jobHistory": [
    {
      "@class": "org.jobrunr.jobs.states.EnqueuedState",
      "state": "ENQUEUED",
      "createdAt": "2020-10-10T18:56:16.346030Z"
    },
    {
      "@class": "org.jobrunr.jobs.states.ProcessingState",
      "state": "PROCESSING",
      "createdAt": "2020-10-10T18:56:16.346997Z",
      "serverId": "62c282de-b852-40f5-9cc9-a8c44e27dc23",
      "updatedAt": "2020-10-10T18:56:16.346997Z"
    }
  ],
  "metadata": {
    "@class": "java.util.concurrent.ConcurrentHashMap",
    "jobRunrDashboardLog-2": {
      "@class": "org.jobrunr.jobs.context.JobDashboardLogger$JobDashboardLogLines",
      "logLines": [
        {
          "level": "INFO",
          "logInstant": "2020-10-10T18:56:16.352182Z",
          "logMessage": "this is an info message"
        },
        {
          "level": "WARN",
          "logInstant": "2020-10-10T18:56:16.352199Z",
          "logMessage": "this is a warning message"
        },
        {
          "level": "ERROR",
          "logInstant": "2020-10-10T18:56:16.352205Z",
          "logMessage": "this is an error message"
        }
      ]
    },
    "jobRunrDashboardProgressBar-2": {
      "@class": "org.jobrunr.jobs.context.JobDashboardProgressBar$JobDashboardProgress",
      "totalAmount": 80,
      "currentValue": 10,
      "progress": 12
    }
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rdehuysscommented, Oct 14, 2020

The analysis of @kupci is correct - it is related to #2840.

Instead of using the PolymorphicTypeValidator below, I’m now using the LaissezFaireSubTypeValidator.instance (an excellent name by the way 😄 ).

 ...
 .activateDefaultTypingAsProperty(BasicPolymorphicTypeValidator.builder()
                                .allowIfBaseType(JobState.class)
                                .allowIfBaseType(Map.class)
                                .allowIfBaseType(JobContext.Metadata.class)
                                .build(),

But I don’t understand why this would fail as the JobDashboardLogger$JobDashboardLogLines implements JobContext.Metadata. Any idea why my PolymorphicTypeValidator is not correct?

0reactions
cowtowncodercommented, Oct 27, 2020

I suspect the issue may have been due to validator not being registered; closing unless new information is uncovered.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FasterXML - Bountysource
Upgrade to 2.11.3 (form 2.11.2) causes Configured `PolymorphicTypeValidator` (of type `com.fasterxml.jackson.databind.jsontype.
Read more >
BasicPolymorphicTypeValidator (jackson-databind 2.11.0 API)
Set of specifically denied base types to indicate that use of specific base types is not allowed: most commonly used to fully block...
Read more >
Index (jackson-databind 2.11.4 API) - javadoc.io
Method for constructing a bean deserializer that uses specified intermediate Builder for binding data, and construction of the value instance.
Read more >
Add type information when serializing class with Jackson so ...
I actually got it working by configuring the ObjectMapper like this: ObjectMapper objectMapper = new ObjectMapper(); objectMapper.
Read more >
Security update for jackson-databind, jackson-dataformats ...
CVE-2020-28491: Fixed a bug which could cause `java.lang.OutOfMemoryError` exception in jackson-dataformats-binary. (bsc#1182481). Non security ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found