I'm trying to create a Java server for a REST API and following this question I used jersey's JdkHttpServer. I imported the necessary jars (from here), but when I start the server the following error appears:
Exception in thread "main" java.lang.AbstractMethodError: org.glassfish.jersey.jdkhttp.JdkHttpHandlerContainerProvider.createContainer(Ljava/lang/Class;Ljavax/ws/rs/core/Application;)Ljava/lang/Object;
at org.glassfish.jersey.server.ContainerFactory.createContainer(ContainerFactory.java:58)
at org.glassfish.jersey.jdkhttp.JdkHttpServerFactory.createHttpServer(JdkHttpServerFactory.java:78)
at PokerJAXRS.main(PokerJAXRS.java:16)
My code is the following:
import com.sun.net.httpserver.HttpServer;
import org.glassfish.jersey.jdkhttp.JdkHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;
import java.net.URI;
public class PokerJAXRS {
private static String baseUri = "http://localhost:9998/";
public static void main(String[] args) throws Exception {
URI bUri = URI.create(baseUri);
HttpServer server = JdkHttpServerFactory.createHttpServer(bUri, new ResourceConfig(PokerResource.class));
System.out.println("Server running");
System.out.println("Visit: http://localhost:9998/");
System.out.println("Hit return to stop...");
System.in.read();
server.stop(0);
System.out.println("Server stopped");
}
}
And in PokerResource
I've got all the paths for the API. Am I missing some import or do I have to define anything else?
EDIT: These are all the jar libs I'm using: