I have an interface with name Field as below:
public interface Field { } This interface is in the module A. I have an enum called BField which is in module B and is implemented as below:
public enum BField implements Field { SOME_FIELD } There is a class named C in the module A as below:
public class C implements Serializable { private Set<Field> f; public Set<Field> getF() { return f; } public void setF(Set<Field> f) { this f = f; } } I have a REST method as below:
@RequestMapping(method=RequestMethod.Post, value="/save") @ResponseBody public void save (@RequestBody C c) { //save c } I send this JSON object to this method:
{ "f": ["SOME_FIELD"] } then I get HTTP 400 bad request error code with the following exception log:
abstract types can only be instantiated with additional type information
The hierarchy of the modules is module B is dependent to module A. I tried to use @JsonTypeInfo but the dependency between modules works as a limit and does not let me to use BField.class in the @JsonSubTypes annotation for the field f in class C.