Skip to content

@JsonIgnoreProperties: ignoring the "cause" property of Throwable on GAE #877

@mmazi

Description

@mmazi

Deserializing an exception class from json on Google App Engine causes this error:

Caused by: java.lang.IllegalArgumentException: Can not access private java.lang.Throwable java.lang.Throwable.cause (from class java.lang.Throwable; failed to set access: java.lang.IllegalAccessException: Reflection is not allowed on private java.lang.Throwable java.lang.Throwable.cause
    at com.fasterxml.jackson.databind.util.ClassUtil.checkAndFixAccess(ClassUtil.java:505)
    at com.fasterxml.jackson.databind.introspect.AnnotatedMember.fixAccess(AnnotatedMember.java:123)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.constructSettableProperty(BeanDeserializerFactory.java:704)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:501)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildThrowableDeserializer(BeanDeserializerFactory.java:356)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:114)

I tried preventing this by using @JsonIgnoreProperties:

@JsonIgnoreProperties("cause")
public class MyException extends RuntimeException { ... }

... but the same error still occurs. What am I doing wrong? What else could I do?

I've also considered setting MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS to false, but I don't like this solution because I need this setting to be true in some other cases (in particular, I provide no-arg constructors for Jackson, but they should't be public in my API).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions