NullPointerException on method return

1

I am making a method to fetch the logged-in user from the database. I'm having a NullPointerException in return of this method

@RequestMapping(value = "/usuarioLogado", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, method = RequestMethod.POST)
public EntidadesAdministradores usuarioLogado(@RequestBody Usuarios usuarios) throws ServletException {

    Usuarios usuAutenticado = uService.buscarPorLogin(usuarios.getLogin());     
    usuarios = usuAutenticado;
    Long idUsuLogado = usuarios.getIdUsuario();

    EntidadesAdministradores administrador = new EntidadesAdministradores(); 
    if(usuarios.getFlagAdministrador()==1) 
        administrador = eaService.buscarUsuarioLogado(idUsuLogado);
        return  administrador;
}

My method buscaUsuarioLogado

public EntidadesAdministradores buscarUsuarioLogado(Long usuarioLogado ){       
    return eaRepository.buscarIdUsuarioLogado(usuarioLogado);
}

my repository method

@Query(value="Select e from EntidadesAdministradores e where e.usuarios  = :parametroId")
public EntidadesAdministradores buscarIdUsuarioLogado(@Param("parametroId") Long usuarioLogado);

Error Log

java.lang.NullPointerException: null
at controller.LoginController.usuarioLogado(LoginController.java:93) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_144]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_144]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_144]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    
asked by anonymous 18.10.2017 / 16:58

1 answer

0

I was able to resolve the issue by clearing and building the project again. There were no more mistakes.

    
18.10.2017 / 18:20