我为我的球衣应用程序添加了一个过滤器,但有时它会抛出空指针,如何修复它以及我做错了什么?
我的代码:
我收到错误:
严重:Servlet [Jersey Web Application]的Servlet.service()在路径[/spcsis-1.0]的上下文中引发异常[java.lang.NullPointerException]的根本原因 显示java.lang.NullPointerException at org.glassfish.jersey.server.spring.scope.RequestContextFilter $ 2.resetAttributes(RequestContextFilter.java:124) 在org.glassfish.jersey.server.spring.scope.RequestContextFilter.filter(RequestContextFilter.java:137) 在org.glassfish.jersey.server.ContainerFilteringStage $ ResponseFilterStage.apply(ContainerFilteringStage.java:196) 在org.glassfish.jersey.server.ContainerFilteringStage $ ResponseFilterStage.apply(ContainerFilteringStage.java:163) 在org.glassfish.jersey.process.internal.Stages.process(Stages.java:171) at org.glassfish.jersey.server.ServerRuntime $ Responder.processResponse(ServerRuntime.java:442) 在org.glassfish.jersey.server.ServerRuntime $ Responder.process(ServerRuntime.java:434) 在org.glassfish.jersey.server.ServerRuntime $ 2.run(ServerRuntime.java:329) 在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:317) 在org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) 在org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) 在org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473) 在org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427) 在org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388) 在org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341) 在org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228) 在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:169) 在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) 在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:316) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(Thread.java:745)