-
-
Notifications
You must be signed in to change notification settings - Fork 127
Closed
Description
I would like to use Pippo with Guice, but not the way described here: http://www.pippo.ro/mod/guice.html
Instead I use the GuiceServlet, Gucie allows to configure all the filters and servlets without the need for web.xm ( expect for GuiceFilter), as described here: https://github.com/google/guice/wiki/ServletModule
I use the ServletModule from Guice and try to add the PippoFilter like this:
filter("/*").through(GuicePippoFilter.class);
bind(GuicePippoFilter.class).in(Scopes.SINGLETON);
Unfortunately I get the following exception:
java.lang.NullPointerException: null
at ro.pippo.core.PippoFilter.initFilterPathFromWebXml(PippoFilter.java:216) ~[pippo-core-1.4.0.jar:na]
at ro.pippo.core.PippoFilter.initFilterPath(PippoFilter.java:195) ~[pippo-core-1.4.0.jar:na]
at ro.pippo.core.PippoFilter.init(PippoFilter.java:96) ~[pippo-core-1.4.0.jar:na]
at io.kiru.GuicePippoFilter.init(GuicePippoFilter.java:37) [main/:na]
at com.google.inject.servlet.FilterDefinition.init(FilterDefinition.java:114) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ManagedFilterPipeline.initPipeline(ManagedFilterPipeline.java:98) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.GuiceFilter.init(GuiceFilter.java:172) [guice-servlet-3.0.jar:na]
at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:138) [jetty-servlet-9.2.5.v20141112.jar:9.2.5.v20141112]
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:852) [jetty-servlet-9.2.5.v20141112.jar:9.2.5.v20141112]
... skipped
GuiceFilter looks like this:
public class GuicePippoFilter extends PippoFilter{
@Inject
public GuicePippoFilter(MyApplication myApplication) {
setApplication(myApplication);
/*
// This workaround works for now
Object cc = this;
try {
Field f1 = cc.getClass().getSuperclass().getDeclaredField("filterPath");
f1.setAccessible(true);
f1.set(cc, "");
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
*/
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
super.init(filterConfig);
}
}
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.
Is it possible to fix this properly? Maybe add a protected setter for filterPath so I can set it from the outside.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels