[
https://issues.apache.org/jira/browse/CXF-6472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14608078#comment-14608078
]
Sergey Beryozkin commented on CXF-6472:
---------------------------------------
I've initiated a conversation which you can trace at the JAX-RS users, however,
while I agree it is somewhat unfortunate, I'm thinking it is unlikely there
will be support for ContextResolver interface (given its method signature and
the reference to Produces) acting as a generic context resolver as opposed to a
typical case of ContextResolver<JAXBContext> providing JAXBContext instances
for custom classes like Book. So in the short term one needs to continue
depending on the framework specific mechansim; I'll reopen this issue
otherwise. The actual class cast exception has been fixed
> Cannot create ContextResolver for class extending HttpServletRequest,
> HttpServletResponse, etc.
> -----------------------------------------------------------------------------------------------
>
> Key: CXF-6472
> URL: https://issues.apache.org/jira/browse/CXF-6472
> Project: CXF
> Issue Type: Bug
> Affects Versions: 3.0.4, 3.1.1
> Environment: all
> Reporter: tomek778
>
> I tried to wrap HttpServletRequest by using ContextProvider, lets assume such
> a simple implementation:
> @Provider
> public class CustomHttpRequestContextResolver implements
> ContextResolver<CustomHttpRequest> {
> @Context
> private HttpServletRequest request;
> public CustomHttpRequest getContext(Class<?> type) {
> return new CustomHttpRequest(request);
> }
> }
> However, before calling context provider CXF first calls
> JAXRSUtils.createServletResourceValue() method that tries to cast
> HttpServletRequest into my wrapped request and it fails with
> ClassCastException.
> I havent found in JAX_RS spec anything telling that such a ContextResolver is
> forbidden.This works also with Apache Wink.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)