title: Cannot get REST response (with Postman). Java, IntelliJ, Tomcat 9, Maven
body: <p>I'm only a beginner. I have this project that I was working on a training course. It was set up on Eclipse and it was working. I'm now trying to get this same code working using IntelliJ Ultimate and I cannot any rest response. I'm probably doing something wrong but I have no clue what it could be as I do not understand much when it comes setting things up. I tried both browser and Postman and I get error 404. I also tried to set a breakpoint to the code and it does not get activated.
  I created a new project, chose Web Aplication and RESTful web services from additional Libraries and Frameworks. I also added Maven framework. I have installed  JDK 1.8 and Tomcat 9.</p>
  
  <p>Below is my maven BOM. I'm not sure if all is correct:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><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 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.wip.controller&lt;/groupId&gt;
      &lt;artifactId&gt;TestApp&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
              &lt;version&gt;2.25.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt;
              &lt;version&gt;2.25.1&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-servlet&lt;/artifactId&gt;
              &lt;version&gt;1.19.3&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.sun.jersey&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-json&lt;/artifactId&gt;
              &lt;version&gt;1.19.3&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;6.0.5&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
      
  &lt;/project&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my web.xml</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
           version="3.1"&gt;
  
      &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
              &lt;param-value&gt;com.wip.controller&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;/param-name&gt;
              &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
  
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;jersey-serlvet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is an example of one of my controller class. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>package com.wip.controller;
  
  import com.wip.bean.FoodGroup;
  import com.wip.service.FoodGroupService;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  import java.util.List;
  
  @Path("/foodgroups")
  public class FoodGroupController
  {
   FoodGroupService foodGroupService = new FoodGroupService();
  
   @GET
   @Produces(MediaType.APPLICATION_JSON)
   public List&lt;FoodGroup&gt; getFoodGroups()
   {
    List&lt;FoodGroup&gt; listOfFoodGroups = foodGroupService.getAllFoodGroups();
    return listOfFoodGroups;
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I tried to use this on postman "localhost:8080/rest/foodgroups"
  This gives me a 404 as below:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Apache Tomcat/9.0.0.M17 - Error report&lt;/title&gt;
          &lt;style type="text/css"&gt;h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}&lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;HTTP Status 404 - &lt;/h1&gt;
          &lt;div class="line"&gt;&lt;/div&gt;
          &lt;p&gt;
              &lt;b&gt;type&lt;/b&gt; Status report
          &lt;/p&gt;
          &lt;p&gt;
              &lt;b&gt;message&lt;/b&gt;
              &lt;u&gt;&lt;/u&gt;
          &lt;/p&gt;
          &lt;p&gt;
              &lt;b&gt;description&lt;/b&gt;
              &lt;u&gt;The requested resource is not available.&lt;/u&gt;
          &lt;/p&gt;
          &lt;hr class="line"&gt;
          &lt;h3&gt;Apache Tomcat/9.0.0.M17&lt;/h3&gt;
      &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>There aren't any errors that come up with server log either.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17\bin\catalina.bat run
  [2017-03-26 07:51:13,166] Artifact TestApp:war exploded: Server is not connected. Deploy is not available.
  Using CATALINA_BASE:   "C:\Users\laptop\.IntelliJIdea2016.3\system\tomcat\Tomcat_9_0_0_M17_TestApp"
  Using CATALINA_HOME:   "D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17"
  Using CATALINA_TMPDIR: "D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17\temp"
  Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_121"
  Using CLASSPATH:       "D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17\bin\bootstrap.jar;D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17\bin\tomcat-juli.jar"
  Connected to the target VM, address: '127.0.0.1:49794', transport: 'socket'
  26-Mar-2017 19:51:13.971 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/9.0.0.M17
  26-Mar-2017 19:51:13.972 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jan 10 2017 20:59:20 UTC
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.0.0
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 8.1
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            6.3
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_121\jre
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_121-b13
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\laptop\.IntelliJIdea2016.3\system\tomcat\Tomcat_9_0_0_M17_TestApp
  26-Mar-2017 19:51:13.973 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\laptop\.IntelliJIdea2016.3\system\tomcat\Tomcat_9_0_0_M17_TestApp\conf\logging.properties
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:49794,suspend=y,server=n
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
  26-Mar-2017 19:51:13.974 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
  26-Mar-2017 19:51:13.975 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\laptop\.IntelliJIdea2016.3\system\tomcat\Tomcat_9_0_0_M17_TestApp
  26-Mar-2017 19:51:13.975 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17
  26-Mar-2017 19:51:13.975 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17\temp
  26-Mar-2017 19:51:13.975 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library 1.2.10 using APR version 1.5.2.
  26-Mar-2017 19:51:13.975 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
  26-Mar-2017 19:51:13.975 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
  26-Mar-2017 19:51:14.806 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized (OpenSSL 1.0.2j  26 Sep 2016)
  26-Mar-2017 19:51:14.908 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
  26-Mar-2017 19:51:14.922 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
  26-Mar-2017 19:51:14.924 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
  26-Mar-2017 19:51:14.926 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
  26-Mar-2017 19:51:14.926 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1258 ms
  26-Mar-2017 19:51:14.949 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
  26-Mar-2017 19:51:14.949 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M17
  26-Mar-2017 19:51:14.958 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
  26-Mar-2017 19:51:14.965 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
  26-Mar-2017 19:51:14.966 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 40 ms
  Connected to server
  [2017-03-26 07:51:15,313] Artifact TestApp:war exploded: Artifact is being deployed, please wait...
  [2017-03-26 07:51:15,673] Artifact TestApp:war exploded: Artifact is deployed successfully
  [2017-03-26 07:51:15,674] Artifact TestApp:war exploded: Deploy took 360 milliseconds
  26-Mar-2017 19:51:24.965 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17\webapps\manager
  26-Mar-2017 19:51:25.034 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory D:\PROJECTS\Programming\apache-tomcat-9.0.0.M17\webapps\manager has finished in 68 ms</code></pre>
  </div>
  </div>
  </p>
  
  <p>I would be super grateful if someone has any ideas what to try next.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Thanks to the link provided by CrazyCoder I have manged to get my REST services to work. Like "localhost:8080/helloworld" works just fine and so some other links to some of my services work fine as well when I tested them through Postman. The only thing I'm struggling now is to get the index.html to come up.</p>
  
  <p>I have tried pretty much every combination in my browser I can think of with no joy:</p>
  
  <pre><code>http://localhost:8080/
  http://localhost:8080/index.html
  http://localhost:8080/MyProject/index.html
  </code></pre>
  
  <p>And it keeps saying that <code>This localhost page can’t be found</code></p>
  
  <p><a href="https://i.stack.imgur.com/p5NKW.png" rel="nofollow noreferrer">Latest screenshot of settings</a></p>
  
  <p>If someone has an idea of what I could try, please advise. I'm just so close to get it running. Thank you.</p>