@Neil Bartlett <njbartl...@gmail.com>
the issue is with start ordering. Because configurator doesn't explicitly
use the Service Loader Mediator to describe a dependency on a _provider_ of
the Json API, if the provider isn't _resolved_ before the JSON API when the
lookup happens it will fail.

The solution is to start the provider earlier.

- Ray



On Tue, May 19, 2020 at 5:04 AM Neil Bartlett <njbartl...@gmail.com> wrote:

> I have raised a JIRA for this issue:
> https://issues.apache.org/jira/browse/FELIX-6277
>
> Cheers,
> Neil
>
> On Tue, 19 May 2020 at 08:58, Neil Bartlett <njbartl...@gmail.com> wrote:
>
> > Hi Apache devs,
> >
> > I'm trying to use org.apache.felix.configurator version 1.0.10 in an OSGi
> > enRoute project. EnRoute uses 1.0.6 by default, but I'm trying to bump
> the
> > version to see if it addresses what might be a lifecycle bug (that's a
> > topic for a separate email).
> >
> > Initially there were some problems resolving the bundle, so 1.0.10 has an
> > import that was not required in 1.0.6:
> >
> > [ERROR] Resolution failed. Capabilities satisfying the following
> > requirements could not be found:
> >     [<<INITIAL>>]
> >       ⇒ osgi.identity: (osgi.identity=org.example.app)
> >           ⇒ [org.example.app version=0.0.1.202005190718]
> >               ⇒ osgi.extender:
> > (&(osgi.extender=osgi.configurator)(version>=1.0.0)(!(version>=2.0.0)))
> >                   ⇒ [org.apache.felix.configurator version=1.0.10]
> >                       ⇒ osgi.wiring.package:
> > (&(osgi.wiring.package=javax.json)(&(version>=1.0.0)(!(version>=2.0.0))))
> >
> > I tried adding org.apache.geronimo.specs:geronimo-json_1.0_spec (which is
> > listed as a provided scope dependency of configurator) to the resolver
> > input as follows:
> >
> >         <dependency>
> >             <groupId>org.apache.geronimo.specs</groupId>
> >             <artifactId>geronimo-json_1.0_spec</artifactId>
> >             <version>1.0-alpha-1</version>
> >             <scope>runtime</scope>
> >         </dependency>
> >
> > This successfully resolves, but the Configurator now throws a CNFE from
> > its activator:
> >
> > ! Failed to start bundle org.apache.felix.configurator-1.0.10, exception
> > activator error org.apache.johnzon.core.JsonProviderImpl not found from:
> > javax.json.spi.JsonProvider:doLoadProvider#132
> > org.osgi.framework.BundleException: Exception in
> > org.apache.felix.configurator.impl.Activator.start() of bundle
> > org.apache.felix.configurator.
> >         at
> >
> org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:803)
> >         at
> >
> org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:732)
> >         at
> >
> org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1005)
> >         at
> >
> org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:357)
> >         ...
> > Caused by: javax.json.JsonException:
> > org.apache.johnzon.core.JsonProviderImpl not found
> >         at
> > javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:132)
> >         at javax.json.spi.JsonProvider.provider(JsonProvider.java:64)
> >         at javax.json.Json.createReader(Json.java:68)
> >         at
> >
> org.apache.felix.configurator.impl.json.JSONUtil.parseJSON(JSONUtil.java:329)
> >         at
> >
> org.apache.felix.configurator.impl.json.JSONUtil.readJSON(JSONUtil.java:161)
> >         at
> >
> org.apache.felix.configurator.impl.json.JSONUtil.readJSON(JSONUtil.java:122)
> >         at
> >
> org.apache.felix.configurator.impl.json.JSONUtil.readConfigurationsFromBundle(JSONUtil.java:86)
> >         at
> >
> org.apache.felix.configurator.impl.Configurator.processAddBundle(Configurator.java:315)
> >         ...
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.johnzon.core.JsonProviderImpl
> >         at
> >
> java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
> >         at
> >
> java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
> >         at
> java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
> >         at
> >
> org.eclipse.osgi.internal.framework.ContextFinder.loadClass(ContextFinder.java:135)
> >         at
> java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
> >         at
> > javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:129)
> >         ...
> >
> > I am running on Java 11 (AdoptOpenJDK build 11.0.7+10). What combination
> > of bundles does Configurator actually require? Why does this bundle
> allow a
> > correct resolution of imports but then throw a CNFE at runtime? Note that
> > configurator 1.0.6 embeds geronimo-json_1.0_spec-1.0-alpha-1.jar,
> > johnzon-core-1.0.0.jar and org.apache.felix.converter-1.0.0.jar using
> > Bundle-ClassPath, but this is no longer the case in 1.0.10. That seems
> like
> > an error.
> >
> > Regards,
> > Neil
> >
>


-- 
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
 (@Liferay)

Reply via email to