0

I have an inheritance structure where SubtaskGroupA and SubtaskGroupB both inherit from the @MappedSuperclass Subtask and to allow the user to submit multiple Subtasks of one Group. I use a helper class SubtaskList with a field List subtasks. A form of this helper class is rendered, a user will enter information (using scala's @select-helper)into all subtasks and submit the form. When binding the input using Form<SubtaskList> form = form(SubtaskList.class).bindFromRequest(); I receive the following exception:

Caused by: com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class play.data.Form and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[0]->models.qosdatamodel.SubtaskGroupA["form"])
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59) ~[jackson-databind-2.3.3.jar:2.3.3]
    at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26) ~[jackson-databind-2.3.3.jar:2.3.3]
    at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:541) ~[jackson-databind-2.3.3.jar:2.3.3]
    at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:644) ~[jackson-databind-2.3.3.jar:2.3.3]
    at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152) ~[jackson-databind-2.3.3.jar:2.3.3]

All fields are private with public getters/setters. I get the same exception when calling toJson on a List of all SubtaskGroupA's.

All help is appreciated.

Edit: The @JsonIgnore Annotation helped a little, I guess, but now I receive a different exception on bindFromRequest():

Caused by: org.springframework.beans.NullValueInNestedPathException: Invalid property 'subtasks' of bean class [models.qosdatamodel.SubtaskList]: Could not instantiate property type [models.qosdatamodel.Subtask] to auto-grow nested property path: java.lang.InstantiationException
at org.springframework.beans.BeanWrapperImpl.newValue(BeanWrapperImpl.java:651) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.beans.BeanWrapperImpl.growCollectionIfNecessary(BeanWrapperImpl.java:885) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:790) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.beans.BeanWrapperImpl.getNestedBeanWrapper(BeanWrapperImpl.java:571) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]
at org.springframework.beans.BeanWrapperImpl.getBeanWrapperForPropertyPath(BeanWrapperImpl.java:548) ~[spring-beans-4.0.3.RELEASE.jar:4.0.3.RELEASE]

`

quirins
  • 3
  • 3

1 Answers1

0

I think the problem exists in your model models.qosdatamodel.SubtaskGroupA. You cannot get access to some field from this class. To avoid this problem you have to find which field caused the problem (you'll find it in logs) and add annotation @JsonIgnore

I don't know exactly if above class SubtaskGroupA is the right one but I'm definitely sure that this is the problem.

Probably you're trying to make json from you model class and error comes from one of your relationships :)

Edit SubtaskList - in this class probably you have a problem :)

Martin Spamer
  • 5,437
  • 28
  • 44
Michał Wolnicki
  • 275
  • 4
  • 13