title: Spring-boot issue with "There was an unexpected error (type=Internal Server Error, status=500)."
body: <p>I started a project with spring-boot and i'm actually trying to GET JSON (if i understood) informations on my localhost port. But I am facing this error: "Internal Servor Error, status=500"</p>
  
  <p>I did a stupid mistake somewhere but I can't find where I did wrong...
  I'm using springboot with JPA and h2 database</p>
  
  <p>Thanks in advance for your help!</p>
  
  <p>Here is my code : </p>
  
  <p>Model : </p>
  
  <pre><code>@Entity
  public class User {
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private int id;
      @Column (name = "name", nullable = false, unique = false)
      private String name;
      @Column (name = "firstname", nullable = false, unique = false)
      private String firstname;
      @Column (name = "username", nullable = false, unique = true)
      private String username;
      @Column (name = "email", nullable = false, unique = true)
      private String email;
  
      // Constructors
      public User(int id, String name, String firstname, String username, String email) {
          super();
          this.id = id;
          this.name = name;
          this.firstname = firstname;
          this.username = username;
          this.email = email;
      }
  
      public User(String name, String firstname, String username, String email) {
          super();
          this.name = name;
          this.firstname = firstname;
          this.username = username;
          this.email = email;
      }
  
      //Getters Setters
      public User() {
          super();
      }
  
      public long getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getFirstname() {
          return firstname;
      }
  
      public void setFirstname(String firstname) {
          this.firstname = firstname;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + ((username == null) ? 0 : username.hashCode());
          result = prime * result + ((email == null) ? 0 : email.hashCode());
          result = prime * result + ((firstname == null) ? 0 : firstname.hashCode());
          result = prime * result + (int) (id ^ (id &gt;&gt;&gt; 32));
          result = prime * result + ((name == null) ? 0 : name.hashCode());
          return result;
      }
  
      @Override
      public boolean equals(Object obj) {
          if (this == obj)
              return true;
          if (obj == null)
              return false;
          if (getClass() != obj.getClass())
              return false;
          User other = (User) obj;
          if (username == null) {
              if (other.username != null)
                  return false;
          } else if (!username.equals(other.username))
              return false;
          if (email == null) {
              if (other.email != null)
                  return false;
          } else if (!email.equals(other.email))
              return false;
          if (firstname == null) {
              if (other.firstname != null)
                  return false;
          } else if (!firstname.equals(other.firstname))
              return false;
          if (id != other.id)
              return false;
          if (name == null) {
              if (other.name != null)
                  return false;
          } else if (!name.equals(other.name))
              return false;
          return true;
      }
  
      @Override
      public String toString() {
          return "User [id=" + id + ", name=" + name + ", firstname=" + firstname + ", Username=" + username + ", email="
                  + email + ", getId()=" + getId() + ", getName()=" + getName() + ", getFirstname()=" + getFirstname()
                  + ", getUsername()=" + getUsername() + ", getEmail()=" + getEmail() + ", hashCode()=" + hashCode()
                  + ", getClass()=" + getClass() + ", toString()=" + super.toString() + "]";
      }
  
  
      }
  
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@Controller
  @RestController
  @CrossOrigin(origins = "*", maxAge = 3600)
  public class UserController {
  
      @Autowired
      UserService UserService;
  
      @GetMapping(value = "/user/{id}")
      public Optional&lt;User&gt; findById(@PathVariable int id) {
          return UserService.findById(id);
      }
  
      @GetMapping(value = "/user/{name}")
      public Optional&lt;User&gt; findByName(@PathVariable String name) {
          return UserService.findByName(name);
      }
  }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>@Repository
  public interface UserRepository extends JpaRepository&lt;User, Integer&gt; {
  
      Optional &lt;User&gt; findById(int id);
  
      Optional &lt;User&gt; findByName(String name);
  
  }
  </code></pre>
  
  <p>Service:</p>
  
  <pre><code>@Service
  public class UserService {
  
      @Autowired
      static UserRepository UserRepository;
  
      public Optional&lt;User&gt; findById(int id) {
          return UserRepository.findById(id);
  
      }
      public Optional&lt;User&gt; findByName(String name) {
          return UserRepository.findByName(name);
  }
  }
  </code></pre>
  
  <p>Data.sql where i stored user objects:</p>
  
  <pre><code>INSERT INTO User (ID, name , firstname, userName, email) VALUES
  (1 , 'bon', 'jean', 'bjean', 'bjean@gmail.com');
  
  INSERT INTO User (ID, name , firstname, userName, email) VALUES
  (2 , 'motte', 'bob', 'bmotte', 'bmotte@gmail.com');
  
  INSERT INTO User (ID, name , firstname, userName, email) VALUES
  (3 , 'wose', 'guy', 'gwose', 'gwose@gmail.com');
  </code></pre>
  
  <p>application_properties:</p>
  
  <pre><code># To See H2 Console in Browser:
  # http://localhost:8080/h2-console
  # Enabling H2 Console
  spring.h2.console.enabled=true
  
  # ===============================
  # DATABASE CONNECTION
  # ===============================
  spring.datasource.url=jdbc:h2:mem:testdb
  spring.datasource.driverClassName=org.h2.Driver
  spring.datasource.username=h2
  spring.datasource.password=h2
  
  # ===============================
  # JPA / HIBERNATE
  # ===============================
  spring.jpa.show-sql=true
  spring.jpa.hibernate.ddl-auto=update
  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
  </code></pre>