I have defined jersey service as:
private static HttpServer createHttpServer() throws IOException {
final ResourceConfig resourceConfig = new ResourceConfig(Api.class);
return JdkHttpServerFactory.createHttpServer(URI, resourceConfig);
}
This compiles fine. But when I try to run it it throws java.lang.NoClassDefFoundError
:
Exception in thread "main" java.lang.NoClassDefFoundError: org/glassfish/jersey/server/ResourceConfig
at EmbeddedHTTPServer.createHttpServer(Unknown Source)
at EmbeddedHTTPServer.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.server.ResourceConfig
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
These are the libs:
$ ls lib
commons-collections-3.2.1.jar jsoup-1.8.3.jar
commons-dbcp-1.4.jar logback-classic-1.1.3.jar
commons-email.jar logback-core-1.1.3.jar
commons-io-2.4.jar mail.jar
commons-lang3-3.0.1.jar mysql-connector-java-5.1.17.jar
gdata-core.jar quartz-2.2.1.jar
javaee-web-api.jar rome-1.5.1.jar
jdom2-2.0.6.jar rome-modules-1.5.1.jar
jersey-container-jdk-http.jar rome-utils-1.5.1.jar
jersey-server.jar slf4j-api-1.7.12.jar
json.jar
Env:
- Ubuntu
- Oracle JDK 1.8
- JAX-RS 2
Any idea?
Thanks.