How to work with frequent local snapshot bundle deployments on Karaf?

孤者浪人 提交于 2019-11-30 00:18:02
Christian Schneider

The key to make the update mechanism of karaf work is to deploy from maven instead of using the deploy folder. Install you bundle like this:

install -s mvn:groupid/artifactID/version

or

install -s mvn:groupid/artifactID/version/typeOfMavenArtifact

Second one is useful for installing for example war/wab artifacts. Full maven protocol specification can be found here.

Then Karaf knows where the bundle came from. You can also check this using la -u. This makes karaf show the update location which now should be a maven uri. You will not that all karaf bundles have an update location like this.

When you now create a new build of your project using maven it will end up in you local maven repository. Then simply run

update <bundleid>

This makes karaf check the update location (in your case you local maven repo) and reload the bundle from there.

You can even further automate this by using

dev:watch

or for karaf 3+

bundle:watch

This will make karaf check you maven repo for changes in SNAPSHOT bundles it has deployed and automatically redeploy these.

This also works very well together with the remote debugging. Use

export KARAF_DEBUG=true

before starting karaf. It then will listen for a debugger on port 5005.

You can then start a remote debug eclipse session on the same port and nicely debug your application in karaf. This works very well even if you change your bundle using one of the approaches above. So you can debug, find your problem, change the code, build and continue debugging with the changed version.

I also use this frequently when I work at the karaf code base itself as this also works for most of karaf's own bundles.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!