Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A699617D23 for ; Fri, 9 Jan 2015 07:45:33 +0000 (UTC) Received: (qmail 49952 invoked by uid 500); 9 Jan 2015 07:45:35 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 49901 invoked by uid 500); 9 Jan 2015 07:45:35 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 49717 invoked by uid 99); 9 Jan 2015 07:45:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Jan 2015 07:45:34 +0000 Date: Fri, 9 Jan 2015 07:45:34 +0000 (UTC) From: =?utf-8?Q?Zden=C4=9Bk_Obst_=28JIRA=29?= To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CXF-6190) HttpServletRequest injection via Context in setter MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-6190?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:all-tabpanel ] Zden=C4=9Bk Obst updated CXF-6190: ----------------------------- Description:=20 I'm trying to inject HttpServletRequest to my JAX-RS resource via @Context = annotation. It works fine if I inject it via method parameter. But I don't = want to "mess" my interfaces with that so I'd like to inject it via setter. I use this simple method (I'm using Kotlin but I the issue should be the sa= me for Java): {code:java} var req : HttpServletRequest? =3D null Context fun setRequest(req : HttpServletRequest) { this.req =3D req } {code} The thing is, that the setter is called via reflection in org.apache.cxf.ja= xrs.utils.InjectionUtils in method injectThroughMethod. The method name is = correct but as parameter value is instance of ThreadLocalHttpServletRequest= which clearly is not HttpServletRequest (it is not inherited class) so thi= s gets thrown:=20 java.lang.IllegalArgumentException: object is not an instance of declaring = class was: I'm trying to inject HttpServletRequest to my JAX-RS resource via @Context = annotation. It works fine if I inject it via method parameter. But I don't = want to "mess" my interfaces with that so I'd like to inject it via setter. I use this simple method (I'm using Kotlin but I the issue should be the sa= me for Java): var req : HttpServletRequest? =3D null Context fun setRequest(req : HttpServletRequest) { this.req =3D req } The thing is, that the setter is called via reflection in org.apache.cxf.ja= xrs.utils.InjectionUtils in method injectThroughMethod. The method name is = correct but as parameter value is instance of ThreadLocalHttpServletRequest= which clearly is not HttpServletRequest (it is not inherited class) so thi= s gets thrown:=20 java.lang.IllegalArgumentException: object is not an instance of declaring = class > HttpServletRequest injection via Context in setter > -------------------------------------------------- > > Key: CXF-6190 > URL: https://issues.apache.org/jira/browse/CXF-6190 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 3.0.3 > Reporter: Zden=C4=9Bk Obst > > I'm trying to inject HttpServletRequest to my JAX-RS resource via @Contex= t annotation. It works fine if I inject it via method parameter. But I don'= t want to "mess" my interfaces with that so I'd like to inject it via sette= r. > I use this simple method (I'm using Kotlin but I the issue should be the = same for Java): > {code:java} > var req : HttpServletRequest? =3D null > Context > fun setRequest(req : HttpServletRequest) { > this.req =3D req > } > {code} > The thing is, that the setter is called via reflection in org.apache.cxf.= jaxrs.utils.InjectionUtils in method injectThroughMethod. The method name i= s correct but as parameter value is instance of ThreadLocalHttpServletReque= st which clearly is not HttpServletRequest (it is not inherited class) so t= his gets thrown:=20 > java.lang.IllegalArgumentException: object is not an instance of declarin= g class -- This message was sent by Atlassian JIRA (v6.3.4#6332)