javamavenapache-karafapache-servicemixjtidy

Installing a feature in servicemix


I am running Apache servicemix 4.5.2. I want to install a feature, i.e. a jar file. The feature I wanted is jtidy.

The pom dependence is:

<dependency>
    <groupId>jtidy</groupId>
    <artifactId>jtidy</artifactId>
    <version>4aug2000r7-dev</version>
</dependency>

and the repository is

http://repo1.maven.org/maven2/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar

I know the command features:install webconsole, for example but jtidy is not in my features:list. I've also tried using the addurl command but it didn't work. (addurl mvn:http://repo1.maven.org/maven2/jtidy/jtidy/4aug2000r7-dev) The Karaf documentation recommends to add a feature descriptor using the Features XML schema but unfortunately the link is broken.

Up to know what i did is to download the jtidy.jar and copied it to my deploy directory. It works, but I don't think that this is the correct way.

Do anybody knows how to install jtidy in servicemix correctly?

Thanks!


Solution

  • There's difference between installing a feature and installing a single JAR or OSGi bundle.

    A feature is defined in an XML file. A feature consists of a number of bundles, configs, ... that are installed together. Have a look at http://karaf.apache.org/manual/latest-2.3.x/users-guide/provisioning.html to learn more about features in Karaf.

    In this case, you want to install a single JAR into the container. You can use the command osgi:install to do this, followed by a URL pointing to the JAR (e.g. mvn:jtidy/jtidy/4aug2000r7-dev).

    However, in your case, there's one more complexity. jtidy is not an OSGi bundle by itself. The easiest way to add the necessary OSGi metadata, would be to use the wrap: protocol to automatically add the OSGi metadata to the JAR.

    So, to wrap things up - to install this jtidy dependency in Apache ServiceMix, you can use

    osgi:install wrap:mvn:jtidy/jtidy/4aug2000r7-dev