title: javax.ws.rs.NotFoundException: HTTP 404 Not Found
body: <p>Below is the web.xml config file:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
  http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" 
  version="3.1"&gt;
   &lt;display-name&gt;pgwrapper&lt;/display-name&gt;
  &lt;servlet&gt;
     &lt;servlet-name&gt;Jersey REST Service&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;jersey.config.server.provider.packages&lt;/param-name&gt;
    &lt;param-value&gt;com.example.postgres.wrapper&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 REST Service&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Below is my ServiceClassProvider.java file:</p>
  
  <pre><code> @SuppressWarnings({ "rawtypes", "unchecked" })
   @Path("/pg")
   public class PostgresDBServiceProvider {
        static final String HOST = "select * from host";
  
       /**
          * @return All Host Ids
          * @throws Exception
       */
       @GET
       @Path("/getAllHostIds")
       @Produces({ MediaType.APPLICATION_XML })
       public static String getAllHostIds() throws Exception {
           List&lt;String&gt; list = new ArrayList&lt;&gt;();
           String hostId = null;;
           ListWrapper listWrapper = new ListWrapper();
           Statement st = PostgresDBConnector.getInstance().createStatement();
           ResultSet rs = st.executeQuery(HOST);
           while (rs.next()) {
               hostId = rs.getString("host_id");
               break;
        }
         return hostId;
       }
  </code></pre>
  
  <p>Client.java:</p>
  
  <pre><code>   public class PostgresClient {
  
     @SuppressWarnings("unchecked")
     public static void main(String[] args) throws Exception {
     .......................
     Client client =
          ClientBuilder.newBuilder().withConfig(config)
                .hostnameVerifier(new InsecureHostnameVerifier())
                .sslContext(ctx).build();
  
    WebTarget target = client.target(getBaseURI());
    String hostIp =
          target.path("rest")
                .path("getAllHostIds").request()
                .accept(MediaType.TEXT_PLAIN).get(String.class);
  
    System.out.println("hostIp:" + hostIp);
  
   }
  
        private static URI getBaseURI() {
       return UriBuilder.fromUri("https://192.168.100.108:8443/pg").build();
    }
  
   }
  </code></pre>
  
  <p>While running thje client ,I am getting below error:</p>
  
  <pre><code> Exception in thread "main" javax.ws.rs.NotFoundException: HTTP 404 Not 
   Found
  </code></pre>
  
  <p>at </p>
  
  <pre><code> org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:1020)
      at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:819)
      at org.glassfish.jersey.client.JerseyInvocation.access$700(JerseyInvocation.java:92)
  </code></pre>
  
  <p>My Tomcat server is running on 8443,but I am unable to execute this rest endpoint, not sure which configuration is missed here.Need pointers to proceed in this.</p>