Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9204599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:44:53+00:00 2026-06-17T23:44:53+00:00

I have a project which uses Spring, Hibernate, and has controllers which return JSONs.

  • 0

I have a project which uses Spring, Hibernate, and has controllers which return JSONs. Naturally, my models contain lists and such to use JPA annotations to define the hibernate relationships, so, for example, I have Users, which contain a set of Challenges they own, and likewise Challenge contains a User who owns it.

Unfortunately I seem to be having a lot of issues with collections embedded in my JSONs.

For example, with that set up (a User owns challenges and a challenge has a owner) I can return a Challenge just fine. I can return a User just fine. But when I try to return a list of challenges, everything blows up! I receive the following error from my Jmeter test:

Error 500 Server Error

I believe this means that the Jackson json parser had an issue setting the json. I believe this, because if I use @JsonIgnoreProperties({“challengesOwned”}) then I can return the list of challenges just fine, since each individual challenge object no longer has a list embedded inside it.

This seems very strange to me. Can Jackson really not map simple embedded lists within JSONs? I’ve also got a huge problem because I have a Map which uses a User as its key … and it seems it’s not even possible to define a JSON map’s key as an embedded object at all!

Does anyone have a suggestion for my issue? Do I have to manually define some Json mappings? Is there a simple solution I just don’t know about?

EDIT:

While what j0ntech says does seem to have been true, it turns out that was not the whole story. It seems that when Spring used Jackson to serialize one of my hibernate entities into it’s JSON version, hibernate was trying to lazy load one of that entity’s properties, but since the entity was outside of its transaction at that point (being “in” the controller), it caused an exception, which just got swallowed up.

So there were actually TWO issues. I figured this out by trying to manually use Jackson to serialize the object I was returning before actually returning it. That way I actually got the stack trace for the other issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:44:54+00:00Added an answer on June 17, 2026 at 11:44 pm

    You probably have a recursive loop (as per DwB’s comment): User contains a list of Challenges, which each contain a User, which contains a list of Challenges and so on and so forth. The parser (or your server at large) doesn’t like that. You should use the annotations JsonManagedReference and JsonBackReference.

    You can read about how to use these annotations here and here. I’ve used them in some of my own projects and they work very well if correctly implemented.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a java ee project which has a text file that uses a
I have a Spring project that uses Maven and has several profiles to allow
I have started work on a project which uses Spring.Net, and i'm coming at
We have a mixed Java and Scala project, which uses Spring transaction management. We
I have a netbeans java console project which uses Spring 3.0 ( which is
I have a spring project which uses different libraries, packed as multiple jars. One
I have a project which I am building with Maven which uses Hibernate (and
I have a Spring MVC project which uses Spring Security. I am wondering how
I have been working on a project which uses Grails with Hibernate... Now the
I've 'inherited' a project which uses Spring annotations to manage transactions/sessions with Hibernate. Or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.