java - Jersey filter ContainerRequestContext with HttpServletRequest return nullpointer -
i injecting httpservletrequest
containerrequestfilter
. when trying use abort , getting nullppointerexception
.
@provider public class authorizationrequestfilter implements containerrequestfilter { @context httpservletrequest httprequest; @override public void filter(containerrequestcontext requestcontext ) throws ioexception { // string auth = requestcontext.getheaderstring("authorization"); uriinfo uriinfo = requestcontext.geturiinfo(); system.out.println(uriinfo.getpath()); //login request if (uriinfo.getpath().equals("resource/users/login")) { return ; } if (httprequest.isrequestedsessionidvalid()== true) { requestcontext.abortwith(response .status(response.status.unauthorized) .build()); }
stacktrace
:09:28 pm org.apache.catalina.core.standardwrappervalve invoke severe: servlet.service() servlet [appconfig] in context path [/vaad2] threw exception [java.lang.nullpointerexception] root cause java.lang.nullpointerexception @ filters.authorizationrequestfilter.filter(authorizationrequestfilter.java:77) @ org.glassfish.jersey.server.containerfilteringstage.apply(containerfilteringstage.java:131) @ org.glassfish.jersey.server.containerfilteringstage.apply(containerfilteringstage.java:67) @ org.glassfish.jersey.process.internal.stages.process(stages.java:197) @ org.glassfish.jersey.server.serverruntime$1.run(serverruntime.java:263) @ org.glassfish.jersey.internal.errors$1.call(errors.java:271) @ org.glassfish.jersey.internal.errors$1.call(errors.java:267) @ org.glassfish.jersey.internal.errors.process(errors.java:315) @ org.glassfish.jersey.internal.errors.process(errors.java:297) @ org.glassfish.jersey.internal.errors.process(errors.java:267) @ org.glassfish.jersey.process.internal.requestscope.runinscope(requestscope.java:297) @ org.glassfish.jersey.server.serverruntime.process(serverruntime.java:254) @ org.glassfish.jersey.server.applicationhandler.handle(applicationhandler.java:1030) @ org.glassfish.jersey.servlet.webcomponent.service(webcomponent.java:373) @ org.glassfish.jersey.servlet.servletcontainer.service(servletcontainer.java:381) @ org.glassfish.jersey.servlet.servletcontainer.service(servletcontainer.java:344) @ org.glassfish.jersey.servlet.servletcontainer.service(servletcontainer.java:221) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:505) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:957) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:423) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1079) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:620) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:318) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(unknown source)
Comments
Post a Comment