Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential ClassCastException in RequestContextListener when destroying the request object [SPR-11378] #16005

spring-projects-issues opened this issue Jan 31, 2014 · 1 comment


Copy link

@spring-projects-issues spring-projects-issues commented Jan 31, 2014

Vikram Hullukunte opened SPR-11378 and commented

In jersey-spring3, The org.glassfish.jersey.server.spring.scope.RequestContextFilter class creates JaxrsRequestAttributes datastructure and sets in the Threadlocal.

If an exception occurs in the calling chain of the jersey resource and the exception is not handled by jersey, then Spring's RequestContextListner bombs while destroying the threadlocal set as part of the request.

The exception:

SEVERE: Exception sending request initialized lifecycle event to listener instance of class org.springframework.web.context.request.RequestContextListener
java.lang.ClassCastException: org.glassfish.jersey.server.spring.scope.JaxrsRequestAttributes cannot be cast to org.springframework.web.context.request.ServletRequestAttributes
at org.springframework.web.context.request.RequestContextListener.requestDestroyed(
at org.apache.catalina.core.StandardContext.fireRequestDestroyEvent(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.valves.AccessLogValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.AbstractHttp11Processor.process(
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

Affects: 3.2.7, 4.0.1

Reference URL:

Backported to: 3.2.8

Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Feb 1, 2014

Juergen Hoeller commented

Good catch! We're defensively handling our RequestAttributes type expectation in the requestDestroyed callback now, performing the unbinding in any case but only invoking ServletRequestAttributes methods if actually applicable.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants