Hawtio as an OSGI bundle - osgi

We have our own karaf based application and recently we decided to migrate our web console on hawtio as a plugin. Is there any possibility to append hawtio to our project as an OSGI bundle? i've downloaded hawtio project, but there is no maven module with packaging mode "bundle" or something like that. As an option of course we can get kar archive file, extract it and use its bundles. But that's not a native way at all. Thank you!

Hello have you try to use the latest Hawtio for karaf (hawtio-karaf) available on maven repository?
http://search.maven.org/#artifactdetails|io.hawt|hawtio-karaf|1.4.26|jar
It provide a features.xml that can be install on Karaf.
First: install everything on your local maven repo.
Second: launch your karaf.
Third: run the command: feature:repo-add mvn:io.hawt/hawtio-karaf/1.4.26/xml/features
Fourth: run the command: feature:install hawtio
According to the official website, the default URL is: http://localhost:8181/hawtio/
Let me know if it is working as you were expecting.

There is no clean solution for standalone unit testing, but apache karaf provides exam environment for such situations - http://karaf.apache.org/manual/latest/developers-guide/writing-tests.html
So we can run tests with our application and hawtio in dev mode.
On production this leak of functionality is absent.

Related

Package and deploy OSGi bundles and Karaf features in Karaf Container

Recently, I have been working on Apache Karaf project.
The first one is a CXF REST service example and the second one is an Apache Karaf Maven example to run and deploy a Karaf container.
What I would like to do is to combine these two. The idea is to download a couple of JAR files from a repository and then package them into a Karaf.
Building Karaf Assembly manually then deploying the created JAR files in my deploy folder under Karaf is not a good idea if the task is reccurent each day. I would very much like to automate this if possible?
To achieve automatic deploy of Java project in Karaf, follow these steps:
Create a feature project: It is a Maven project and its goal is to create a descriptor of JAR (bundles) to be deployed under Karaf. The packaging of this Maven project is feature.
For your project of Karaf Assembly, add your feature as dependency and add it as boot feature so it can be installed when Karaf is up.
Look at this project https://github.com/benson-basis/karaf-feature-version-tc.
It has all the necessary configuration to automate Karaf building and deploy.

Is it possible to install the karaf server using maven?

I would like to use maven to deploy a complete karaf server including my own features. But so far I am unable to find a way to add the karaf server itself as a dependency. This would save a lot of manual steps, esp. for the other developers which would not have to setup karaf manually.
This would have the added benefit that I do not have to check in the karaf server into the repository in order to have all required parts available from the repository.
Question: is there a way to configure a project using karaf which will setup the karaf server and all required dependencies without manually downloading the files from the karaf website?
This can be done using the karaf-maven-plugin. There is even an example which does this shipped with karaf: examples/karaf-maven-example.
Here is what the examples do
karaf-maven-example-run uses the karaf-maven-plugin:run goal to download and start a Karaf instance.
karaf-maven-example-run-bundle uses the karaf-maven-plugin:run goal to download, start a Karaf instance and deploy the project bundle in this running instance.
karaf-maven-example-deploy uses the karaf-maven-plugin:deploy goal to deploy the module artifact into a Karaf instance (remote for example).
karaf-maven-example-client uses the karaf-maven-plugin:client goal to execute a shell command on a running Karaf instance.
karaf-maven-example-kar packages a features repository as a kar file, ready to be deployed.
karaf-maven-example-assembly uses the karaf-maven-plugin to create a Karaf distribution.
see here for more details.

Deployment in Jboss fuse using Maven

I have created a Fuse integration project in developer studio 9.0.2 and I'm using jboss-fuse-karaf-6.3.0 as the runtime container.
I want to deploy this project using Maven, but not able to figure out -
How and where to give server URL, user name and password for the deployment ?
Does project gets deployed to fabric or karaf ?
Will appreciate if anybody can help with some pointers.
Thanks in advance.
Is that server running locally or remote?
Locally you can simply define the server in the servers view and then use Add context menu to deploy your project.
it gets deployed to Karaf
When building projects with Maven I use osgi:install and dev:watch commands (available in both JBoss Fuse and vanilla Karaf). The following setup works well for a development machine.
First build with Maven using install goal, so the artifact gets installed in local repository.
Then issue osgi:install (see Manual Deployment in JBoss Fuse docs) command in your container to install your bundle. Job done!
> osgi:install mvn:it.your.package/your-artifact/1.0.0
Once the bundle is installed you will see a message like
Bundle ID: 352
This is the ID of the bundle installed. Issue the following command:
> dev:watch 352
Watched URLs/IDs:
352
Now every time you rebuild with Maven, the bundle gets redeployed automatically.
Watch out some settings to be changed if dev:watch does not reload bundles on JBoss Fuse 6.3.0
edit: use -SNAPSHOT in your version with this setup. Regular versionsmay not redeploy correctly because the container sees the version is the same and may use previously loaded classes, thus causing classloading issues.

Eclipse Virgo 3.0.3 and apache felix web console

Folks,
I'm trying to get the apache Felix webconsole running on an eclipse Virgo 3.0.3 installation -- I need the extra details it provides that the standard virgo admin doesn't.
I uploaded the full org.apache.felix.webconosle-3.1.8.jar to the pickup dir.
This virgo Jetty is running at port 8098, but when I do:
host:8098/system/console
I am getting the 404 not found.
Any ideas here how to get the webconsole integrated into the Eclipse Virgo Jetty install?
Thanks!
Although I didn't use Virgo in a long time, I guess it is because the installation is missing a standard OSGi HTTP service, which is required for the Felix web console bundle to work. You need to install a bundle that exports such a service based on the Jetty bundle you are using.

how to make camel-example-cxf-proxy work in serviceMix 4.3.0

I downloaded camel 2.6.0 and used example camel-example-cxf-proxy (under example folder) to deploy into serviceMix.
what i would like to do is packaging it to become a jar file and then goto serviceMix karaf console to install this jar.
(install -s wrap:file:/c:/...jar)
But this example doesn't work in serviceMix 4.3.0.
Do you know what thing i have to modify to make it work within serviceMix 4.3.0
Do i have to install any other bundle into serviceMix?
The first thing is that you should make sure your maven project builds a bundle. I recently did a tutorial that shows how to run camel routes in OSGi:
http://www.liquid-reality.de/display/liquid/2012/01/03/Karaf+Tutorial+Part+5+-+Running+Apache+Camel+integrations+in+OSGi
So basically you have to make sure that the camel features you need are installed. In your case this is probably camel-cxf and camel-http.
Then you need to change the pom to create a bundle. See the pom of the example:
https://github.com/cschneider/Karaf-Tutorial/blob/master/camel/jms2rest/pom.xml
You need to change the packaging to bundle and add the maven bundle plugin. For camel projects the default typically work very well.
Btw. you can also run camel on pure karaf when you follow the instructions in my tutorial. This has the advantage that you can almost always use the newest camel version while servicemix often comes with an older version.

Resources