Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add PippoFilter as Guice Filter #369
I would like to use Pippo with Guice, but not the way described here: http://www.pippo.ro/mod/guice.html
I use the ServletModule from Guice and try to add the PippoFilter like this:
Unfortunately I get the following exception:
GuiceFilter looks like this:
I guess Pippo expects a web.xml configuration and reads the properties from web.xml and fails. My workaround for now is to set the "filterPath" string to empty.
It's not a problem for me to add a a new
I had no time to response quicker.
In your example (https://dzone.com/articles/pippo-and-jersey-jax-rs), you get your dependency from the ServletContext
With ServletModule (assuming you would have used Guice ) you might just inject it directly:
But your example is a different one, you use Pippo and add the Jersey Servlet additionally. My use case is, that I have an application with few servlets and want to add the PippoFilter.
Is there maybe a PippoServlet, so I can add it directly instead of the Filter (with the Filter, I have another problem, that if Pippo cannot find a routing, then it'll send a 404, but I would like to follow the filter chain instead ).
Thanks for your explanation.
The reason is because I don't use a DI library in that demo and I need to "share" the
I can take a look to see if I can do something in this direction. I use filters from inside (simple routes) of my application. If I need to add external filters I make it via
And by the way, related to approach described in http://www.pippo.ro/mod/guice.html. Maybe the code snippet and the explanation are not the best. For example, that section describe only how to use Guice in controllers. When I use plain routes approach (without controllers) with DI (Spring) in my application, I instantiate my Application class via DI and pass it to PippoServer(
Pippo is very flexible in my opinion and you can achieve a behavior on several ways.
Awesome, I have not seen PippoServlet. Actually, that is what I've been searching for. Just added these to my servlet-bindings and it works as expected:
I had to subclass PippoServlet, so I can inject the Application:
I saw that documentation, but it focuses on using Guice to Inject dependencies ( and not using Pippo as a dependency in an existing application ).
I am glad to see that your problem is resolved so easy
You are right.
If you encounter other problems, please let me know.