hammock-project/hammock

Jetty + Jersey doesn't work

Closed this issue · 10 comments

If you run the jersey tests with jetty as a container, it fails on a 404. Resteasy works fine.

@shamoh any ideas on this one?

@johnament Do you have test case or example to simply reproduce the issue? Thanks.

@shamoh Yes, I actually turned on travis now for all three types of containers. To reproduce, run mvn install -Dwebserver=jetty from rest-jersey

@johnament I'm not so familiar with Arquillian. Could you recommend me how to configure IDE(A) to run single test? Thanks.

Assuming you're on the latest, it should just work. I use manual container configuration. Try this page https://www.jetbrains.com/help/idea/2016.2/arquillian-a-quick-start-guide.html

@johnament mvn install -Dwebserver=jetty in rest-jersey no more fails. You probably fix the issue.

I see, it is necessary now to use jetty-test profile (mvn install -Pjetty-test).

Hi sorry @shamoh you are correct. I was using the -Dwebserver property however it was creating some failing tests in my release build run so decided to switch back. Should have let you know.

Jersey expects that:

  • a servlet name is JerseyServlet
  • and ServletContext.getAttribute('jersey.config.servlet.internal.resourceConfig_JerseyServlet') returns configured org.glassfish.jersey.server.ResourceConfig instance.

Hammock part to fulfill Jersey's expectation is in JerseyContainerConfigurator class, rest-jersey module.

But Jetty Hammock support breaks these expectations:

  • servlet name is for example org.glassfish.jersey.servlet.ServletContainer-aa149ed
  • servlet attribute does not contain any value jersey.config.servlet.internal.resourceConfig_* value.

I will investigate more. But maybe you know even now why Jetty behaves differently comparing to for example Undertow.

Ah ha! Thanks for the tip @shamoh

Based on what you described, I noticed that the servlet that gets registered in jetty has no name. When I tried to give it a name, things broke. Turns out to give it a name, you need to create the servlet holder and then manually add it.

I can push up a fix, but 100% credit goes to you on this.