Null reference exception on custom filter implementation
tekbird opened this issue · comments
I had to use a filter before the requestDispatcher filter of activeweb. The purpose of my filter was to turn off session using the following wrapper class:
chain.doFilter(new HttpServletRequestWrapper((HttpServletRequest) req) {
@Override
public HttpSession getSession() {
return null;
}
@Override
public HttpSession getSession(boolean create) {
return null;
}
}, res);
This works as expected, except that the standard output prints a long stacktrace:
java.lang.NullPointerException at deployment.mvc.jlite.test.war//org.javalite.activeweb.SessionHelper.getSessionAttributes(SessionHelper.java:40) at deployment.mvc.jlite.test.war//org.javalite.activeweb.ParamCopy.copySessionAttrsInto(ParamCopy.java:63) at deployment.mvc.jlite.test.war//org.javalite.activeweb.ParamCopy.copyInto(ParamCopy.java:41) at deployment.mvc.jlite.test.war//org.javalite.activeweb.ControllerRunner.renderResponse(ControllerRunner.java:141) at deployment.mvc.jlite.test.war//org.javalite.activeweb.ControllerRunner.run(ControllerRunner.java:74) at deployment.mvc.jlite.test.war//org.javalite.activeweb.RequestDispatcher.doFilter(RequestDispatcher.java:213) at io.undertow.servlet@2.0.13.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet@2.0.13.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at deployment.mvc.jlite.test.war//app.config.SessionKiller.doFilter(SessionKiller.java:27)
what are you trying to do? Looks like you are interfering with the container?
I was trying to get rid of the JSESSIONID cookie. I guess I solved the issue by returning a dummy implementation for HttpSession.
best to do this at the container level.