How to easily deploy a Karaf Osgi container with a maven project

I am developing an OSGI package to parse a PDF file using the PDFBox library. I use maven to create the project, and Karaf the OSGI container. The PDFBox library is compatible with OSGI, so I thought it would be easy. But I just can't get the deployment model.

In a traditional web application, I would build one WAR file containing all the dependencies, and put it in the Servlet container, and it will be deployed. On the other hand, the only way I figured out how to install the osgi package is to do it manually. I have to create an installation instruction file that lists all the dependencies that you need to manually download and copy to the Karaf deployment folder, and be sure to do it in the correct order. I feel like back in the stone ages.

There should be an easier way, right? I still use maven to declare dependencies, but I just need to use the provided scope. It would be great if these dependencies could be automatically installed.

I use maven-bundle-plugin to create a package from my application. It creates the OBR repository (repository.xml), and I tried installing my package using the obr karaf plugin, but it still doesn't help with the dependencies.

+7
maven osgi apache-karaf karaf
source share
1 answer

There are various options for creating packages. I prefer to install the package using Maven through the Karaf console, for example:

install mvn:org.apache.pdfbox/pdfbox/1.8.4 

If you do not want to install each kit one by one, you can use the so-called functions, as described here . The function lists all the necessary packages:

 <feature name='my-project' version='1.0.0'> <feature version='2.4.0'>camel-spring</feature> <bundle start-level='80' start='false'>mvn:com.mycompany.myproject/myproject-dao</bundle> <bundle start-level='85' start='false'>mvn:com.mycompany.myproject/myproject-service</bundle> <bundle start-level='85' start='false'>mvn:com.mycompany.myproject/myproject-camel-routing</bundle> </feature> 

You add a function through the Karaf console:

 features:addUrl mvn:org.apache.servicemix.nmr/apache-servicemix-nmr/1.0.0-m2/xml/features features:install nmr 

Instead of the mvn handler, you can also use the file handler:

 features:addUrl file:base/features/features.xml 
+8
source share

All Articles