users@glassfish.java.net

Re: JAX-RS (Jersey) on Java 6 Endpoint

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 25 Aug 2009 21:19:21 +0200

On Aug 25, 2009, at 5:54 PM, glassfish_at_javadesktop.org wrote:

> From what I can tell it is supposed to be possible to publish a
> RESTful web service using the built-in Java 6 Endpoint. But I can't
> figure it out.
>
> Perhaps I have a dependency issue, but ultimately it's boilding down
> to this line of code failing.
>
> [code]RuntimeDelegate.getInstance().createEndpoint(app,
> javax.xml.ws.Provider.class);[/code]
>

The JAX-WS Provider is no longer supported.

You can use the Light Weight HTTP server directly, for example:

   RuntimeDelegate.getInstance().createEndpoint(app,
com.sun.net.httpserver.HttpServer.class);

You can also use a Jersey helper class to create an HttpServer:

   https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/container/httpserver/HttpServerFactory.html

But this may limit the configuration possibilities.


> which gives me:
> [pre]Exception in thread "main" java.lang.IllegalArgumentException:
> No container provider supports the type interface
> javax.xml.ws.Provider
> at
> com
> .sun
> .jersey
> .api
> .container.ContainerFactory.createContainer(ContainerFactory.java:183)
> at
> com
> .sun
> .jersey
> .api
> .container.ContainerFactory.createContainer(ContainerFactory.java:130)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .provider
> .RuntimeDelegateImpl.createEndpoint(RuntimeDelegateImpl.java:74)
> [/pre]
>
> I've added the following to my classpath:
> jsr311-api.jar
> jersey-server-1.0.3.1.jar
> jersey-core-1.0.3.1.jar
> jersey-json-1.0.3.1.jar
> jersey-simple-1.0.3-SNAPSHOT.jar (links are broken for this one,
> 1.0.3 snapshot is the best I can find)
>

You do not require the last one.

See attached for a basic maven project.

Paul.






> Can anyone post an example of using JAX_RS that does not use Grizzly
> or any other App Server (i.e. GlassFish). I want a lightweight
> solution that is easily embedded in my app... I already use the
> built-in Java 6 Endpoint for a JAX-WS service.
>
> Thanks,
>
> Scott
> [Message sent by forum member
> 'swpalmer' (scott.palmer_at_2connected.org)]
>
> http://forums.java.net/jive/thread.jspa?messageID=361869
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>