JB,

After reading of Apache Aires’s Service API 10 times I could figured out:

a) maven-bundle-plugin changes

<SPI-Consumer>*</SPI-Consumer>
<Require-Capability>osgi.extender; 
filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
<Import-Package>.,
Path/to/merged-elastic-jars
…

b) Merge all Elastic’s JARs files into a single one... 
<target name="zip">
        <zip destfile="elasticsearch-all-7.6.2.jar">
            <zipgroupfileset dir="." includes="*7.6.2*.jar"/>
        </zip>
        <zip destfile="lucene-all-8.4.0.jar">
            <zipgroupfileset dir="." includes="*8.4.0*.jar"/>
        </zip>
    </target>

I really didn’t get why merging jar into single one was part of the solution, 
but it is fine to me.

Thanks,

Davi


> On 10 May 2020, at 02:44, Jean-Baptiste Onofré <[email protected]> wrote:
> 
> Hi
> 
> Do you embed meta-in fin your bundle ? You can take a look on elasticsearch 
> 7.x service mix bundle  
> 
> Regards 
> JB
> 
> Le sam. 9 mai 2020 ? 19:30, Davi Baldin Tavares <[email protected]> a 
> ?crit :
> Hi Karaf users,
> 
> My bundle is using Elasticsearch 7.x. jars and everything is almost working 
> well, except for internal classes not being constructed well. Code is working 
> no tests outside Karaf.
> 
> While investigating, I?ve found this piece of code
> 
> XContentBuilder.class:117 (Elastic)
> 
>  // Load pluggable extensions
>         for (XContentBuilderExtension service : 
> ServiceLoader.load(XContentBuilderExtension.class)) {
>             Map<Class<?>, Writer> addlWriters = service.getXContentWriters(); 
>  
> 
> Jar file has META-INF/services file for XContentBuilderExtension (the piece 
> of code that is not being resolved while using Karaf). I?m using 4.2.7
> 
> Unfortunately, Elasting isn?t OSGi ready either (no Bundle META):
> 
> karaf@root()> bundle:install -s mvn:org.elasticsearch/elasticsearch/7.6.2
> Bundle IDs: 
> Error executing command: Error installing bundles:
>       Unable to install bundle mvn:org.elasticsearch/elasticsearch/7.6.2: 
> org.osgi.framework.BundleException: OSGi R3 bundle not supported
> karaf@root()> bundle:install -s 
> mvn:org.elasticsearch.client/elasticsearch-rest-high-level-client/7.6.2
> Bundle IDs: 
> Error executing command: Error installing bundles:
>       Unable to install bundle 
> mvn:org.elasticsearch.client/elasticsearch-rest-high-level-client/7.6.2: 
> org.osgi.framework.BundleException: OSGi R3 bundle not supported
> 
> 
> Is there a way to make sure ServiceLoader is able to work with JARs inside 
> bundle?s class path?
> 
> Thanks,
> 
> Davi

Reply via email to