Unsupported 'Bundle-ManifestVersion' value: 1

Hi There, I trying to develop an google task Add-on but after adding the dependencies to my bundle I’am getting the following exception during mvn clean install.

Caused by: org.osgi.framework.BundleException: Unable to build resource for mvn:com.google.apis/google-api-services-tasks/v1-rev71-1.25.0: Unsupported ‘Bundle-ManifestVersion’ value: 1
at org.apache.felix.utils.resource.ResourceBuilder.build(ResourceBuilder.java:82)
at org.apache.felix.utils.resource.ResourceBuilder.build(ResourceBuilder.java:71)

Can anybody help me to find a solution.

Many Thanks,

Konrad

If you look at /META-INF/MANIFEST.MF in that JAR you can see it does not have OSGi bundle headers:

Manifest-Version: 1.0
Archiver-Version: jar
Created-By: googleapis.com
Built-By: Google, Inc.
Build-Jdk: 1.8.0_242

So it is not an OSGi bundle and thus you should not add it as bundle dependency in the feature.xml file.

Instead you should add the dependency with no scope (the same as <scope>compile</scope>) to pom.xml. Then it will automatically be embedded into your add-on bundle.

If the Karaf feature verification then complains about missing packages imported by that dependency, you can make those optional using the bnd.importpackage property. See for instance the RRD4j add-on pom.xml, which does something similar for rrd4j.

Hi wborn, many thanks for your support. Your advice fixed this issue and brought me to the following pom.xml entry:

<properties>
    <bnd.importpackage>com.google.api-client.*;resolution:=optional, com.google.oauth-client.*;resolution:=optional,\
      com.google.api.client.*;resolution:=optional, com.sun.net.*;resolution:=optional,
      org.apache.http.client.*;resolution:=optional
    </bnd.importpackage>
  </properties>

Many Thanks again , Kind Regards Konrad

1 Like

Hi wborn, the entry within the pom help only for a short time, because after installation of the bundle the class loading for the google dependencies failed during runtime:

java.lang.NoClassDefFoundError: com/google/api/client/http/HttpTransport
	at org.openhab.binding.googletask.internal.GoogleTaskHandlerFactory.createHandler(GoogleTaskHandlerFactory.java:50) ~[?:?]
	at org.openhab.core.thing.binding.BaseThingHandlerFactory.registerHandler(BaseThingHandlerFactory.java:129) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.doRegisterHandler(ThingManagerImpl.java:670) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.registerHandler(ThingManagerImpl.java:647) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.registerAndInitializeHandler(ThingManagerImpl.java:1116) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.thingAdded(ThingManagerImpl.java:520) ~[?:?]
	at org.openhab.core.thing.internal.ThingRegistryImpl.notifyTrackers(ThingRegistryImpl.java:212) ~[?:?]
	at org.openhab.core.thing.internal.ThingRegistryImpl.notifyListenersAboutAddedElement(ThingRegistryImpl.java:132) ~[?:?]
	at org.openhab.core.thing.internal.ThingRegistryImpl.notifyListenersAboutAddedElement(ThingRegistryImpl.java:1) ~[?:?]
	at org.openhab.core.common.registry.AbstractRegistry.added(AbstractRegistry.java:175) ~[?:?]
	at org.openhab.core.common.registry.AbstractRegistry.added(AbstractRegistry.java:1) ~[?:?]
	at org.openhab.core.common.registry.AbstractProvider.notifyListeners(AbstractProvider.java:60) ~[?:?]
	at org.openhab.core.common.registry.AbstractProvider.notifyListeners(AbstractProvider.java:79) ~[?:?]
	at org.openhab.core.common.registry.AbstractProvider.notifyListenersAboutAddedElement(AbstractProvider.java:83) ~[?:?]
	at org.openhab.core.common.registry.AbstractManagedProvider.add(AbstractManagedProvider.java:67) ~[?:?]
	at org.openhab.core.common.registry.AbstractRegistry.add(AbstractRegistry.java:346) ~[?:?]
	at org.openhab.core.io.rest.core.internal.thing.ThingResource.create(ThingResource.java:283) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[?:?]
	at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[?:?]

Can you please help me again to resolve the loading dependencies issue.

Many Thanks,

Regards Konrad

Looks like your dependency depends on more dependencies. So just also add the required dependencies to the pom.xml and don’t make those package imports optional in the property. These will then also be embedded. It’s a bit trial and error.

What i not understand is that the pom contains the dependency which can’t be loaded

Caused by: java.lang.ClassNotFoundException: com.google.api.client.http.HttpTransport cannot be found by org.openhab.binding.googletask_3.2.0.202110271835
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:519) ~[org.eclipse.osgi-3.16.200.jar:?]
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:171) ~[org.eclipse.osgi-3.16.200.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]

My pom.xml

<bnd.importpackage>com.google.api-client.*;resolution:=dynamic, com.google.oauth-client.*;resolution:=dynamic,\
      com.google.api.client.*;resolution:=dynamic, com.sun.net.*;resolution:=dynamic,\
      org.apache.http.*;resolution:=dynamic,
    </bnd.importpackage>

You can similarly embed that missing/required dependency by removing the com.google.api-client packages from the bnd.importpackage property and add it to pom.xml:

<dependency>
  <groupId>com.google.api-client</groupId>
  <artifactId>google-api-client</artifactId>
  <version>1.25.0</version>
</dependency>

If that dependency has its own required dependencies, you need to add those as well.