Wednesday, July 16, 2014

Using Spring framework with Fabric8

So you wanna deploy Spring application into OSGi?

In the older versions of the Karaf, ServiceMix and Fuse we recommended to use Spring Dynamic Modules to deploy applications based on the Spring framework. As Spring DM project is not actively maintained anymore, we currently don't recommend to use it. Moreover due to the fact that there is no other alternative for Spring deployments in the OSGi environment, we don't recommend provisioning Spring-based applications into the OSGi anymore.

Spring Boot container

The recommended approach for working with the Spring applications in the Fabric8 environment is to use the Spring Boot container - the flat classpath microservice provisioned and managed by the Fabric8.

You can provision Spring Boot container either as a managed JVM process or as a Docker container.

Spring Boot container comes with many useful utilities that makes it much easier to use Apache Camel and ActiveMQ. Spring Boot containers can be also aware of the Gateway, ZooKeeper registry and the other Fabric8 components.

Other flat classpath containers

The other option to work with the Spring-based applications in the Fabric8 environment is to deploy those as a part of the WAR into Tomcat or as a module into the WildFly or Apache TomEE. You can also provision managed JVM process and start Spring application context yourself. Keep in mind that those deployment options don't make you to use Spring Boot - you can always create and manage the Spring application context yourself.


  1. Thanks for article. I haven't started prime time with fabric8 yet, but plan to. Meanwhile, If writing bundle for Fuse OSGI container (or karaf) that uses Camel, i didn't realize use of Spring XML to express your Camel route was frowned upon. Oh well, there is always Blueprint. I suppose blueprint is still viable for new Camel development to be deployed to Fuse OSGI container?

  2. Hi,

    Actually I wrote this post to increase the awareness about the fact that Spring DM is not maintained anymore. And that Spring fan-boys should use for example the Fabric8's Spring Boot container instead.

    Regarding Blueprint - yes, it is supported in Fuse by all means. And it is definitely recommended for the OSGi deployments.

    The another thing is that it is worth to consider if you really want to follow the OSGi path. There are so many cool flat classpath alternatives in Fabric right now :) . This is my personal opinion, but flat classpath are so simple and easy to maintain. I <3 flat classpaths, I really do :) .