title: JAX RS - Embedded Jetty and Swagger not getting json
body: <p>With Below code I am able to call my API with:</p>
  
  <pre><code>http://localhost:8080/test/myapi/squareRoot?input=2
  </code></pre>
  
  <p>and get the output</p>
  
  <pre><code>{
      "action":"Square Root",
      "input":2.0,"output":1.4142135623730951
  }
  </code></pre>
  
  <p>but when I try to call</p>
  
  <pre><code>http://localhost:8080/test/swagger.json
  </code></pre>
  
  <p>I am getting a 404 error. Please help me understand my error.</p>
  
  <pre><code>package com.krish.som.controller;
  
  import io.swagger.annotations.Api;
  import io.swagger.annotations.ApiOperation;
  
  import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.QueryParam;
  import javax.ws.rs.core.MediaType;
  
  @Path("myapi")
  @Api(value = "/squareRoot", description = "Web Services to browse squareRoot")
  public class Calculator {
  
  
      @GET
      @Path("squareRoot")
      @ApiOperation(value = "Return one entity", notes = "Returns one entity at random", response = Result.class)
      @Produces(value = MediaType.APPLICATION_JSON)
      public Result squareRoot(@QueryParam("input") double input){
          Result result = new Result("Square Root");
          result.setInput(input);
          result.setOutput(Math.sqrt(result.getInput()));
          return result;
      }
  
      @GET
      @Path("square")
      @Produces(MediaType.APPLICATION_JSON)
      public Result square(@QueryParam("input") double input){
          Result result = new Result("Square");
          result.setInput(input);
          result.setOutput(result.getInput()*result.getInput());
          return result;
      }
  
      static class Result{
          double input;
          double output;
          String action;
  
          public Result(){}
  
          public Result(String action) {
              this.action = action;
          }
  
          public String getAction() {
              return action;
          }
  
          public void setAction(String action) {
              this.action = action;
          }
  
          public double getInput() {
              return input;
          }
  
          public void setInput(double input) {
              this.input = input;
          }
  
          public double getOutput() {
              return output;
          }
  
          public void setOutput(double output) {
              this.output = output;
          }
      }
  }
  
  
  
  
  package com.krish.som.controller;
  
  import com.krish.som.controller.Calculator;
  import io.swagger.jaxrs.config.DefaultJaxrsConfig;
  import org.eclipse.jetty.server.Server;
  import org.eclipse.jetty.servlet.ServletContextHandler;
  import org.eclipse.jetty.servlet.ServletHolder;
  import org.glassfish.jersey.servlet.ServletContainer;
  
  public class SOMServer {
      public SOMServer() {
      }
  
      public static void main(String[] args) throws Exception {
          Server server = new Server(8080);
          ServletContextHandler context = new ServletContextHandler(1);
          context.setContextPath("/test");
          server.setHandler(context);
          ServletHolder apiServlet = context.addServlet(ServletContainer.class, "/*");
          apiServlet.setInitParameter("jersey.config.server.provider.classnames", Calculator.class.getCanonicalName());
          apiServlet.setInitOrder(0);
          apiServlet.setInitParameter("com.sun.jersey.config.property.packages", "com.krish.som.controller;io.swagger.jaxrs.json;io.swagger.jaxrs.listing;io.swagger.resources");
          ServletHolder swaggerServlet = context.addServlet(DefaultJaxrsConfig.class, "/swagger-core");
          swaggerServlet.setInitOrder(1);
          server.start();
          server.join();
      }
  }
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns="http://maven.apache.org/POM/4.0.0"
           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.krish&lt;/groupId&gt;
      &lt;artifactId&gt;som&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;dependencies&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
              &lt;artifactId&gt;jetty-server&lt;/artifactId&gt;
              &lt;version&gt;9.2.3.v20140905&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
              &lt;artifactId&gt;jetty-servlet&lt;/artifactId&gt;
              &lt;version&gt;9.2.3.v20140905&lt;/version&gt;
          &lt;/dependency&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.7&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-core&lt;/artifactId&gt;
              &lt;version&gt;2.7&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-jetty-http&lt;/artifactId&gt;
              &lt;version&gt;2.7&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt;
              &lt;version&gt;2.7&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;io.swagger&lt;/groupId&gt;
              &lt;artifactId&gt;swagger-jersey2-jaxrs&lt;/artifactId&gt;
              &lt;version&gt;1.5.3&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
              &lt;version&gt;${slf4j-version}&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;${slf4j-version}&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;slf4j-version&gt;1.7.12&lt;/slf4j-version&gt;
      &lt;/properties&gt;
  &lt;/project&gt;
  </code></pre>