1

Currently I am moving from karaf 3.0.5 to the newest version 4.0.2, I do assembly my own karaf with the karaf-maven-plugin. This is how my pom looks like.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
    <groupId>my.own.group</groupId>
    <artifactId>assemble</artifactId>
    <version>1.14.0-SNAPSHOT</version>
    <relativePath>..</relativePath>
</parent>

<artifactId>karaf-customize</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>karaf-assembly</packaging>

<dependencies>
    <dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>framework</artifactId>
        <version>${karaf.version}</version>
        <type>kar</type>
    </dependency>
    <dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>standard</artifactId>
        <classifier>features</classifier>
        <version>${karaf.version}</version>
        <type>xml</type>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf.karaf</groupId>
        <artifactId>apache-cxf</artifactId>
        <classifier>features</classifier>
        <version>${cxf.version}</version>
        <type>xml</type>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.karaf.features</groupId>
        <artifactId>enterprise</artifactId>
        <classifier>features</classifier>
        <version>${karaf.version}</version>
        <type>xml</type>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>my.own.group</groupId>
        <artifactId>kar-archive</artifactId>
        <version>1.14.0-SNAPSHOT</version>
        <type>pom</type>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>my.own.group</groupId>
        <artifactId>karaf-branding</artifactId>
        <version>1.14.0-SNAPSHOT</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>com.alutam</groupId>
        <artifactId>ziputils</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.6.3</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>karaf-maven-plugin</artifactId>
            <version>${karaf.version}</version>
            <extensions>true</extensions>
            <configuration>
                <javase>1.8</javase>
                <bootFeatures>
                    <feature>jasypt-encryption</feature>
                    <feature>config</feature>
                    <feature>standard</feature>
                    <feature>region</feature>
                    <feature>management</feature>
                    <feature>bundle</feature>
                    <feature>package</feature>
                    <feature>kar</feature>
                    <feature>ssh</feature>
                    <feature>http</feature>
                    <feature>cxf</feature>
                    <feature>service-wrapper</feature>
                    <feature>jdbc</feature>
                    <feature>system</feature>
                </bootFeatures>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

With this configuration I do get the following error for several dependencies.

Caused by: org.osgi.framework.BundleException: Unsupported 'Bundle-ManifestVersion' value: 1
    at org.apache.karaf.features.internal.resolver.ResourceBuilder.doBuild(ResourceBuilder.java:88)
    at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:78)

I guess it happens within this parser. The reason is some old third party libraries have only Bundle-ManifestVersion: 1 set within their manifest file. With karaf-maven-plugin 3.x this didn't matter at all. In contrast the karaf-maven-plugin 4.x fails with message above. The only way I know to fix this is either rebuild from source or repack the hole jar again.

Is there any other way like a configuration for the karaf-maven-plugin to disable this constraint check? Because it would be awful lot of work to get all of this bundles up an running, again.

Community
  • 1
  • 1
Christian
  • 1,664
  • 1
  • 23
  • 43

1 Answers1

1

I faced the same error when updating to Karaf 4 and you have two choices:

Osgify conflictive dependency using bndtools:

  1. Download bnd tools

  2. Open a shell where you have downloaded bnd-2.4.0.jar.

  3. Type: java -jar bnd-2.4.0.jar wrap -o osgify-dependency.jar dependency.jar where dependency.jar is your third party and osgify-dependency.jar will be the output.

  4. Deploy to maven repo overriding the previous maven coordinates, or deploy your thirdparty with different coordinates.

    mvn deploy:deploy-file -Dfile osgify-dependency.jar ..

Enable the wrap protocol

Add to you maven karaf plugin wrap and wrapper features.

So you can use wrap protocol to fix your corrupted MANIFEST.MF

Inside some karaf features:

<bundle>wrap:mvn:group.id/third.party.artefact.id/version</bundle>

Inside your pom.xml notice feature wrap / wrapper.

 <plugin>
    <groupId>org.apache.karaf.tooling</groupId>
    <artifactId>karaf-maven-plugin</artifactId>
    <extensions>true</extensions>
    <executions>
    </executions>
    <configuration>

     <!-- no startupFeatures -->
     <bootFeatures>
      <feature>feature</feature>
      <feature>jaas</feature>
      <feature>shell</feature>
      <feature>ssh</feature>
      <feature>management</feature>
      <feature>bundle</feature>
      <feature>config</feature>
      <feature>deployer</feature>
      <feature>diagnostic</feature>
      <feature>instance</feature>
      <feature>kar</feature>
      <feature>log</feature>
      <feature>package</feature>
      <feature>service</feature>
      <feature>system</feature>
      <feature>wrap</feature>
      <feature>aries-blueprint</feature>
     </bootFeatures>
     <installedFeatures>
      ..
      <feature>wrapper</feature>
     </installedFeatures>
    </configuration>
   </plugin>

Here you have the full code where i tested:

https://github.com/antoniomaria/gazpachoquest/blob/master/karaf-assembly/pom.xml

  • Thanks for your answer. I think wrap and wrapper are two complete different features. Wrapper enable me to let karaf run as a service. Before karaf4 this was called service-wrapper. And yes I used the wrap feature, too to fix this. Also I have to mention, that I removed my maven parent. Because in may case this provided a lot of unnecessary dependencies I didn't need in my karaf deployment. – Christian Nov 16 '15 at 13:30
  • You are absolutely right, wrap and wrapper are two complete different things i just messed them up. But nice that we came up with the same solution. – Antonio Maria Sanchez Berrocal Nov 16 '15 at 16:19