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 05D68200CC1 for ; Mon, 10 Jul 2017 09:07:31 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 04395168447; Mon, 10 Jul 2017 07:07:31 +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 C9D01168400 for ; Mon, 10 Jul 2017 09:07:29 +0200 (CEST) Received: (qmail 10125 invoked by uid 500); 10 Jul 2017 07:07:28 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 10113 invoked by uid 99); 10 Jul 2017 07:07:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jul 2017 07:07:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 03AF0191784 for ; Mon, 10 Jul 2017 07:07:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.321 X-Spam-Level: X-Spam-Status: No, score=-0.321 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id viaezVvk4fb7 for ; Mon, 10 Jul 2017 07:07:24 +0000 (UTC) Received: from mail-qt0-f182.google.com (mail-qt0-f182.google.com [209.85.216.182]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id C5115626D1 for ; Mon, 10 Jul 2017 07:07:23 +0000 (UTC) Received: by mail-qt0-f182.google.com with SMTP id i2so65407929qta.3 for ; Mon, 10 Jul 2017 00:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-transfer-encoding; bh=0HpOvenQafUdxNvfLeWvC4dtowQdZdEDE5bNfel0Qns=; b=GZO5zRBZusbfmRhHimo+cleL9jf078nOL5NMO7XUBbb9Oirk3Pdsmedny6FTQzmOAB mfKtUnt1FqyMRquAJdrjtJFtaxu2QiVyxPnNlMCUGeCXOn4RCEFY+fg8SWWUdsGR28Ha y5jWZZDTa/rCjjOtKug8e2ZpBWYY89E9nhZtbDB57eyNa5VYP6jsSvqS9jjCVReOSRFU 68JpcWAT2sLXc5Gxe4gjwzyiUsKwH8sRNszqLYvy6Jrlk1veee3cZPf9fv/v/ooIDiwf bkBFvq/QyzPY8M55s/1Jz6rte5tnJJGdbHXzm0y542ptoPPg4u0EOJENtl9VIo/KyjNv 8X6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-transfer-encoding; bh=0HpOvenQafUdxNvfLeWvC4dtowQdZdEDE5bNfel0Qns=; b=MR1E5FqUfEbGiYWyjJRD7/JBNh1XkRmGkkLKOA7lNlo30s3kV/EqiE0LmpPuCu9lTl Nt6OZtu8WYkvxrqcux9A46ltSa6W2zRih+/1PP1pFrybmNNOw89UH15vZgAVbkoLTkAv 1VGaXWt2FyQMFohJiWHg9qPaBNSJ0pSZHBejt80BQ5CbaFHTm//QP8u02qBqBl/RipE/ /HkGiGqXQsV76qO6PETfgXRFb8yE7LQ0uUbsKLOBHfFAcjO4OepENntcBBvuxppOKXeL hl/YTK5oASdKb/YaWUpSKhinmP6koT/zVG87XRxwiATp9M8tqyovxeUo62DvESqlDUvW D8tg== X-Gm-Message-State: AIVw112B+UQu0R0uaq7Yaj+Tc4cWlAUgG4hMClNIHn7q6s6ZvhRChy+b yxJSSxEPMNSAsv9KFJglRLOG/0tgKg7g X-Received: by 10.200.4.140 with SMTP id s12mr2352502qtg.35.1499670443088; Mon, 10 Jul 2017 00:07:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.63.197 with HTTP; Mon, 10 Jul 2017 00:07:02 -0700 (PDT) In-Reply-To: <1FE2DD72EED64546B2B37C1BF1726E1F34916764@KEDMBX01.desqld.internal> References: <1FE2DD72EED64546B2B37C1BF1726E1F3491533A@KEDMBX01.desqld.internal> <1FE2DD72EED64546B2B37C1BF1726E1F34916361@KEDMBX01.desqld.internal> <1FE2DD72EED64546B2B37C1BF1726E1F34916764@KEDMBX01.desqld.internal> From: Claus Ibsen Date: Mon, 10 Jul 2017 09:07:02 +0200 Message-ID: Subject: Re: camel route to remote EJB using karaf blueprint To: "users@camel.apache.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable archived-at: Mon, 10 Jul 2017 07:07:31 -0000 You can try from camelContext there is a getApplicationContextClassLoader method you can try using. On Mon, Jul 10, 2017 at 1:37 AM, Matthew Shaw wrote: > Thanks Claus, I can't change the source system, so I have to consume the = ejb from osgi unfortunately. In the scenario below, I do have it working, p= artially, as you say, I'm now battling classloader issues. Trawling the pos= ts I have read about setting the Thread.currentThread().setClassContextLoad= er() to the bundle context, but that does nothing to help me. > > Would I be correct in assuming that because I am loading the camel contex= t via a blueprint and apache aries that I would need to get a hold of that = classloader? I think my manifest looks pretty good below as I'm referencing= all the weblogic client stuff correctly through my imports. > > -----Original Message----- > From: Claus Ibsen [mailto:claus.ibsen@gmail.com] > Sent: Sunday, 9 July 2017 5:26 PM > To: users@camel.apache.org > Subject: Re: camel route to remote EJB using karaf blueprint > > Hi > > I think you are going on a path where nobody really goes - calling remote= EJBs (... from OSGi). > Then classloading is much more problematic to setup. You would need to in= stall the WebLogic EJB client and also make sure to have all the right pack= age imports in your application bundle etc. > > I really don't recommend using remote EJB calls, you end up with a tight = coupling on Java, Java serialization etc. Are you not able to use another p= rotocol in the communication to WebLogic? > > If you really must, then try first to get a non OSGi example / unit test = etc up and running so you at least know that this part works. > Then its "fighting" the OSGi classloading and get all that sorted. > > > > On Fri, Jul 7, 2017 at 3:51 AM, Matthew Shaw wrote: >> As an addendum, I think the issue maybe that using jndi and the weblogic= initial context is outside the camel context, but the way I am invoking it= . Which in turn, will be trying to load the same classes required again, th= rough a completely separate class loader? >> >> -----Original Message----- >> From: Matthew Shaw [mailto:Matthew.Shaw@ambulance.qld.gov.au] >> Sent: Friday, 7 July 2017 11:07 AM >> To: users@camel.apache.org >> Subject: camel route to remote EJB using karaf blueprint >> >> Hi All, >> >> I've been banging my head against the wall now for a week, trying to get= a camel route going which consumes a remote service on an EJB2 container i= n weblogic 10.3. I keep getting class versioning issues between my client a= nd the server.I have the exact same versions of the server jars in karaf as= bundles and I import them through my manifest. My bundle installs ok into= karaf with a state of "Active" and the camel routes start up. I'm a newbie= in the osgi, camel world. >> >> I'm running camel 2.19.1 in apache karaf 4.1.1. >> >> My blueprint looks like this: >> >> > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" >> xmlns:cm=3D"http://aries.apache.org/blueprint/xmlns/blueprint= -cm/v1.0.0" >> xmlns:jaxws=3D"http://cxf.apache.org/blueprint/jaxws" >> xmlns:cxf=3D"http://cxf.apache.org/blueprint/core" >> xmlns:camel=3D"http://camel.apache.org/schema/blueprint" >> xmlns:camelcxf=3D"http://camel.apache.org/schema/blueprint/cx= f" >> xsi:schemaLocation=3D" >> http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi= .org/xmlns/blueprint/v1.0.0/blueprint.xsd >> http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org= /schemas/blueprint/jaxws.xsd >> http://cxf.apache.org/blueprint/core http://cxf.apache.org/= schemas/blueprint/core.xsd >> "> >> >> > class=3D"au.gov.qld.ambulance.services.legacywrapper.eTimesheetMediation >> "/> >> >> > class=3D"au.gov.qld.ambulance.services.legacywrapper.eTimesheetEJB2Bean" >> /> >> >> >> >> >> >> >> >> My manifest is as follows: >> >> Manifest-Version: 1.0 >> Bnd-LastModified: 1499385820689 >> Build-Jdk: 1.8.0_131 >> Built-By: mshaw >> Bundle-Blueprint: OSGI-INF/blueprint/camel-context.xml >> Bundle-ManifestVersion: 2 >> Bundle-Name: legacywrapper >> Bundle-SymbolicName: au.gov.qld.ambulance.tams.legacywrapper >> Bundle-Version: 0.0.1.SNAPSHOT >> Created-By: Apache Maven Bundle Plugin >> Export-Package: >> au.gov.qld.ambulance.services.legacywrapper;uses:=3D"au.go >> v.qld.des.aftimesheet.dto,javax.naming,org.apache.camel.builder";versi >> o >> n=3D"0.0.1",au.gov.qld.ambulance.services.legacywrapper.domain;uses:=3D"= ja >> v ax.xml.bind,javax.xml.bind.annotation";version=3D"0.0.1" >> Import-Package: >> au.gov.qld.des.aftimesheet.dto;version=3D"0.0.0",au.gov.ql >> d.des.aftimesheet.ejb;version=3D"0.0.0",au.gov.qld.des.aftimesheet.excep >> t >> ion;version=3D"0.0.0",com.fasterxml.jackson.annotation;version=3D"[2.8,3= )" >> , >> com.fasterxml.jackson.databind;version=3D"[2.8,3)",javax.ejb,javax.namin >> g >> ,javax.rmi,javax.xml.bind,javax.xml.bind.annotation,javax.xml.namespac >> e >> ,org.apache.camel;version=3D"[2.19,3)",org.apache.camel.builder;version= =3D" >> [2.19,3)",org.apache.camel.model;version=3D"[2.19,3)",org.apache.camel.m >> o >> del.rest;version=3D"[2.19,3)",org.osgi.service.blueprint;version=3D"[1.0= .0 >> , >> 2.0.0)",org.restlet.data,org.slf4j;version=3D"[1.7,2)",au.gov.qld.des.af >> t >> imesheet.officer.dto;version=3D"0.0.0",weblogic.jndi,javax.rmi.CORBA,org= . >> omg.CORBA,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.CORBA_2_3.p >> o >> rtable >> Require-Capability: osgi.ee;filter:=3D"(&(osgi.ee=3DJavaSE)(version=3D1.= 8))" >> Tool: Bnd-3.3.0.201609221906 >> >> My route builder impl class: >> >> >> public class eTimesheetMediation extends RouteBuilder { >> >> Logger logger =3D >> LoggerFactory.getLogger(eTimesheetMediation.class); >> >> @BeanInject("eTimesheetEJB2Bean") >> eTimesheetEJB2Bean eTimesheetEJB2Bean; >> >> @Override >> public void configure() throws Exception { >> >> >> restConfiguration().component("restlet").host("localhost").port(8095). >> bindingMode(RestBindingMode.json); >> >> rest("/services/legacywrapper/etimesheet") >> .post() >> .consumes(MediaType.APPLICATION_JSON.getName()) >> .type(ETimesheetRequest.class) >> .to("direct:extractTimesheetId"); >> >> from("direct:extractTimesheetId") >> .process(new Processor() { >> @Override >> public void process(Exchange exchange) throws Except= ion { >> ETimesheetRequest eTimesheetRequest =3D exchange= .getIn().getBody(ETimesheetRequest.class); >> exchange.getIn().setBody(eTimesheetRequest.getTi= mesheetId()); >> } >> }) >> .to("direct:etimesheetGet"); >> >> >> from("direct:etimesheetGet") >> .doTry() >> .bean(eTimesheetEJB2Bean, "mediate") >> .log(LoggingLevel.INFO,"Timesheet successfully trans= formed") >> .convertBodyTo(String.class, "UTF-8") >> .doCatch(Exception.class) >> .log(LoggingLevel.ERROR ,exceptionMessage().toString= ()) >> .throwException(new RuntimeException(exceptionMessag= e().toString())) >> .endDoTry(); >> >> >> } >> } >> >> >> My ejb client code / bean: >> >> >> public class eTimesheetEJB2Bean { >> >> public String mediate(Integer eTimesheetId) { >> >> Hashtable env =3D new Hashtable(); >> env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitia= lContextFactory"); >> env.put(Context.PROVIDER_URL, "t3://poldesaps02:5013"); >> env.put(Context.SECURITY_PRINCIPAL, "testuser4"); >> env.put(Context.SECURITY_CREDENTIALS, "passw0rd"); >> >> Context ic =3D null; >> >> try { >> ic =3D new InitialContext(env); >> }catch (NamingException e) { >> throw new RuntimeException(e); >> } >> >> return marshallTimesheetToJSON(ic ,getTimesheet(ic, >> eTimesheetId)); >> >> } >> >> >> >> public TimesheetTransferObject getTimesheet (Context ic, Integer eTi= mesheetId) { >> Object homeObject =3D null; >> >> try { >> homeObject =3D ic.lookup(TimesheetSessionFacadeHome.JNDI_NAM= E); >> } catch (NamingException e) { >> throw new RuntimeException(e); >> } >> >> TimesheetSessionFacadeHome home =3D (TimesheetSessionFacadeHome) >> PortableRemoteObject.narrow(homeObject, >> TimesheetSessionFacadeHome.class); >> >> TimesheetSessionFacade remote =3D null; >> try { >> remote =3D (TimesheetSessionFacade) PortableRemoteObject.nar= row(home.create(), TimesheetSessionFacade.class); >> TimesheetTransferObject result =3D remote.getTimesheet(eTime= sheetId); >> // TimesheetTransferObject result =3D new TimesheetTransferOb= ject(); >> >> return result; >> } catch (ClassCastException e) { >> throw new RuntimeException(e); >> } catch (RemoteException e) { >> throw new RuntimeException(e); >> } catch (CreateException e) { >> throw new RuntimeException(e); >> }catch (AFTimesheetException e) { >> throw new RuntimeException(e); >> } >> } >> >> private String marshallTimesheet (Context ic, >> TimesheetTransferObject timesheet) { >> >> String xml =3D ""; >> ByteArrayOutputStream baos =3D new ByteArrayOutputStream(); >> >> try { >> JAXBContext jc =3D JAXBContext.newInstance(String.class, Tim= esheetTransferObject.class); >> JAXBIntrospector introspector =3D jc.createJAXBIntrospector(= ); >> Marshaller marshaller =3D jc.createMarshaller(); >> marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); >> marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, tru= e); >> if (null =3D=3D introspector.getElementName(timesheet)) { >> JAXBElement jaxbElement =3D new JAXBElement(new >> QName("http://services.ambulance.qld.gov.au/data/services/corporate/hr >> i/timeandattendance", "Timesheet", "ta"), timesheet.getClass(), >> timesheet); >> >> marshaller.marshal(jaxbElement, baos); >> } else { >> marshaller.marshal(timesheet, baos); >> } >> xml +=3D baos.toString(); >> } catch (JAXBException e) { >> throw new RuntimeException(e); >> } >> return xml; >> } >> >> private String marshallTimesheetToJSON (Context ic, >> TimesheetTransferObject timesheet) { >> >> try { >> ObjectMapper objectMapper =3D new ObjectMapper(); >> objectMapper.setSerializationInclusion(JsonInclude.Include.N= ON_NULL); >> objectMapper.addMixIn(MealBrokenTransferObject.class, MealBr= okenTransferObjectMixIn.class); >> objectMapper.addMixIn(ShiftTransferObject.class, ShiftTransf= erObjectMixIn.class); >> objectMapper.addMixIn(TimesheetTransferObject.class, Timeshe= etTransferObjectMixIn.class); >> objectMapper.addMixIn(CallOutTransferObject.class, CalloutTr= ansferObjectMixIn.class); >> objectMapper.addMixIn(CallOutCaseTransferObject.class, CallO= utCaseTransferObjectMixIn.class); >> objectMapper.addMixIn(AllowanceTransferObject.class, Allowan= ceTransferObjectMixIn.class); >> return objectMapper.writeValueAsString(timesheet); >> } catch (Exception e) { >> throw new RuntimeException(e); >> } >> >> } >> >> } >> >> >> Any help / insight would be really appreciated. >> >> Cheers, >> Matt. >> >> >> >> >> >> This email, including any attachments sent with it, is confidential and = for the sole use of the intended recipient(s). This confidentiality is not = waived or lost, if you receive it and you are not the intended recipient(s)= , or if it is transmitted/received in error. >> >> Any unauthorised use, alteration, disclosure, distribution or review of = this email is strictly prohibited. The information contained in this email,= including any attachment sent with it, may be subject to a statutory duty = of confidentiality if it relates to health service matters. >> >> If you are not the intended recipient(s), or if you have received this e= mail in error, you are asked to immediately notify the sender. You should a= lso delete this email, and any copies, from your computer system network an= d destroy any hard copies produced. >> >> If not an intended recipient of this email, you must not copy, distribut= e or take any action(s) that relies on it; any form of disclosure, modifica= tion, distribution and/or publication of this email is also prohibited. >> >> Although the Queensland Ambulance Service takes all reasonable steps to = ensure this email does not contain malicious software, the Queensland Ambul= ance Service does not accept responsibility for the consequences if any per= son's computer inadvertently suffers any disruption to services, loss of in= formation, harm or is infected with a virus, other malicious computer progr= amme or code that may occur as a consequence of receiving this email. >> >> Unless stated otherwise, this email represents only the views of the sen= der and not the views of the Queensland Government. >> >> ********************************************************************** >> ********** >> >> The content presented in this publication is distributed by the Queensla= nd Government as an information source only. The State of Queensland makes = no statements, representations or warranties about the accuracy, completene= ss or reliability of any information contained in this publication. The Sta= te of Queensland disclaims all responsibility and all liability (including = without limitation for liability in negligence) for all expenses, losses, d= amages and costs you might incur as a result of the information being inacc= urate or incomplete in any way, and for any reason reliance was placed on s= uch information. >> This email, including any attachments sent with it, is confidential and = for the sole use of the intended recipient(s). This confidentiality is not = waived or lost, if you receive it and you are not the intended recipient(s)= , or if it is transmitted/received in error. >> >> Any unauthorised use, alteration, disclosure, distribution or review of = this email is strictly prohibited. The information contained in this email,= including any attachment sent with it, may be subject to a statutory duty = of confidentiality if it relates to health service matters. >> >> If you are not the intended recipient(s), or if you have received this e= mail in error, you are asked to immediately notify the sender. You should a= lso delete this email, and any copies, from your computer system network an= d destroy any hard copies produced. >> >> If not an intended recipient of this email, you must not copy, distribut= e or take any action(s) that relies on it; any form of disclosure, modifica= tion, distribution and/or publication of this email is also prohibited. >> >> Although the Queensland Ambulance Service takes all reasonable steps to = ensure this email does not contain malicious software, the Queensland Ambul= ance Service does not accept responsibility for the consequences if any per= son's computer inadvertently suffers any disruption to services, loss of in= formation, harm or is infected with a virus, other malicious computer progr= amme or code that may occur as a consequence of receiving this email. >> >> Unless stated otherwise, this email represents only the views of the sen= der and not the views of the Queensland Government. >> >> ********************************************************************** >> ********** >> >> The content presented in this publication is distributed by the Queensla= nd Government as an information source only. The State of Queensland makes = no statements, representations or warranties about the accuracy, completene= ss or reliability of any information contained in this publication. The Sta= te of Queensland disclaims all responsibility and all liability (including = without limitation for liability in negligence) for all expenses, losses, d= amages and costs you might incur as a result of the information being inacc= urate or incomplete in any way, and for any reason reliance was placed on s= uch information. >> > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2 > > This email, including any attachments sent with it, is confidential and f= or the sole use of the intended recipient(s). This confidentiality is not w= aived or lost, if you receive it and you are not the intended recipient(s),= or if it is transmitted/received in error. > > Any unauthorised use, alteration, disclosure, distribution or review of t= his email is strictly prohibited. The information contained in this email, = including any attachment sent with it, may be subject to a statutory duty o= f confidentiality if it relates to health service matters. > > If you are not the intended recipient(s), or if you have received this em= ail in error, you are asked to immediately notify the sender. You should al= so delete this email, and any copies, from your computer system network and= destroy any hard copies produced. > > If not an intended recipient of this email, you must not copy, distribute= or take any action(s) that relies on it; any form of disclosure, modificat= ion, distribution and/or publication of this email is also prohibited. > > Although the Queensland Ambulance Service takes all reasonable steps to e= nsure this email does not contain malicious software, the Queensland Ambula= nce Service does not accept responsibility for the consequences if any pers= on's computer inadvertently suffers any disruption to services, loss of inf= ormation, harm or is infected with a virus, other malicious computer progra= mme or code that may occur as a consequence of receiving this email. > > Unless stated otherwise, this email represents only the views of the send= er and not the views of the Queensland Government. > > *************************************************************************= ******* > > The content presented in this publication is distributed by the Queenslan= d Government as an information source only. The State of Queensland makes n= o statements, representations or warranties about the accuracy, completenes= s or reliability of any information contained in this publication. The Stat= e of Queensland disclaims all responsibility and all liability (including w= ithout limitation for liability in negligence) for all expenses, losses, da= mages and costs you might incur as a result of the information being inaccu= rate or incomplete in any way, and for any reason reliance was placed on su= ch information. --=20 Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2