You're going about it the wrong way. JerseyJaxrsConfig is a hack to pass in config params to Swagger, statically. You can just do something like this in startServer()
ServletConfig sc = new MyServletConfig();
JerseyJaxrsConfig jjc = new JerseyJaxrsConfig();
jjc.init(sc);
return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
Here's a sample MyServletConfig class (I use an inner class on Main):
private static class MyServletConfig implements ServletConfig {
private Map<String, String> initParams = new HashMap<>();
private MyServletConfig() {
initParams.put("api.version", "1.0.0");
initParams.put("swagger.api.basepath", "http://localhost:8080/content-store");
}
@Override
public String getServletName() {
return "JaxRS Servlet";
}
@Override
public ServletContext getServletContext() {
return null;
}
@Override
public String getInitParameter(String s) {
return initParams.get(s);
}
@Override
public Enumeration getInitParameterNames() {
return Collections.enumeration(initParams.keySet());
}
}
I frankly have no clue about most of what you are doing in main(String[]), but if you were trying to mock a web context to pass on those values to Swagger, drop the code. Mine looks like this:
public static void main(String[] args) throws IOException {
final HttpServer server = startServer();
System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...", BASE_URI));
System.in.read();
server.stop();
}
All that being said, this is an alternative way of doing it:
ConfigFactory.config().setBasePath("http://localhost:8080/content-store");
It basically does the same thing; I also wanted to customize other things that are more Jersey specific so I kept using the JerseyJaxrsConfig class, so I used the first incantation, but your mileage may vary.
Hope that helps!