users@jersey.java.net

Re: [Jersey] Better example

From: Rebel Geek <rebel.geek_at_gmail.com>
Date: Thu, 22 Jul 2010 12:17:58 -0400

Thanks, Leonardo.

Let me see if I grok what you're saying....

1) Use the com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory as before
2) Edit my web.xml according to your instructions.
3) Create my REST resources as before

The only thing I'm missing is how does the application read/use the web.xml? Originally, I was invoking my application from the command line, like....

java -jar jetty-runner.jar --path /myContext myApp.war

I now want to run my app like...

java -jar myApp.jar

And have it serve up the HTML, Servlets and RESTful services. Which is why I want to embed the web server in the app.

Regards,


Alfred


On Jul 22, 2010, at 12:07, Leonardo wrote:

> Hi Rebel,
>
> on your web.xml do something like this:
>
> <servlet>
> <description>servlet do jersey</description>
> <display-name>ServletContainer</display-name>
> <servlet-name>ServletContainer</servlet-name>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>ServletContainer</servlet-name>
> <url-pattern>/service/*</url-pattern>
> </servlet-mapping>
>
> and if you want some classpath scanning facilities, grab those jars
> (those are a bit outdated, but will do the job as example):
>
> asm-3.1.jar
> jersey-core-1.1.5.1.jar
> jersey-json-1.1.5.1.jar
> jersey-server-1.1.5.1.jar
> jsr311-api-1.1.jar
>
> 2010/7/22 Rebel Geek <rebel.geek_at_gmail.com>:
>> Hello,
>> I did a few searches in the forums and I could not find what I was looking
>> for, so please forgive me if I've indadvertedly repeated a question....
>> I have a Wep Application (WAR) that I have running with the Jetty-runner. It
>> has the following features:
>>
>> Serves up dojo pages (static HTML)
>> Has Servlets/filters for authentication and AJAX
>>
>> I would like to add Jersey RESTful services to this, but I'd also like to
>> get rid of Jetty and use Grizzly completely embedded in the application. I
>> see examples of embedding Grizzly and I see examples of creating REST
>> Resource, etc., but I don't see any examples that will point me to using
>> Jersey/Grizzly to create a web server that will server HTML, Servlets and
>> RESTful services all in one.
>> The reason why I'm struggling is because the Jersey examples use the
>> com.sun.jersey.api.container.grizzly.GrizzlyWebContainerFactory as opposed
>> to GrizzlyWebServer class from the Grizzly packages. Can somebody point me
>> to documentation or an example that will put me on the correct path?
>> Thank you,
>> Alfred
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>