I'm very new to java so I'm not sure why this is happening.
I have developed a small java application using Jersey + Jetty. This works perfectly when running it in intelliJ but doesn't work from the jar. When I go to localhost:2222 jetty should show me a index.html page but instead jetty says No context on this server matched or handled this request.
Jar was created using these instructions How to build jars from IntelliJ properly?
public class App{
private static final int SERVER_PORT = 2222;
public static void main(String[] args) throws Exception {
URI baseUri = UriBuilder.fromUri("http://localhost").port(SERVER_PORT)
.build();
ResourceConfig config = new ResourceConfig(Resource.class);
Server server = JettyHttpContainerFactory.createServer(baseUri, config,
false);
ContextHandler contextHandler = new ContextHandler("/rest");
contextHandler.setHandler(server.getHandler());
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setResourceBase("src/Web");
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { resourceHandler,
contextHandler, new DefaultHandler() });
server.setHandler(handlerCollection);
server.start();
server.join();
}
}