title: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization
body: <p>I'm developing <strong>spring boot microservices</strong> example from the link: <a href="https://dzone.com/articles/spring-boot-creating" rel="noreferrer">https://dzone.com/articles/spring-boot-creating</a>. In this project I simply updated the parent dependency to its latest version and other code files are unchanged. I faced the following error when I click <strong><a href="http://localhost:8080/order?idCustomer=2&amp;idProduct=3&amp;amount=4" rel="noreferrer">http://localhost:8080/order?idCustomer=2&amp;idProduct=3&amp;amount=4</a></strong></p>
  
  <pre><code>2016-09-09 11:46:20.888 ERROR 14152 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : StandardWrapper.Throwable
  
  org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
  [[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.util.List br.com.alexandreesl.handson.rest.ProductRest.getProducts() and public java.util.List br.com.alexandreesl.handson.rest.CustomerRest.getCustomers() at matching regular expression /. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@14c14bf']
      at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:555) ~[jersey-server-2.23.1.jar:na]
      at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184) ~[jersey-server-2.23.1.jar:na]
      at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350) ~[jersey-server-2.23.1.jar:na]
      at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347) ~[jersey-server-2.23.1.jar:na]
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[jersey-common-2.23.1.jar:na]
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[jersey-common-2.23.1.jar:na]
      at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) ~[jersey-common-2.23.1.jar:na]
      at org.glassfish.jersey.server.ApplicationHandler.&lt;init&gt;(ApplicationHandler.java:347) ~[jersey-server-2.23.1.jar:na]
      at org.glassfish.jersey.servlet.WebComponent.&lt;init&gt;(WebComponent.java:392) ~[jersey-container-servlet-core-2.23.1.jar:na]
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177) ~[jersey-container-servlet-core-2.23.1.jar:na]
      at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369) ~[jersey-container-servlet-core-2.23.1.jar:na]
      at javax.servlet.GenericServlet.init(GenericServlet.java:158) ~[tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1194) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.4.jar:8.5.4]
      at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]
  </code></pre>
  
  <p>the updated <strong>pom.xml</strong></p>
  
  <pre><code>&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;1.4.0.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&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-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-jersey&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>
  
  <p><strong>Application.java</strong></p>
  
  <pre><code>@SpringBootApplication
  public class Application {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p><strong>ApplicationConfig.java</strong></p>
  
  <pre><code>@Configuration
  public class ApplicationConfig {
      @Named
      static class JerseyConfig extends ResourceConfig {
          public JerseyConfig() {
              this.packages("br.com.alexandreesl.handson.rest");
          }
      }
  
      @Bean
      public RestTemplate restTemplate() {
          RestTemplate restTemplate = new RestTemplate();
          return restTemplate;
      }
  }
  </code></pre>
  
  <p><strong>Order.java</strong></p>
  
  <pre><code>public class Order {
      private long id;
      private long amount;
      private Date dateOrder;
      private Customer customer;
      private Product product;
      // setters and getters
  }
  </code></pre>
  
  <p><strong>OrderRest.java</strong></p>
  
  <pre><code>@Named
  @Path("/")
  public class OrderRest {
      private long id = 1;
  
      @Inject
      private RestTemplate restTemplate;
  
      @GET
      @Path("order")
      @Produces(MediaType.APPLICATION_JSON)
      public Order submitOrder(@QueryParam("idCustomer") long idCustomer,
              @QueryParam("idProduct") long idProduct,
              @QueryParam("amount") long amount) {
  
          Customer customer = restTemplate.getForObject("http://localhost:8080/customer?id={id}", Customer.class, idCustomer);
          Product product = restTemplate.getForObject("http://localhost:8080/product?id={id}", Product.class,idProduct);
  
          Order order = new Order();
          order.setCustomer(customer);
          order.setProduct(product);
          order.setId(id);
          order.setAmount(amount);
          order.setDateOrder(new Date());
          id++;
          return order;
      }
  }
  </code></pre>
  
  <p><strong>Customer.java</strong></p>
  
  <pre><code>public class Customer {
      private long id;
      private String name;
      private String email;
      // setters and getters
  }
  </code></pre>
  
  <p><strong>CustomerRest.java</strong></p>
  
  <pre><code>@Named
  @Path("/")
  public class CustomerRest {
      private static List&lt;Customer&gt; customers = new ArrayList&lt;Customer&gt;();
  
      static {
          Customer customer1 = new Customer();
          customer1.setId(1);
          customer1.setNome("Customer 1");
          customer1.setEmail("customer1@gmail.com");
  
          Customer customer2 = new Customer();
          customer2.setId(2);
          customer2.setNome("Customer 2");
          customer2.setEmail("Customer2@gmail.com");
  
          Customer customer3 = new Customer();
          customer3.setId(3);
          customer3.setNome("Customer 3");
          customer3.setEmail("Customer3@gmail.com");
  
          Customer customer4 = new Customer();
          customer4.setId(4);
          customer4.setNome("Customer 4");
          customer4.setEmail("Customer4@gmail.com");
  
          Customer customer5 = new Customer();
          customer5.setId(5);
          customer5.setNome("Customer 5");
          customer5.setEmail("Customer5@gmail.com");
  
          customers.add(customer1);
          customers.add(customer2);
          customers.add(customer3);
          customers.add(customer4);
          customers.add(customer5);
      }
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public List&lt;Customer&gt; getCustomers() {
          return customers;
      }
  
      @GET
      @Path("customer")
      @Produces(MediaType.APPLICATION_JSON)
      public Customer getCustomer(@QueryParam("id") long id) {
          Customer cli = null;
          for (Customer c : customers) {
              if (c.getId() == id)
                  cli = c;
          }
          return cli;
      }
  }
  </code></pre>
  
  <p><strong>Product.java</strong></p>
  
  <pre><code>public class Product {
      private long id;
      private String sku;
      private String description;
      // setters and getters
  }
  </code></pre>
  
  <p><strong>ProductRest.java</strong></p>
  
  <pre><code>@Named
  @Path("/")
  public class ProductRest {
      private static List&lt;Product&gt; products = new ArrayList&lt;Product&gt;();
  
      static {
          Product product1 = new Product();
          product1.setId(1);
          product1.setSku("abcd1");
          product1.setDescription("Product1");
          Product product2 = new Product();
          product2.setId(2);
          product2.setSku("abcd2");
          product2.setDescription("Product2");
          Product product3 = new Product();
          product3.setId(3);
          product3.setSku("abcd3");
          product3.setDescription("Product3");
          Product product4 = new Product();
          product4.setId(4);
          product4.setSku("abcd4");
          product4.setDescription("Product4");
          products.add(product1);
          products.add(product2);
          products.add(product3);
          products.add(product4);
      }
  
      @GET
      @Produces(MediaType.APPLICATION_JSON)
      public List&lt;Product&gt; getProducts() {
          return products;
      }
  
      @GET
      @Path("product")
      @Produces(MediaType.APPLICATION_JSON)
      public Product getProduct(@QueryParam("id") long id) {
          Product prod = null;
          for (Product p : products) {
              if (p.getId() == id)
                  prod = p;
          }
          return prod;
      }
  }
  </code></pre>
  
  <p>Please guide on this issue.</p>