cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "tomek778 (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-6472) Cannot create ContextResolver for class extending HttpServletRequest, HttpServletResponse, etc.
Date Wed, 24 Jun 2015 11:41:04 GMT

    [ https://issues.apache.org/jira/browse/CXF-6472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14599280#comment-14599280
] 

tomek778 commented on CXF-6472:
-------------------------------

stack from v.3.0.4:

Caused by: java.lang.ClassCastException
        at java.lang.Class.cast(Class.java:2990)
        at org.apache.cxf.jaxrs.utils.JAXRSUtils.createServletResourceValue(JAXRSUtils.java:1168)
        at org.apache.cxf.jaxrs.utils.JAXRSUtils.createContextValue(JAXRSUtils.java:1104)
        at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:836)
        at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:791)
        at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
        at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:77)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
        ... 41 more

I am trying to inject as a jax-rs mehtod param:
 @Context CustomHttpRequest //implements HttpServletRequest

but following condition is true (for method param clazz=CustomHttpRequest) :

    if (HttpServletRequest.class.isAssignableFrom(clazz)) {
            value = m.get(AbstractHTTPDestination.HTTP_REQUEST);
        }

thus same method fails on line: 
return clazz.cast(value)

I would expect createServletResourceValue() will return null for clazz = CustomHttpRequest
.


> 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)

Mime
View raw message