I have a project that uses Spring, Hibernate and has controllers that return JSON. Naturally, my models contain lists, etc., To use JPA annotations to define hibernate relationships, so for example, I have users that contain a set of problems that they have, and also the Challenge contains a user who owns it.
Unfortunately, I seem to have a lot of problems with collections built into my JSON.
For example, with this setting (the user owns the tasks, and the call has the owner), I can return the call just fine. I can return the user just fine. But when I try to return the list of problems, everything explodes! I get the following error from the Jmeter test:
Error 500 Server Server
I believe this means that the Jackson json parser had a problem setting json. I believe in this because if I use @JsonIgnoreProperties ({"tasksOwned"}), then I can return the list of tasks just fine, since each individual request object no longer has a list built into it.
It seems very strange to me. Can Jackson really not display simple inline lists in JSON? I also have a huge problem, because I have a map in which the user uses his key ... and it seems even impossible to define the JSON map key as an inline object in general!
Does anyone have a suggestion on my problem? Do I need to manually define some Json mappings? Is there a simple solution that I just donβt know about?
EDIT:
Although what j0ntech says seemed to be true, it turns out that this was not the whole story. It seems that when Spring used Jackson to serialize one of my sleeping entities in the JSON version, hibernate tried to be lazy to load one of these properties of the object, but since the object was outside its transaction at this point (being "in", the controller), it caused exception that has just been swallowed.
So there were actually two problems. I thought about this while trying to manually use Jackson to serialize the object I was returning before returning it. So I got a stack trace for another problem.