You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using bundle com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider in an OSGi environment. The first thing I got was this exception:
java.lang.ClassNotFoundException: com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector cannot be found by com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider_2.6.3
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.fasterxml.jackson.jaxrs.json.JsonMapperConfigurator._resolveIntrospector(JsonMapperConfigurator.java:109)
The bundle com.fasterxml.jackson.module.jackson-module-jaxb-annotations was active, but not visible by the class loader of the first bundle.
My workaround was a fragment bundle. However, my suggestion here is to make the first bundle depend optionally on the other:
@diamondarts which order did you install/activate the two bundles? If the jackson-jaxrs-json-provider bundle was installed and resolved before the jackson-module-jaxb-annotations bundle then the optional import would be disabled (because in OSGi optional imports are only checked at the time the bundle is resolved, and if the package is not available at that time then it's not checked again until the bundle is refreshed/re-installed). So one option is to make sure the jackson-module-jaxb-annotations bundle is always resolved before the jackson-jaxrs-json-provider bundle (using a deployment manager or a container like Karaf can help). Alternatively if you can't change the install order you could refresh the jackson-jaxrs-json-provider bundle after the jackson-module-jaxb-annotations bundle was installed.
Another solution would be to use DynamicImport-Package instead of the optional import:
since dynamic imports are checked when needed, instead at bundle resolution time - and if a dynamic import isn't available then it will be rechecked the next time it's requested. (In other words it only caches a successful lookup, compared to an optional import which also caches a failed lookup). So a dynamic import would let you install the bundles in any order, at the cost of repeated failed lookups for the case when the jaxb bundle is not installed.
Hello,
I am using bundle
com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider
in an OSGi environment. The first thing I got was this exception:The bundle
com.fasterxml.jackson.module.jackson-module-jaxb-annotations
was active, but not visible by the class loader of the first bundle.My workaround was a fragment bundle. However, my suggestion here is to make the first bundle depend optionally on the other:
Thanks for the good work,
Björn
The text was updated successfully, but these errors were encountered: