4

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!

рüффп
  • 5,172
  • 34
  • 67
  • 113
Luixv
  • 8,590
  • 21
  • 84
  • 121

1 Answers1

6

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
gertv
  • 276
  • 1
  • 2
  • Thanks for your answer. BTW, what about if I want to add a jar developed by myself which is local to my environment (myJar.jar)? – Luixv Oct 18 '13 at 09:44
  • 2
    If you're using Maven for development, the usual solution would be to build the artifact and then use the same kind of URL for your artifacts (mvn://). However, the URL can be anything you want really, so you can also use http://... or file:// to point to the artifact. – gertv Oct 18 '13 at 10:36