karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boban Petkovic (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (KARAF-5674) Karaf 4.2.0 M2 class path issue
Date Tue, 20 Mar 2018 16:15:00 GMT

     [ https://issues.apache.org/jira/browse/KARAF-5674?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Boban Petkovic updated KARAF-5674:
----------------------------------
    Description: 
While migrating our application to work on karaf 4.2.0 (once it got released) I hit an issue
with class loader while testing on karaf 4.2.0 M2. I will try to explain it simple:

Let say I have bundle A that contains REST endpoints (CXF 3.2.2). I use dosgi to register
CXF endpoints. From REST endpoint (in bundle A) we invoke some code from bundle B that uses aws-java-sdk-osgi
bundle (version 1.11.272). This fails with the error:

javax.xml.stream.XMLInputFactory: Provider com.ctc.wstx.stax.WstxInputFactory not found

The same code works on karaf 4.1.5 and karaf 4.0.7 that we use at the moment. After some investigation
I figured out that the context of class loader used to invoke the code from our bundles is org.apache.cxf.cxf-rt-transports-http.
When I tried to set class loader to use our bundle's context it worked fine:
{code:java}
ClassLoader tccl = Thread.currentThread() .getContextClassLoader(); Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
AWS SDK calls that fails (from bundle B) 
Thread.currentThread().setContextClassLoader(tccl);{code}
Has something been changed when it comes to class loading mechanism in 4.2.0? While testing
the same code on 4.1.5 I can see that the same context (org.apache.cxf.cxf-rt-transports-http)
is used, but it works fine.

  was:
While migrating our application to work on karaf 4.2.0 (once it got released) I hit an issue
with class loader while testing on karaf 4.2.0 M2. I will try to explain it simple:

Let say I have bundle A that contains REST endpoints (CXF 3.2.2). I use dosgi to register
CXF endpoints. From REST endpoint (in bundle A) we invoke some code from bundle B that uses aws-java-sdk-osgi
bundle (version 1.11.272). This fails with the error:

javax.xml.stream.XMLInputFactory: Provider com.ctc.wstx.stax.WstxInputFactory not found

The same code works on karaf 4.1.5 and karaf 4.0.7 that we use at the moment. After some investigation
I figured out that the context of class loader used to invoke the code from our bundles is org.apache.cxf.cxf-rt-transports-http.
When I tried to set class loader to use our bundle context it worked fine:
{code:java}
ClassLoader tccl = Thread.currentThread() .getContextClassLoader(); Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
AWS SDK calls that fails (from bundle B) 
Thread.currentThread().setContextClassLoader(tccl);{code}
Has something been changed when it comes to class loading mechanism in 4.2.0? While testing
the same code on 4.1.5 I can see that the same context (org.apache.cxf.cxf-rt-transports-http)
is used, but it works fine.


> Karaf 4.2.0 M2 class path issue
> -------------------------------
>
>                 Key: KARAF-5674
>                 URL: https://issues.apache.org/jira/browse/KARAF-5674
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-osgi
>    Affects Versions: 4.2.0.M2
>            Reporter: Boban Petkovic
>            Priority: Critical
>
> While migrating our application to work on karaf 4.2.0 (once it got released) I hit an
issue with class loader while testing on karaf 4.2.0 M2. I will try to explain it simple:
> Let say I have bundle A that contains REST endpoints (CXF 3.2.2). I use dosgi to register
CXF endpoints. From REST endpoint (in bundle A) we invoke some code from bundle B that uses aws-java-sdk-osgi
bundle (version 1.11.272). This fails with the error:
> javax.xml.stream.XMLInputFactory: Provider com.ctc.wstx.stax.WstxInputFactory not found
> The same code works on karaf 4.1.5 and karaf 4.0.7 that we use at the moment. After some
investigation I figured out that the context of class loader used to invoke the code from
our bundles is org.apache.cxf.cxf-rt-transports-http. When I tried to set class loader to
use our bundle's context it worked fine:
> {code:java}
> ClassLoader tccl = Thread.currentThread() .getContextClassLoader(); Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
> AWS SDK calls that fails (from bundle B) 
> Thread.currentThread().setContextClassLoader(tccl);{code}
> Has something been changed when it comes to class loading mechanism in 4.2.0? While testing
the same code on 4.1.5 I can see that the same context (org.apache.cxf.cxf-rt-transports-http)
is used, but it works fine.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message