Deserializing List<Serializable> object fails - using Spring 4.2.4 RestController and Jackson 2.5.4.
I get the following error:
Unexpected failure: Could not read document: Can not construct instance of java.io.Serializable, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information\n at [Source: java.io.PushbackInputStream@408725ba; line: 1, column: 3071] (through reference chain: gov.sandia.generated.entities.eacontent.Ea[\"commonSections\"]->gov.sandia.generated.entities.eacontent.CommonSections[\"purpose\"]->gov.sandia.generated.entities.eacontent.Purpose[\"releaseReason\"]->java.util.ArrayList[0]->gov.sandia.generated.entities.eacontent.ReleaseReason[\"paragraph\"]->java.util.ArrayList[0]->gov.sandia.generated.entities.eacontent.Paragraph[\"content\"]->java.util.ArrayList[0]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.io.Serializable, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information\n at [Source: java.io.PushbackInputStream@408725ba; line: 1, column: 3071] (through reference chain: gov.sandia.generated.entities.eacontent.Ea[\"commonSections\"]->gov.sandia.generated.entities.eacontent.CommonSections[\"purpose\"]->gov.sandia.generated.entities.eacontent.Purpose[\"releaseReason\"]->java.util.ArrayList[0]->gov.sandia.generated.entities.eacontent.ReleaseReason[\"paragraph\"]->java.util.ArrayList[0]->gov.sandia.generated.entities.eacontent.Paragraph[\"content\"]->java.util.ArrayList[0])
Code for Paragraph:
package def.com.generated.entities.eacontent;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "paragraph", propOrder = {
"content"
})
public class Paragraph implements Serializable
{
private final static long serialVersionUID = -1L;
@XmlElementRef(name = "paragraph", namespace = "http://def.com/ea/schemas", type = JAXBElement.class, required = false)
@XmlMixed @org.mongodb.morphia.annotations.Serialized
protected List<Serializable> content;
@XmlAttribute(name = "ea-revision", required = true)
protected String eaRevision;
@XmlAttribute(name = "href")
protected String href;
@XmlAttribute(name = "id")
protected String id;
@XmlAttribute(name = "sequence")
protected String sequence;
@XmlAttribute(name = "para-status")
protected ParaStatus paraStatus;
/**
* Default no-arg constructor
*
*/
public Paragraph() {
super();
}
public Paragraph(final List<Serializable> content, final String eaRevision, final String href, final String id, final String sequence, final ParaStatus paraStatus) {
this.content = content;
this.eaRevision = eaRevision;
this.href = href;
this.id = id;
this.sequence = sequence;
this.paraStatus = paraStatus;
}
public List<Serializable> getContent() {
if (content == null) {
content = new ArrayList<Serializable>();
}
return this.content;
}
public String getEaRevision() {
return eaRevision;
}
public void setEaRevision(String value) {
this.eaRevision = value;
}
public String getHref() {
return href;
}
public void setHref(String value) {
this.href = value;
}
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
public String getSequence() {
return sequence;
}
public void setSequence(String value) {
this.sequence = value;
}
public ParaStatus getParaStatus() {
return paraStatus;
}
public void setParaStatus(ParaStatus value) {
this.paraStatus = value;
}
}
Do I need a custom mapper? If so, what?
Thanks!