1

I have legacy app written in Java 7 using Spring 3.2.18 that runs on Karaf 2.4.4 together with Spring-DM. I plan to move to newer versions of Spring, Java and Karaf.

I know that spring-dm is unsupported and I should move to Blueprint, but I'm not sure if I could then load OSGI beans in Spring context like spring-dm does. Does Karaf 2.4.4 supports it?

I would like not to change source code too much and still use @Autowired as I use right now.

As first step I plan to replace spring-dm with blueprint, next step would be to upgrade Spring 3 to Spring 4. Is it valid approach?

1 Answers1

1

Karaf by default uses Aries Blueprint, which does not supports spring beans at all, however you can use blueprint-maven-plugin, which creates a blueprint.xml file from annotated classes.

But if your code has a strong dependency with Spring, like SpringMVC to provide servlets, you can use Gemini Blueprint , which is the successor of Spring-DM and suports Spring up to version 4.3.x, but i must warn you, it can be tricky to make it work on karaf, specially if you use SpringMVC.

Cλstor
  • 445
  • 3
  • 11
  • There is an extension to Aries Blueprint which seems to support Spring/Spring-DM, but it's not documented : https://github.com/apache/aries/tree/trunk/blueprint/blueprint-spring – Jérémie B Jul 23 '17 at 16:40
  • it is worth saying that blueprint-maven-plugin will probably drop support of spring annotations : http://aries.apache.org/modules/blueprint-maven-plugin.html#spring-supported-in-version-1x-probably-dropped-in-next-major-versions – isco Jul 24 '17 at 08:56
  • It looks like Karaf 3 uses gemini extender by default https://github.com/apache/karaf/blob/karaf-3.0.8/assemblies/features/spring/src/main/feature/feature.xml As I don't want to change source code too much I think I'll try just to change SpringDM xml context configuration to Gemini Blueprint –  Jul 24 '17 at 10:49
  • @JérémieB I know that one, sadly it's still in very early alpha stage, so it can't be used in production. If i remember well, by default it has Gemini 1.0, which does not supports spring 4, you will need to use gemini 2.x, you can create your own feature file for it. – Cλstor Jul 24 '17 at 16:12
  • I agree and I can not get answers from the guys of Aries on this component. Sadly, most of the Aries documentation is too light to be confident (aries proxy, jpa, blueprint custom namespace, ...) – Jérémie B Jul 24 '17 at 16:16
  • can you elaborate on your point that making gemini work with karaf could be tricky – jayant mishra May 07 '18 at 14:59
  • 1
    @jayantmishra Sure! There are two major issues i found with gemini on Karaf. 1) Gemini-blueprint is not able to parse some blueprint.xml files because they are tighly coupled with Aries implementation, i've already submited a patch to gemini to fix that, should be released with gemini 3.1 2) Spring-servlets does not bind correctly with osgi, the old spring-dm had the OsgiBundleXmlWebApplicationContext implementation, which is not available on gemini, but it is on Virgo, so you will need to get that class from there. Well, it will work, but with some headaches. – Cλstor May 16 '18 at 00:07