title: java.util.ServiceConfigurationError Provider not a subtype while using OSGi bundle
body: <p>I'm creating a Liferay 7.1 OSGi bundle, which has some external dependencies in it. In consideration of time, we opted to embed the external JAR in our OSGi Bundle. I've managed to create a bnd file, which includes all of the ElasticSearch dependencies, and put them on the bundle classpath. I've used the source-code from github (<a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-search-elasticsearch6/portal-search-elasticsearch6-impl/build.gradle" rel="nofollow noreferrer">https://github.com/liferay/liferay-portal/blob/master/modules/apps/portal-search-elasticsearch6/portal-search-elasticsearch6-impl/build.gradle</a>) and the bnd.bnd file, to check what's imported.</p>
  
  <p>When activating the bundle, an exception is thrown:</p>
  
  <pre><code>The activate method has thrown an exception 
  java.util.ServiceConfigurationError: org.elasticsearch.common.xcontent.XContentBuilderExtension: Provider org.elasticsearch.common.xcontent.XContentElasticsearchExtension not a subtype
      at java.util.ServiceLoader.fail(ServiceLoader.java:239)
      at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
      at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
      at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
      at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
      at org.elasticsearch.common.xcontent.XContentBuilder.&lt;clinit&gt;(XContentBuilder.java:118)
      at org.elasticsearch.common.settings.Setting.arrayToParsableString(Setting.java:1257)
  </code></pre>
  
  <p>The XContentBuilderExtension is from the elasticsearch-x-content-6.5.0.jar,
  the XContentElasticsearchExtension class, is included in the elasticsearch-6.5.0.jar. Both are Included Resources, and have been put on the classpath.</p>
  
  <p>The Activate-method initializes a TransportClient in my other jar, hence it happens on activation ;).</p>
  
  <p>Edit: </p>
  
  <p>I've noticed that this error does NOT occur when installing this the first time, or when the portal restarts. So it only occurs when I uninstall and reinstall the bundle. (This is functionality I really prefer to have!). Maybe a stupid thought.. But could it be that there is some 'hanging thread'? That the bundle is not correctly installed, or that the TransportClient still is alive? I'm checking this out. Any hints are welcome!</p>
  
  <p>Edit 2:</p>
  
  <p>I'm fearing this is an incompatibility between SPI and OSGi? I've checked: The High Level Rest Client has the same issue. (But then with another Extension). I'm going to try the Low-Level Rest Client. This should work, as there are minimal dependencies, I'm guessing. I'm still very curious on why the incompatibility is there. I'm certainly no expert on OSGi, neither on SPI. (Time to learn new stuff!)</p>