title: Error Service Rest Spring Boot: java.util.NoSuchElementException: No value present
body: <p>Good morning, I have a problem when making a REST web service with spring boot, the application runs to me, but when presenting the data it shows me as if the table did not exist in the database ORACLE, I do not know if it is that I am missing something in the configuration of the classes, a continuation I attach the answers that I get:</p>
  
  <p>When I consult to get all the clients:
  <a href="https://i.stack.imgur.com/N057z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N057z.png" alt="enter image description here"></a></p>
  
  <p>When I consult to obtain a particular record:</p>
  
  <p><a href="https://i.stack.imgur.com/XRGcx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XRGcx.png" alt="enter image description here"></a></p>
  
  <p>My Code</p>
  
  <p>Main Class</p>
  
  <pre><code>package com.example.consulta;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class App {
  
      public static void main(String[] args) {
          SpringApplication.run(App.class, args);
      }
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code> package com.example.consulta.controller;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.example.consulta.entity.Cliente;
  import com.example.consulta.service.ClienteService;
  
  @RestController
  public class ClienteController {
  
      @Autowired
      private ClienteService  clienteService;
  
      @GetMapping("/allCliente")
      public List&lt;Cliente&gt; listarCliente(){
          return clienteService.findAll();
      }
  
      @GetMapping("/cliente/{cedula}")
      public Cliente detalleCliente(@PathVariable int cedula) {
          return  clienteService.findById(cedula);
  
      }
  
  }
  </code></pre>
  
  <p>DAO </p>
  
  <pre><code>package com.example.consulta.DAO;
  import org.springframework.data.repository.CrudRepository;
  
  import com.example.consulta.entity.Cliente;
  
  public interface ClienteDAO extends CrudRepository&lt;Cliente, Integer&gt;{
  }
  </code></pre>
  
  <p>Cliente</p>
  
  <pre><code>package com.example.consulta.entity;
  
  import javax.persistence.Entity;
  import javax.persistence.Id;
  
  
  @Entity
  public class Cliente {
  
      @Id
      private int cedula;
      private String nombre;
      private String apellido;
      private String tipo_cliente;
  
      public int getCedula() {
          return cedula;
      }
      public void setCedula(int cedula) {
          this.cedula = cedula;
      }
      public String getNombre() {
          return nombre;
      }
      public void setNombre(String nombre) {
          this.nombre = nombre;
      }
      public String getApellido() {
          return apellido;
      }
      public void setApellido(String apellido) {
          this.apellido = apellido;
      }
      public String getTipo_cliente() {
          return tipo_cliente;
      }
      public void setTipo_cliente(String tipo_cliente) {
          this.tipo_cliente = tipo_cliente;
      }   
  
  }
  </code></pre>
  
  <p>clienteService</p>
  
  <pre><code>package com.example.consulta.service;
  
  import java.util.List;
  
  import com.example.consulta.entity.Cliente;
  
  public interface ClienteService {
  
      public List&lt;Cliente&gt; findAll();
      public Cliente findById(int cedula);
  
  }
  </code></pre>
  
  <p>ClienteServiceImpl</p>
  
  <pre><code>package com.example.consulta.service;
  
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.example.consulta.DAO.ClienteDAO;
  import com.example.consulta.entity.Cliente;
  
  @Service
  
      public class ClienteServiceImpl implements ClienteService{
  
          @Autowired
          private ClienteDAO clienteDao;
  
          @Override
          @Transactional
          public List&lt;Cliente&gt; findAll() {
              return (List&lt;Cliente&gt;) clienteDao.findAll();
          }
  
          @Override
          public Cliente findById(int cedula) {
              return clienteDao.findById(cedula).get();
          }
  
  
      }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.2.1.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.example.consulta&lt;/groupId&gt;
      &lt;artifactId&gt;ServiceConsultaCliente&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;ServiceConsultaCliente&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;!-- change it to oracle driver --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.h2database&lt;/groupId&gt;
              &lt;artifactId&gt;h2&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                      &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>application.properties</p>
  
  <pre><code>spring.application.name=prueba-microservicio-cliente
  spring.datasource.url=jdbc:oracle:thin:@//10.164.7.203:1521/ORCLPDB1.localdomain
  spring.datasource.username=cesar
  spring.datasource.password=xxxxx123
  spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
  spring.jpa.hibernate.ddl-auto=update
  </code></pre>
  
  <p>Annex proof that my table exists with the user cesar, and I can connect using SQL Developer:</p>
  
  <p><a href="https://i.stack.imgur.com/PHkCn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PHkCn.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/7kCin.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7kCin.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/k26by.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k26by.png" alt="enter image description here"></a></p>
  
  <p>SQL code to create the table:</p>
  
  <pre><code>CREATE TABLE cliente(
          cedula NUMBER(10) NOT NULL,
          nombre varchar (15) NOT NULL,
          apellido varchar (15),
          tipo_cliente varchar(10) NOT NULL,
          PRIMARY KEY (cedula)
  );
  </code></pre>
  
  <p>I am new to spring boot, and I am testing to create microvservices with docker, I have to have my database in a container, which I don't know if it influences</p>
  
  <p>Structure of my project</p>
  
  <p><a href="https://i.stack.imgur.com/zS0bz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zS0bz.png" alt="enter image description here"></a></p>