Skip to content

ServletWebRequest.checkNotModified attempts to call HttpServletResponse.getStatus() on Servlet 2.5 [SPR-13396] #17976

Closed

Description

@spring-projects-issues

Eric Burns opened SPR-13396 and commented

Using the following:

  • Java 6
  • WebSphere 7.0.0.31 - Servlet 2.5
  • Spring 4.2.0.RELEASE
  • Spring Security 3.2.7.RELEASE

getStatus is being called from the checkNotModified functions in the ServletWebRequest class, specificially ServletWebRequest.java (line 176):

public boolean checkNotModified(String etag, long lastModifiedTimestamp) {
		HttpServletResponse response = getResponse();
		if (StringUtils.hasLength(etag) && !this.notModified) {
			if (response == null || HttpStatus.valueOf(response.getStatus()).is2xxSuccessful()) {
				etag = addEtagPadding(etag);
				this.notModified = isETagNotModified(etag) && isTimestampNotModified(lastModifiedTimestamp);
				if (response != null) {
					if (this.notModified && supportsNotModifiedStatus()) {
						response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
					}
					if(response.getHeader(HEADER_ETAG) == null) {
						response.setHeader(HEADER_ETAG, etag);
					}
					if(response.getHeader(HEADER_LAST_MODIFIED) == null) {
						response.setDateHeader(HEADER_LAST_MODIFIED, lastModifiedTimestamp);
					}
				}
			}
		}
		return this.notModified;

Stacktrace:

[8/25/15 15:21:21:005 CDT] 0000001e webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[carepathui]: java.lang.NoSuchMethodError: javax/servlet/http/HttpServletResponse.getStatus()I
	at org.springframework.web.context.request.ServletWebRequest.checkNotModified(ServletWebRequest.java:176)
	at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:241)
	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1602)
	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:149)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:125)
	at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:80)
	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:908)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:507)
	at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3954)
	at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945)
	at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306)
	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
	at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
	at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
	at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
	at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1660)

Affects: 4.2 GA

Issue Links:

Referenced from: commits 803d7b5

Activity

  1. spring-projects-issues commented on Aug 27, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Interestingly, we only have one other place where we're currently calling getStatus(), namely in FrameworkServlet.publishRequestHandledEvent. We have a reflective responseGetStatusAvailable guard there; I guess we need the same in ServletWebRequest, providing reasonable default assumptions when we can't check the actual status on Servlet 2.5.

    Juergen

  2. spring-projects-issues commented on Sep 2, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Jean Detoeuf commented

    It seems that getHeader(String) is also being called inside checkNotModified. This method is not in HttpServletResponse in Servlet 2.5. Here is the stacktrace I'm facing. Issue was introduced in 4.2.0 as we were previously in 4.1.7.

    Using the following:

    Java 7.0_11
    Jonas 5.2.4 - Servlet 2.5
    Spring 4.1.7.RELEASE
    
    [ERROR] 2015-09-02 11:04:12,663 [TP-Processor15]  org.apache.juli.logging.DirectJDKLog:167 - Servlet.service() for servlet appServlet threw exception
    java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getHeader(Ljava/lang/String;)Ljava/lang/String;
            at org.springframework.web.context.request.ServletWebRequest.checkNotModified(ServletWebRequest.java:187) ~[spring-web-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.servlet.resource.ResourceHttpRequestHandler.handleRequest(ResourceHttpRequestHandler.java:240) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) ~[javaee-api-5.2.4.jar:5.2.4]
            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) ~[javaee-api-5.2.4.jar:5.2.4]
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) ~[jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) ~[jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.ow2.jonas.web.tomcat6.CheckOpenResourcesValve.invoke(CheckOpenResourcesValve.java:73) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.ow2.jonas.web.tomcat6.tx.TransactionValve.invoke(TransactionValve.java:90) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.ow2.jonas.web.tomcat6.ResetAuthenticationValve.invoke(ResetAuthenticationValve.java:95) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:776) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:705) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:898) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) [jonas-web-container-tomcat-6.0-5.2.4-ipojo.jar:5.2.4]
            at java.lang.Thread.run(Thread.java:722) [na:1.7.0_11]

    As of today, we're not able to switch to a servlet 3.0 compatible application server.

  3. spring-projects-issues commented on Sep 2, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Jean Detoeuf commented

    Previous stacktrace was generated when upgrading to Spring 4.2.1.

  4. spring-projects-issues commented on Sep 2, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Jean Detoeuf, could you please create a follow-up JIRA issue for that one? We'll guard those remaining calls for 4.2.2.

    Juergen

  5. spring-projects-issues commented on Sep 2, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Jean Detoeuf commented

    Follow up was created here

  6. added
    type: bug
    in: web
    on Jan 11, 2019
  7. added this to the 4.2.1 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions