Getting 500 Server Error with Spring Boot REST application JpaRepository

2.4k Views Asked by At

I am working on a Spring Boot based application that exposes its database through REST by using a number of interfaces extending JpaRepository. Everything looks and works fine with the exception of a curious phenomenon: When I POST to create a new row in the database, it does its job well. The row gets created in the table. Even my aspect around "*save()" method gets triggered and all. Despite all the positive outlook, the response code is 500. Please advice on how I can dig into that?

1

There are 1 best solutions below

1
On

Ok I got it. It is the "around" aspect which does not return the result returned by the joinPoint.proceed()

It was like that:

@Around("execution(* save(..))")
void saveWithNotify(ProceedingJoinPoint joinPoint) throws Throwable
{
    Object entity = joinPoint.proceed();
    afterSave(entity);
}

Corrected as:

@Around("execution(* save(..))")
Object saveWithNotify(ProceedingJoinPoint joinPoint) throws Throwable
{
    Object entity = joinPoint.proceed();
    afterSave(entity);
    return entity;
}

Many thanks to those who tried to help