title: HTTP Status 405 - Method Not Allowed Error for Rest API
body: <p>Am asking this question after doing some research. I did followed the solutions given for this kind of error but did not work for me. Any suggestions as where am going wrong in the below code.I am creating a REST API but when I request the url it is giving me the 405 error.Below is the URI am requesting.</p>
  
  <pre><code>    http://localhost:8080/Project/services/start/version
  </code></pre>
  
  <p>Below is the code snippet.</p>
  
  <pre><code>@Path("/start")
  
  public class StartService {
  @GET
  @Path("/version")
  @Produces({"text/plain","application/xml","application/json"})
  public String getVersion() {
      String ver="";
  
      try{
  
  
            Runtime rt = Runtime.getRuntime();
            Process pr = rt.exec("C:\\server\\dgr -v" );
  
            BufferedReader stdInput = new BufferedReader(new InputStreamReader
  (pr.getInputStream()));
            BufferedReader input = new BufferedReader(stdInput);
           // String ver ="";
            StringBuffer verOutput = new StringBuffer();
                  while((ver =  input.readLine()) != null){
                      verOutput.append(ver + "\n");
                      System.out.println(ver);
                  }
  
  
          }catch (Throwable t)  
            {  
              t.printStackTrace();  
            }  
  
  
          finally {  
  
          }
      return ver;  }
  
  }
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;web-app 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  version="3.0"&gt;
  
  &lt;servlet&gt;
  &lt;display-name&gt;eLicensingWeb&lt;/display-name&gt;      
      &lt;servlet-name&gt;JAX-RS REST&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.container.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.cem.plc.service&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;JAX-RS REST&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/services/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  
  &lt;/web-app&gt;
  </code></pre>