{"action":"closed","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1195","repository_url":"https://api.github.com/repos/FasterXML/jackson-databind","labels_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1195/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1195/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-databind/issues/1195/events","html_url":"https://github.com/FasterXML/jackson-databind/issues/1195","id":148239347,"number":1195,"title":"JsonMappingException not Serializable due to 2.7 reference to underlying parser","user":{"login":"mjustin","id":1580571,"avatar_url":"https://avatars.githubusercontent.com/u/1580571?v=3","gravatar_id":"","url":"https://api.github.com/users/mjustin","html_url":"https://github.com/mjustin","followers_url":"https://api.github.com/users/mjustin/followers","following_url":"https://api.github.com/users/mjustin/following{/other_user}","gists_url":"https://api.github.com/users/mjustin/gists{/gist_id}","starred_url":"https://api.github.com/users/mjustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjustin/subscriptions","organizations_url":"https://api.github.com/users/mjustin/orgs","repos_url":"https://api.github.com/users/mjustin/repos","events_url":"https://api.github.com/users/mjustin/events{/privacy}","received_events_url":"https://api.github.com/users/mjustin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/FasterXML/jackson-databind/milestones/39","html_url":"https://github.com/FasterXML/jackson-databind/milestones/2.7.0","labels_url":"https://api.github.com/repos/FasterXML/jackson-databind/milestones/39/labels","id":1299741,"number":39,"title":"2.7.0","description":null,"creator":{"login":"cowtowncoder","id":55065,"avatar_url":"https://avatars.githubusercontent.com/u/55065?v=3","gravatar_id":"","url":"https://api.github.com/users/cowtowncoder","html_url":"https://github.com/cowtowncoder","followers_url":"https://api.github.com/users/cowtowncoder/followers","following_url":"https://api.github.com/users/cowtowncoder/following{/other_user}","gists_url":"https://api.github.com/users/cowtowncoder/gists{/gist_id}","starred_url":"https://api.github.com/users/cowtowncoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cowtowncoder/subscriptions","organizations_url":"https://api.github.com/users/cowtowncoder/orgs","repos_url":"https://api.github.com/users/cowtowncoder/repos","events_url":"https://api.github.com/users/cowtowncoder/events{/privacy}","received_events_url":"https://api.github.com/users/cowtowncoder/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":33,"state":"open","created_at":"2015-09-10T17:33:07Z","updated_at":"2016-04-14T22:15:09Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-04-14T03:16:06Z","updated_at":"2016-04-14T22:15:09Z","closed_at":"2016-04-14T22:15:09Z","body":"JsonMappingExceptions thrown by the Jackson parser cannot be serialized.  This breaks any code that assumes the exception (per the Serializable interface it implements) is serializable.\r\n\r\nSince the exception contains a reference to a non-serializable parser (such as com.fasterxml.jackson.core.json.ReaderBasedJsonParser), serialization will throw a NotSerializableException.  Furthermore, the parser may contain a reference to the class being parsed; if that class is not itself serializable, that too will prevent serialization.\r\n\r\nThe expected behavior would be that these exceptions would be serializable.\r\n\r\nI ran across this issue when testing some code with a missing subtype.  The following code will replicate this issue:\r\n    import com.fasterxml.jackson.annotation.JsonSubTypes;\r\n    import com.fasterxml.jackson.annotation.JsonTypeInfo;\r\n    import com.fasterxml.jackson.databind.JsonMappingException;\r\n    import com.fasterxml.jackson.databind.ObjectMapper;\r\n\r\n    import java.io.ByteArrayOutputStream;\r\n    import java.io.NotSerializableException;\r\n    import java.io.ObjectOutputStream;\r\n\r\n    public class SerializationTest {\r\n        public static void main(String[] args) throws Exception {\r\n            try {\r\n                new ObjectMapper().readValue(\"{\\\"type\\\": \\\"B\\\"}\", ClassToRead.class);\r\n            } catch (JsonMappingException e) {\r\n                try (ObjectOutputStream stream = new ObjectOutputStream(new ByteArrayOutputStream())) {\r\n                    stream.writeObject(e);\r\n                } catch (NotSerializableException e2) {\r\n                    // java.io.NotSerializableException: com.fasterxml.jackson.core.json.ReaderBasedJsonParser\r\n                    System.err.println(\"Unable to serialize exception \" + e);\r\n                    e2.printStackTrace();\r\n                }\r\n            }\r\n            try {\r\n                new ObjectMapper().readValue(\"{\\\"classToRead\\\": {\\\"type\\\": \\\"B\\\"}}\", ContainerClassToRead.class);\r\n            } catch (JsonMappingException e) {\r\n                try (ObjectOutputStream stream = new ObjectOutputStream(new ByteArrayOutputStream())) {\r\n                    stream.writeObject(e);\r\n                } catch (NotSerializableException e2) {\r\n                    // java.io.NotSerializableException: jackson.ContainerClassToRead\r\n                    System.err.println(\"Unable to serialize exception \" + e);\r\n                    e2.printStackTrace();\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property=\"type\")\r\n    @JsonSubTypes({\r\n            @JsonSubTypes.Type(value = SubclassToRead.class, name = \"A\")\r\n    })\r\n    abstract class ClassToRead {}\r\n    class SubclassToRead extends ClassToRead {}\r\n\r\n    class ContainerClassToRead {\r\n        public ClassToRead classToRead;\r\n    }"}}