0

My spring boot rest application has a controller with the below method. It uses hibernate internally to get data from Oracle DB. My issue is that, when I invoke this service, it returns a HTTP ERROR 500. But there aren't any errors logged anywhere and the debug log in the below code prints the entire Job object without any issues. I debugged and saw that the job object is returning as well.

I doubt some data is causing issue when converting the Job object to json, but how do I find which field is causing the issue ?

Is there a way to log issues occuring during the json conversion ?

@GetMapping(params = {"jobId"})
  @ResponseBody
  public Job findById(long jobId) {
    Job job = jobHistoryService.findById(jobId);
    log.debug(job.toString());
    return job;
  }
3
  • @Deadpool This page isn’t working 127.0.0.1 is currently unable to handle this request. HTTP ERROR 500 Commented Jan 17, 2019 at 1:29
  • stackoverflow.com/a/20488306/839979 Commented Jan 17, 2019 at 1:33
  • write a unit test with mockmvc and print the response out. you should be able to see the error message Commented Jan 17, 2019 at 1:34

1 Answer 1

1

I followed the advice in comment and set log level in applicaion.yml to info and it printed out the error. The error printed out was this.

com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor

Searched stack overflow and found this solution of adding the below to entites and it worked like a charm.Thanks guys !

@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"}) 

stackoverflow link

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.