sunnygleason / j4-minimal

Minimal web application example using Embedded Jetty, Jersey, Guice, and Jackson
62 stars 19 forks source link

Eliminate need for EmptyServlet #3

Open shaggyfrog opened 12 years ago

shaggyfrog commented 12 years ago

Is it possible to eliminate the need for the EmptyServlet class? Perhaps since newer versions of Jersey and/or Guice and/or jersey-guice have been released?

sunnygleason commented 12 years ago

After a quick look -- not that I know of, based on this page, and the examples provided at guice-servlet:

http://randomizedsort.blogspot.com/2011/05/using-guice-ified-jersey-in-embedded.html http://code.google.com/p/google-guice/wiki/ServletModule

Most examples I've seen use DefaultServlet; I tend to prefer the provided EmptyServlet because it can't possibly expose any additional services.

If you discover a way to eliminate the use of EmptyServlet, please let us know -- pull requests are always welcome!

Cheers and best regards,

-Sunny

shaggyfrog commented 12 years ago

On May 25, 2012, at 8:05 AM, Sunny Gleason wrote:

After a quick look -- not that I know of, based on this page, and the examples provided at guice-servlet:

http://randomizedsort.blogspot.com/2011/05/using-guice-ified-jersey-in-embedded.html http://code.google.com/p/google-guice/wiki/ServletModule

Most examples I've seen use DefaultServlet; I tend to prefer the provided EmptyServlet because it can't possibly expose any additional services.

If you discover a way to eliminate the use of EmptyServlet, please let us know -- pull requests are always welcome!

Cheers and best regards,

-Sunny

Thanks for the reply, Sunny!

Check out this Gist: https://gist.github.com/2831098

Using that web.xml (or something like it), I can use the mvn jetty:run command to start up my service without any mention of a servlet or EmptyServlet. It would seem to me if that web.xml is enough to get my service off the ground using the maven jetty plugin, there must be an analogous way to start up Jetty inside Java code (i.e. "embedded Jetty"). From the log output, it looks like oejsh.ContextHandler is instantiated instead of ServletContextHandler.

Any thoughts?

Thomas Hauk Shaggy Frog Software www.shaggyfrog.com