• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Spring Boot

 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access a REST controller with a Java client. The code in the controller is

The controller works with Postman although at the end posts an Internal Server Error.
The code of the client is
 
Saloon Keeper
Posts: 26543
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A "500" error indicates a bug in your Java code that threw an Exception.

More than that we cannot tell unless you show us the server logs with the stack trace in them.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd lay good odds on there not being anything useful in the server logs:

Those catch blocks should log the exception.
The second catch block should not return null, but should do nothing other than log the problem.
 
Sheriff
Posts: 22716
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alejandro, what you've written there is very dangerous. Unless when you're making an actual database management tool, you shouldn't allow users to specify the query to execute in any way. Definitely not like this, but you should also be aware of SQL injection. Right now, a user can send in any query, as long as it produces a result set. That could even be a compound statement that performs a DELETE or even a DROP TABLE statement.

If you want this service to be as dynamic as now, let the user only send the table name. Validate that it's one you expect, then create your SQL query yourself ("SELECT * FROM " + table is now safe because you validated that table is white listed
 
Tim Holloway
Saloon Keeper
Posts: 26543
187
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:I'd lay good odds on there not being anything useful in the server logs:

Those catch blocks should log the exception.
The second catch block should not return null, but should do nothing other than log the problem.



Do NOT eat exceptions silently if you ever expect me to respect your code. I get very angry.  

Either handle an exception or report it. Don't create an unnecessary mystery.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic