Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EB235200B7E for ; Tue, 6 Sep 2016 18:46:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E9BE0160ACB; Tue, 6 Sep 2016 16:46:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3BC46160AA9 for ; Tue, 6 Sep 2016 18:46:45 +0200 (CEST) Received: (qmail 55304 invoked by uid 500); 6 Sep 2016 16:46:44 -0000 Mailing-List: contact users-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@felix.apache.org Delivered-To: mailing list users@felix.apache.org Received: (qmail 55288 invoked by uid 99); 6 Sep 2016 16:46:44 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 16:46:44 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id A0468CD6D8 for ; Tue, 6 Sep 2016 16:46:43 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.055 X-Spam-Level: X-Spam-Status: No, score=0.055 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.124, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id M9fcgZXGCYDn for ; Tue, 6 Sep 2016 16:46:40 +0000 (UTC) Received: from nm16.bullet.mail.bf1.yahoo.com (nm16.bullet.mail.bf1.yahoo.com [98.139.212.175]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 2DD435FBD4 for ; Tue, 6 Sep 2016 16:46:40 +0000 (UTC) Received: from [98.139.215.142] by nm16.bullet.mail.bf1.yahoo.com with NNFMP; 06 Sep 2016 16:46:39 -0000 Received: from [98.139.212.219] by tm13.bullet.mail.bf1.yahoo.com with NNFMP; 06 Sep 2016 16:46:39 -0000 Received: from [127.0.0.1] by omp1028.mail.bf1.yahoo.com with NNFMP; 06 Sep 2016 16:46:39 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 241288.49444.bm@omp1028.mail.bf1.yahoo.com X-YMail-OSG: Afp3Rn4VM1mjOAU5WpTSj4fz9gG2idVSlYg766ZXBaQSSVDdrYr0J8BkxgESM9d 8fZ2cEnfP6HDvnf_cBlHG88Ipw3tfOT4DmoQnFjjA9TcZQHY6A7FgaieMQX2ggLUE1qtyaKGipKu gR3Xi3enNRd8rGpDxXyFfb9L3SLpe7w3caUTb1ZjrXE8pIjmL0ZkFiZ8CgLvfUhjOFnCxiVMlr3D cQlTmMaGUfqb_ouSzSQdvEB0AidCykozb1hNVmoSrdot3nZBm2pe2fjUMruEIqEd6X0TJYoBDyu8 qfQRBZ4RIAxsYqFQgGXSWv5mw8vxDP4bkNpD9DihHYxEu_jLUr_OMdpLKjTAgNCvKaFtOPjdsFLS OlvKWPSojOIraIjaaYw5HzpxCHJVvS2Zb4TTPNSbv6nBgVbYAXBeV62U4akSdgsGfZRb.qsjWuty wPhpAAXYMZCGKFfp8ELbS8xQHhtVeD1Leg2hEdDEjHn0mXg4nMdjk2QlXMexIHOZ5NCf5GWKn5cA xglOSXNFg9NdEQKAtrghxddpB8QPw.rcVbyhMjmGnes274i4GiXcEoXU_ Received: from jws106245.mail.bf2.yahoo.com by sendmailws134.mail.bf1.yahoo.com; Tue, 06 Sep 2016 16:46:38 +0000; 1473180398.841 Date: Tue, 6 Sep 2016 16:46:38 +0000 (UTC) From: Alessandro Gherardi Reply-To: Alessandro Gherardi To: "users@felix.apache.org" Message-ID: <1994305923.456116.1473180398505@mail.yahoo.com> Subject: Issues with embedded Felix framework and JAXRS MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_456115_1412896026.1473180398500" References: <1994305923.456116.1473180398505.ref@mail.yahoo.com> archived-at: Tue, 06 Sep 2016 16:46:46 -0000 ------=_Part_456115_1412896026.1473180398500 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi,I have a non-OSGi Java app that loads=C2=A0an OSGi bundle=C2=A0by embedd= ing Felix. The bundle exposes its functionality as an OSGi service. The app= accesses the service via a service tracker.=C2=A0The app uses the org.osgi= .framework.system.packages.extra option so that the service interface and t= he classes=C2=A0that the interfaces=C2=A0refers to are all loaded by the sa= me classloader in both the app and the bundle. The bundle uses Jersey 2.X and the app uses Jersey 1.17. When the app calls= the bundle via the service, the Jersey 2.X code throws the following excep= tion: Exception in thread "main" java.lang.LinkageError: ClassCastException: atte= mpting to castfile:/C:/XXX/bin/javax/ws/rs/ext/RuntimeDelegate.class to bun= dle://59.1:1/javax/ws/rs/ext/RuntimeDelegate.classat javax.ws.rs.ext.Runtim= eDelegate.findDelegate(RuntimeDelegate.java:146) at javax.ws.rs.ext.Runtime= Delegate.getInstance(RuntimeDelegate.java:120) at javax.ws.rs.core.UriBuild= er.newInstance(UriBuilder.java:95)... Looking at the Jersey source code, it appears that RuntimeDelegate tries to= load a concrete subclass via javax.ws.rs.ext.FactoryFinder. FactoryFinder = reads the name of the subclass from file META-INF/services/javax.ws.rs.ext.= RuntimeDelegate, and it loads that file via the calling threads's context c= lass loader. Since the calling thread is an application's thread, its class= loader is the application's class loader, so META-INF/services/javax.ws.rs= .ext.RuntimeDelegate points to a Jersey 1.17 class. I can kind-of workaround the problem by setting=C2=A0the application thread= to an "empty" class loader before calling the service - i.e.: ClassLoader saveCL =3D Thread.currentThread().getContextClassLoader(); ClassLoader myCL =3D new URLClassLoader(new URL[0], saveCL.getParent()); try { =C2=A0 Thread.currentThread().setContextClassLoader(myCL); =C2=A0 call OSGi service } finally { =C2=A0 Thrad.currentThread().setContextClassloader(saveCL); } However, I'm surprised I have to do that. Shouldn't the framework take care= of this - even if the service caller is the embedded application rather th= an another OSGi bundle? Notice: This issue may or may not be related to=C2=A0 commons-logging and A= xis problems Thank you in advance,Alessandro =20 | =20 | =20 | =20 | | | | | | =20 | | =20 commons-logging and Axis problems | | | | =20 ------=_Part_456115_1412896026.1473180398500--