Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Latest Jersey example does not work

I have isntalled the latest version of jersey (Bundle-Version: 2.13.0) and the examples for that version. Then I tried (for testing Restful services - \examples\helloworld-pure-jax-rs\src\main\java\org\glassfish\jersey\examples) the Hello World example in Eclipse. The result ist this:

"Hello World" Jersey Example Application
Exception in thread "main" java.lang.IllegalArgumentException: No container provider supports the type interface com.sun.net.httpserver.HttpHandler
at org.glassfish.jersey.server.ContainerFactory.createContainer(ContainerFactory.java:87)
at org.glassfish.jersey.server.internal.RuntimeDelegateImpl.createEndpoint(RuntimeDelegateImpl.java:71)
at org.glassfish.jersey.examples.helloworld.jaxrs.App.startServer(App.java:72)
at org.glassfish.jersey.examples.helloworld.jaxrs.App.main(App.java:88)

I thought the example should work out of the box as it does not use any specific http servers. Only

import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;

My Java version is:

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) Client VM (build 25.25-b02, mixed mode, sharing)

Any idea what could be wrong or what I missed?

best Klemens

like image 537
user2737950 Avatar asked Sep 06 '25 18:09

user2737950


1 Answers

In my case I was following an example. Finally I only needed to add this dependency org.glassfish.jersey.containers jersey-container-jdk-http (remember the exception's message "No container provider supports the type interface com.sun.net.httpserver.HttpHandler"):

    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-jdk-http</artifactId>
        <version>2.18</version>
    </dependency>

You could change the version according your environment.

like image 138
lmiguelmh Avatar answered Sep 08 '25 06:09

lmiguelmh