title: Error 404--Not Found - Unable to call REST WebService
body: <p>I am not lucky so far to get the solution for the below error,</p>
  
  <p>"Error 404--Not Found</p>
  
  <p>From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:</p>
  
  <p>10.4.5 404 Not Found</p>
  
  <p>The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
  If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address."</p>
  
  <p>but no luck and so posting this question here.</p>
  
  <p>I have a requirement to download a image file from the server location using RESTFul Web Services. So, i created a REST WS in eclipse as below steps,</p>
  
  <ol>
  <li>Eclipse --> File --> New Dynamic WebProject</li>
  <li>Created a service class called "DownloadWebService" in src</li>
  <li>Added Jersey libraries in Java Resources --> Libraries folder.</li>
  <li>Created index.jsp and web.xml in WebContent folder.</li>
  <li>Project right click --> Export--> WAR file.</li>
  </ol>
  
  <p>DownloadWebService:</p>
  
  <pre><code>package com.downloadfile.webservice;
  import java.io.File;
  import java.util.logging.Logger;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.Response;
  import javax.ws.rs.core.Response.ResponseBuilder;
  @Path("/files")   
  public class DownloadWebService { 
  
      private static final String FILE_PATH = "/ngs/app/alect/test";  
      @POST   
      @Path("/image")   
      @Produces("image/png")    
      public Response getFile() { 
          System.out.println("************");
          Logger.getLogger("############");
          File file = new File(FILE_PATH);    
          ResponseBuilder response = Response.ok((Object) file);
          System.out.println("testing Web Service..."+FILE_PATH);
          System.out.println("");
          response.header("Content-Disposition","attachment; filename=\"test.png\"");  
          return response.build();     
  
      }  
   }  
  </code></pre>
  
  <p>Web.xml:</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://java.sun.com/xml/ns/javaee"   
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"   
  id="WebApp_ID" version="3.0"&gt;  
   &lt;servlet&gt;  
      &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;  
      &lt;servlet-class&gt;com.downloadfile.webservice.DownloadWebService&lt;/servlet-class&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>Index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;a href="rest/files/image"&gt;Download Image File&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am able to deploy this WAR application in WebLogic server and when i hit the test below link, it's taking me the index.jsp file in the browser which is expected and it's correct. After i click the link "Download Image File", its forwarding the below URL in the browser</p>
  
  <p><a href="http://alecitapp.corp.apple.com:7007/AppleDownloadWebService/rest/files/image" rel="nofollow">http://alecitapp.corp.apple.com:7007/AppleDownloadWebService/rest/files/image</a></p>
  
  <p>It's throwing the above said 404 --Not found error.</p>
  
  <p>Am i missing something here? Not even seeing the Service class is being called? Index page is coming up and on click the download link it should go to the Service class but it didn't.</p>
  
  <p>Please correct me if i am doing wrong.</p>
  
  <p>Thanks,
  Karthik.</p>