Ahh, nuts.
I think I figured it out. This did not work:
http://localhost:8890/test
so I tried changing the context to this:
WebappContext ctx = new WebappContext("hub", "/crap");
then, this worked:
http://localhost:8890/crap/test
but I don't want that, I want it at the root. So I changed it back to this:
WebappContext ctx = new WebappContext("hub", "/");
and discovered that this worked:
http://localhost:8890//test
so then I tried, somewhat randomly, an empty context path:
WebappContext ctx = new WebappContext("hub", "/");
and, holy smokes, this now works:
http://localhost:8890/test
That wasn't obvious to me AT ALL.
On Thu, Jun 7, 2012 at 4:50 PM, Christopher Piggott <cpiggott_at_gmail.com> wrote:
> http://java.net/projects/jersey/sources/svn/content/trunk/jersey/contribs/jersey-guice/src/test/java/com/sun/jersey/guice/AbstractGuiceGrizzlyTest.java?rev=5717
>
> In this file, line 105, in the tests you create a GuiceFilter (which
> makes sense to me) but also a Servlet that does nothing.
>
> Can somebody explain why the servlet?
>
> I'm trying to more or less replicate setting up grizzly2 + guice +
> jersey. This was all working great with grizzly 1.9 but I want to
> upgrade to grizzly 2, and a lot has changed. What I have so far is
> this:
>
> WebappContext ctx = new WebappContext("hub", "/");
> ctx.addListener(HubContextListener.class);
> FilterRegistration reg = ctx.addFilter("gf", GuiceFilter.class);
> reg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), "/*");
>
> HttpServer ws = HttpServer.createSimpleServer("/", 8890);
> ctx.deploy(ws);
>
> This isn't exactly the same as that unit test because I'm not using
> the jersey-grizzly2 package. I need to create the server myself, I
> think, because I have to attach an SSLConfig to it, and I didn't see a
> way to do that when you create it through GrizzlyServerFactory
> (correct me if I'm wrong here). Either way ... it doesn't seem like
> it should be necessary: create an HttpServer and deploy this
> WebappContext to it.
>
> What happens is:
> * Server starts on the right port
> * Context listener gets called
> * Main injector gets created
> * My custom container request filter gets created
> * All my root resources and providers get found by
> ScanningResourceConfig (yay!)
>
> but when I go to make any request, all that happens is my container
> request filter gets hit (which emits some log messages). The request
> doesn't seem to go any further than that. It returns a 404. (The
> resource module ends with .serve("/*") like usual).
>
> Now, all of this worked under grizzly 1.9.4 OK, but of course the way
> you set up the server/filters is completely different.
>
>
> Any idea what could be wrong?
>
> --Chris