title: Spring boot rest : Circular view path [error]: would dispatch back to the current handler URL [/error] again
body: <p>My issue is I get 404 error when calling the spring boot application on localhost:8080/users</p>
  
  <pre><code>package com.myproj.users.controller;
  
  import java.nio.file.attribute.UserPrincipalNotFoundException;
  import java.security.Principal;
  import java.util.concurrent.atomic.AtomicLong;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.myproj.users.Greeting;
  import com.myproj.users.PhysicalCharacteristicsRepository;
  import com.myproj.users.UserRepository;
  import com.myproj.users.UserResource;
  
  @RestController
  @RequestMapping("/users")
  public class UserRestController {
  
      private UserRepository userRepository;
      private PhysicalCharacteristicsRepository characteristicsRepository;
  
      @RequestMapping(value = "/greeting/", method = RequestMethod.GET)
      public String greeting() throws UserPrincipalNotFoundException {
          return "Greeting";
      }
  
      @RequestMapping(value = "/error/")
      public String error() {
          return "Error handling";
      }
  
      private static final String template = "Hello, %s!";
      private final AtomicLong counter = new AtomicLong();
  
      @RequestMapping(method = RequestMethod.GET)
      public @ResponseBody Greeting sayHello(@RequestParam(value = "name", required = false, defaultValue = "Stranger") String name) {
          return new Greeting(counter.incrementAndGet(), String.format(template, name));
      }
  
      @Autowired
      UserRestController(UserRepository userRepository, PhysicalCharacteristicsRepository characteristicsRepository) {
          this.userRepository = userRepository;
          this.characteristicsRepository = characteristicsRepository;
      }
  }
  
  
  package com.myproj.users.controller;
  
  import java.nio.file.attribute.UserPrincipalNotFoundException;
  
  import org.springframework.hateoas.VndErrors;
  import org.springframework.http.HttpStatus;
  import org.springframework.web.bind.annotation.ControllerAdvice;
  import org.springframework.web.bind.annotation.ExceptionHandler;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.bind.annotation.ResponseStatus;
  
  import com.weather.exceptions.UserNotFoundException;
  
  @ControllerAdvice
  class UserControllerAdvice {
  
      @ResponseBody
      @ExceptionHandler(UserNotFoundException.class)
      @ResponseStatus(HttpStatus.NOT_FOUND)
      VndErrors userNotFoundExceptionHandler(UserNotFoundException ex) {
          return new VndErrors("error", ex.getMessage());
      }
  
      @ResponseBody
      @ExceptionHandler(UserPrincipalNotFoundException.class)
      @ResponseStatus(HttpStatus.NOT_FOUND)
      VndErrors userPrincipalNotFoundException(UserPrincipalNotFoundException ex) {
          return new VndErrors("error", ex.getMessage());
      }
  }
  
  package com.myproj.users;
  
  public class Greeting {
  
      private final long id;
      private final String content;
  
      public Greeting(long id, String content) {
          this.id = id;
          this.content = content;
      }
  
      public long getId() {
          return id;
      }
  
      public String getContent() {
          return content;
      }
  
  }
  </code></pre>
  
  <p>I have tested the spring project in <a href="https://spring.io/guides/gs/actuator-service/" rel="nofollow">https://spring.io/guides/gs/actuator-service/</a> and it worked so I ignore what's going on.</p>