You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2017/07/13 07:06:24 UTC

[Bug 61289] New: NullPointerException in Response.generateCookieString()

https://bz.apache.org/bugzilla/show_bug.cgi?id=61289

            Bug ID: 61289
           Summary: NullPointerException in
                    Response.generateCookieString()
           Product: Tomcat 8
           Version: 8.5.16
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: matthias.keller@ergon.ch
  Target Milestone: ----

Sometimes (about every third try) we get a NullPointerException within the
connector when trying to write an empty, expired Cookie under Tomcat 8.5.13 and
8.5.16. This problem doesn't occur on Tomcat 7.0.77.

The stacktrace (from 8.5.13) is as follows:

org.apache.catalina.connector.Response.generateCookieString(Response.java:999)
org.apache.catalina.connector.Response.addCookie(Response.java:947)
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)

The code leading to it is:

Cookie c = new Cookie(cookieName, "");
c.setMaxAge(0);
cookie.setPath(contextPath);
response.addCookie(cookie);

We use the LegacyCookieProcessor via tomcat's context.xml:
<CookieProcessor className="org.apache.tomcat.util.http.LegacyCookieProcessor"
/>

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61289] NullPointerException in Response.generateCookieString()

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61289

--- Comment #1 from matthias.keller@ergon.ch ---
Here's the stacktrace of this problem from 8.5.16:

org.apache.catalina.connector.Response.generateCookieString(Response.java:1019)
org.apache.catalina.connector.Response.addCookie(Response.java:967)
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)
javax.servlet.http.HttpServletResponseWrapper.addCookie(HttpServletResponseWrapper.java:58)

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61289] NullPointerException in Response.generateCookieString()

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61289

Chuck Caldarale <ch...@unisys.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|REOPENED                    |RESOLVED

--- Comment #4 from Chuck Caldarale <ch...@unisys.com> ---
As Mark stated, the cause is almost always incorrect response object handling
in the application, and that this should be pursued on the Tomcat Users'
mailing list.  Bugzilla is not a support forum.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61289] NullPointerException in Response.generateCookieString()

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61289

hugo <hu...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #3 from hugo <hu...@gmail.com> ---
I got the same exception when I create a spring boot application, the version
of tomcat is 8.5.16.
I has debug it, and found that the getContext() method got a null, so the
exception occured.
My english is pool,all of you can the exceprion detail, as follow:
java.lang.NullPointerException: null
        at
org.apache.catalina.connector.Response.generateCookieString(Response.java:1019)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at org.apache.catalina.connector.Response.addCookie(Response.java:967)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.connector.ResponseFacade.addCookie(ResponseFacade.java:386)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at com.easyedm.common.utils.CookieUtil.addCookie(CookieUtil.java:37)
~[classes/:na]
        at com.easyedm.common.utils.CookieUtil.addCookie(CookieUtil.java:49)
~[classes/:na]
        at
com.easyedm.admin.service.impl.AdminInfoServiceImpl.userLoginRecord(AdminInfoServiceImpl.java:63)
~[classes/:na]
        at
com.easyedm.admin.service.impl.AdminInfoServiceImpl.login(AdminInfoServiceImpl.java:52)
~[classes/:na]
        at
com.easyedm.admin.controller.AdminInfoController.adminLogin(AdminInfoController.java:59)
~[classes/:na]
        at
com.easyedm.admin.controller.AdminInfoController$$FastClassBySpringCGLIB$$e2440cb5.invoke(<generated>)
~[classes/:na]
        at
org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
~[spring-aop-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
~[spring-aop-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)
~[spring-aop-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
~[spring-aop-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
~[spring-aop-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
~[spring-aop-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
~[spring-aop-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
com.easyedm.admin.controller.AdminInfoController$$EnhancerBySpringCGLIB$$242ca14c.adminLogin(<generated>)
~[classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_91]
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_91]
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_91]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91]
        at
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
~[spring-webmvc-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
~[tomcat-embed-websocket-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
~[spring-web-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
~[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[na:1.8.0_91]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[na:1.8.0_91]
        at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[tomcat-embed-core-8.5.16.jar:8.5.16]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61289] NullPointerException in Response.generateCookieString()

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61289

--- Comment #5 from matthias.keller@ergon.ch ---
For anyone stumbiling upon this issue later on, set the following system
property to make the cause much more visible. This led me to the correct
suspect immediately:

org.apache.catalina.connector.RECYCLE_FACADES=true

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 61289] NullPointerException in Response.generateCookieString()

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61289

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
It looks like the Context object is null which points to the application
accessing the response object outside of the normal request/response processing
cycle. This can happen when an application incorrectly retains a reference to a
response object.

The users list is the place to follow up on this. If that discussion concludes
that there is a Tomcat bug here, please feel free to re-open this issue and
provide the simplest possible test case that demonstrates the problem on a clea
install of the latest stable 8.5.x release.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org