users@jersey.java.net

Re: [Jersey] Re: roll-your-own Guice

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Sat, 4 Jul 2009 09:15:41 -0400

Hi Bill,
My class named jerseyGuiceModule extends ServletModule, which has the
method serve() as well as serveRegex(). So the short answer is that
it comes from package com.google.inject.servlet.ServletModule which I
found in guice-servlet-2.0.jar.

http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/servlet/ServletModule.html

You can download it here:

http://code.google.com/p/google-guice/

the file guice-2.0.zip includes that.

A lot of the early problems I had were because I was using old jars,
examples, and docs. Paul S. pointed this out, which set me on my way.




On Sat, Jul 4, 2009 at 6:41 AM, Bill de hOra<bill_at_dehora.net> wrote:
> Christopher Piggott wrote:
>>
>> I fixed that.  Again, the web.xml had a problem.  When you define a
>> <filter> you apparently have to also define a <filter-mapping> that
>> matches it.  Looking at the example in
>>
>> https://jersey.dev.java.net/nonav/apidocs/1.1.0-ea/contribs/jersey-guice/com/sun/jersey/guice/spi/container/servlet/package-summary.html
>> I thought that if you didn't declare a filter-mapping it would default
>> to mapping to everything.  Apparently not.  (I should have known this
>> - I had the same problem the first time I ever declared a <servlet>
>> without a <servlet-mapping>)
>>
>> Apologies for what turned out to be a problem with my tomcat
>> configuration, really having nothing to do with jersey.
>>
>>
>> So ... I have a more-or-less complete example now, using guice, tomcat
>> 6.0.18, and jersey 1.1.0-ea.  If anybody needs any snippets on how I
>> made this work please let me know.  It is all a lot of fun once you
>> get it going.
>
> It's more or less what I wound up with as well.
>
> This bit's interesting:
>
>  serve("/*").with(GuiceContainer.class);
>
> it gives me an error because GuiceContainer does not extends HttpServlet so
> I end up only using filter("/*").through. What dependencies are you using?
>
> I ran into a JSP rendering problem with Guice; apparently it's a known bug
> with the way things are forwarded. The workaround for me is not to put the
> Guice filter into web.xml for injection, instead I have jersey resources
> inject their fields manually (which kind of sucks unfortunately). That or
> ensure Guice's filter is not in the same url-pattern scope as the the JSPs.
>
> Bill
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>