how to solve Internal Server Error in spring data

steph_ntic

Hello I want to update this entity, but I get this error enter image description here

Thanks for your help!

@PostMapping("updateabitre/{id}")
public Arbitre updateArbitre(@PathVariable Long id, Arbitre newArbitre){
    ServiceArbitre serviceArbitre = null;
    Arbitre arbitre = serviceArbitre.getArbitreById(id);
    arbitre.setNomArbitre(newArbitre.getNomArbitre());
    arbitre.setNationnalite(newArbitre.getNationnalite());

    serviceArbitre.updateArbitre(arbitre);
    return arbitre;
}
Blair Nangle

Here, you are setting serviceArbitre to null before immediately invoking one of its functions, hence the NullPointerException.

ServiceArbitre serviceArbitre = null;
Arbitre arbitre = serviceArbitre.getArbitreById(id);

Also, you may need to annotate updated entity parameter (Arbitre newArbitre) with @RequestBody, that is:

public Arbitre updateArbitre(@PathVariable Long id, @RequestBody Arbitre newArbitre){

Otherwise Spring may not know to map the HTTP request body to the object.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to solve this internal server error

500 internal server error php, how to solve?

how to solve this error "HTTP Error 500.19 - Internal Server Error"

How to solve "502 internal error - server connection terminated" error?

How do I solve kubeflow notebook internal server error

How to solve Internal Server Error in Next.Js?

How to solve "HTTP Error 500.19 - Internal Server Error" "<remove name="ExtensionlessUrlHandler-Integrated-4.0" />"

How to solve tigris::call_geolocator() Internal Server Error (HTTP 500) error?

How to handle Internal server error (500) on spring rest API?

How to solve SQLException - Data conversion error in Spring Boot

How to debug "internal server error"?

500 Internal Server Error Spring boot & JWT

spring boot on azure Internal Server Error

Spring File Upload Internal server error

Spring boot on Azure produces internal server error

MeteorJS -- Internal server error [500] -- No Data

How to Solve This error (Server Is Busy The record was saved. However, the data could not be displayed because the server is busy)

How Spring Data REST return hibernate-JPA validation & server internal errors in json not stack trace

Spring Boot - There was an unexpected error (type=Internal Server Error, status=500)

Flask server internal error, how to fix it

How to handle an "Internal Server Error" with Android WebView?

How solve Servlet Context Error into Spring?

How to solve getting bean error in spring boot

How to solve this Spring Boot Whitelabel error

How to solve psql error: could not connect to server?

How to solve node on linux server 502 error?

How to solve this error on live server for laravel?

500 Internal Server Error instead of 404 in Spring Boot

Spring 5 - HTTP Status 500 – Internal Server Error