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!
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
Related
How to see what an installed Karaf feature have inside?
Does it have other features in it?
What bundles and with what start-level does it install?
I talking about features like cxf of http.
You can use the command:
feature:info <featurename>
to get details about the feature. It shows dependent features, bundle and config for this feature.
If you want even more details you can check the feature repos:
feature:repo-list
Each install feature repo will be shown with a mvn uri.
For example for cxf 3.2.5 you would see.
cxf-3.2.5 mvn:org.apache.cxf.karaf/apache-cxf/3.2.5/xml/features
Karaf can directly display the content of these urls
cat mvn:org.apache.cxf.karaf/apache-cxf/3.2.5/xml/features
This will display the xml of the cxf feature. You can also find this directly in the maven central repo.
If a feature does strange things during its installation then there is also a way to debug:
feature:install -v http
This will install the karaf http feature and on the way log in detail what is done. Like bundles being deinstalled, installed, refreshed, restart, configs being deployed. This helps a lot when things do not go like expected.
I got a 3rd party jar which I am using for Blowfish decryption in a bundle that I need to deploy on apache karaf.
So now I also need karaf to know this jar but every solution I find is about creating a whole bundle for that jar which is pretty much for a simple library imo.
What I already did is installing that jar in my local maven repository and adding the dependency but this also doesn't work (at least on karaf).
Is there any other way to get 3rd party jars on apache karaf to work?
Are you using a features xml file? If so you could use wrap:mvn: to make it available:
<feature name="feature1" version="1.0.0">
<bundle>wrap:mvn:group.id/third.party.artefact.id/version</bundle>
<bundle>mvn:group.id/your.artefact/version</bundle>
</feature>
This will bundle the third party jar at runtime and make sure it's installed for your bundle to use. Taken from Karaf - Creating bundles
In addiction to #fiw you may want to osgify your thirdparty jar using Bndtools. In order to achive it:
Download bnd tools
Open a shell where you have downloaded bnd-2.4.0.jar.
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.
Deploy to maven repo overriding the previous maven coordinates, or deploy your thirdparty with different coordinates.
mvn deploy:deploy-file -Dfile osgify-dependency.jar ...
Someone could reccomend me what mailer install on the new Play 2.2.1 (java)? And how to install?
From older questions I've seen that the TypeSafe one is developed by Play creators that it should be good about compatibility but it doesn't send email with attachments, and they don't specify the dependencies to use on Play 2.2. Another suggestion I found is Apache mail (this seems to send also attachments), but don't know if works on 2.2 and how to install it. I'm finding lack of documentation on this side.
I'd like a lightweight Mailer that doesn't install tons of library.
How to install:
For unmanaged dependency just download the binaries, unzip it and copy the required *.jar files into lib folder in your project (create it if doesn't exists).
Optionally if you can find required package in Maven repository, you can just add a managed dependency to your build file (in SBT format).
Both approaches are clearly described in the Play's dependencies doc.
Just tip: after adding dependencies, clean the build, update dependencies and re-create configuration for your prefered IDE if required.
Edit:
Here you've got all Apache's commons in Maven: http://mvnrepository.com/artifact/org.apache.commons
Just go to last version of required lib and copy required dependency format (from SBT tab in this case) and use as described in above docs.
FYI: Play already imports some commons libraries ie. lang3, others like io, email etc you can import additionally if required.
I want to develop a multi-module application according to OSGi specification. Let's assume that one of my modules uses Apache Commons Logging 1.1.1. Spring provides a bundled version of Apache Commons Logging 1.1.1 in their repository, so I can add the corresponding dependency in my POM.
If I install my bundle in Apache Felix for example, is it right that the dependency to Apache Commons Logging 1.1.1 will not be resolved until I install the bundle of Apache Commons Logging 1.1.1 as well? My bundle will try to import a package that hasn't been exported.
I don't really understand how dependency management works in the OSGi world. Should I install every bundle that my application needs? Also, I don't understand how it integrates with Maven?
Thanks in advance for your explanations
EDIT: I've seen there is a subproject of Apache Felix called OBR that seems to facilitate bundles management (e.g. deployment). But, we already have a Maven architecture with local repositories, private repositories... How is OBR integrated to Maven?
If you want to use OSGi together with maven then I recommend Apache Karaf as a server which can use the Felix OSGi framework. The advantage is that you can install bundles directly from maven repositories using mvn: urls.
If you just use Apache Karaf with a maven repo then you have no transitive resolution at runtime. You have to install all bundles you need. What helps a lot is that karaf has the concept of features. So you can use the features as coarse grained building blocks. You can also create your own features where you refer to other features and bundles. This allows to install your whole app with one command.
Felix and Karaf also support OBR but you would have to create your own OBR Repo. There are currently no public OBR repos. The advantage of OBR is that it can resolve most of the transitive dependencies. The Karaf features even work together with OBR so you can just list some top level bundles in the feature and let OBR resolve the rest.
In practice I have good experiences with simple Karaf features without OBR. It is some manual work but less than you would expect and works quite well.
OSGi dependencies are based on Java packages: when a bundle states that it needs to import a given package (indicating a range of versions that are acceptable), the framework will attempt to "wire" that import to a suitable version of that package, that must be exported by another bundle.
If the package cannot be found, the bundle won't be resolved and cannot be started - so yes you'll need to install all bundles that your application requires, and as Christian indicates there are various tools that can help you with that.
A simple way to get the required bundles is to use the maven-dependencies-plugin to grab the bundles from Maven's list of dependencies and copy them somewhere where your app can find them at startup to install them, as done in [2] (in launcher/pom.xml), a small example app that I wrote.
You could also use Sling's maven-launchpad-plugin [3] to generate a runnable jar file that embeds the OSGi framework and all bundles that you need, and sets up everything at startup.
About the import and exports - without going into details, assuming you use the maven-bundle-plugin [1] to build your bundles, you'll specify what packages you want your bundle to export (others will be invisible to other bundles), and the maven-bundle-plugin will generate (in most cases automatically, but you can override that as needed) the list of packages to import, so there's usually not much work if your own code is cleanly split between packages that you want to export and internal implementation packages.
[1] http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
[2] https://github.com/bdelacretaz/OSGi-for-mere-mortals
[3] http://sling.apache.org/site/maven-launchpad-plugin.html
Is there a place where I can download Java EE API JARs as OSGi bundles?
I don't know of anywhere where you can do that, but you can wrap the jars and deploy them as bundles with the wrap scheme.
So the command that you would want to use to pull them from maven and wrap them as bundles would be osgi:install -s wrap:mvn:javax/javaee-api/6.0.
Apache Geronimo produces API jars for the Java EE packages and they are all (at least all the ones I've used) OSGi bundles. They are all installed in maven central. You can search for them in maven central here and either download them for use outside maven, or you can add the dependency to your pom and get them that way.