0

I was using KARAF 4.0.10 which installs spring 3.1.4 as boot feature. We were using spring for web module (spring-mvc) with spring-dm (spring-osgi-web).

Here is my example web.xml. That is my web.xml Mvc Servlet

<servlet>
<servlet-name>javorai-api</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.osgibundlexmlwebapplicationcontext</param-value>
</init-param>

As we upgraded KARAF to 4.2.0, spring is upgraded to 5.0.4 and spring-dm does not support it anymore. it is deprecated now. based on internet search, I found the suggestion to move on to gemini blueprint as replacement of spring-dm. I have downloaded gemini-blueprint/IO, Core and extender module by configuring it as maven dependency.

Can you please guide on what should be changed in web.xml to move on to gemini blueprint as replacement of spring-dm?

Also is there any way to get it working without using blueprint and directly referring spring jar files in web.xml

  • Correct me if I am wrong, but Gemini project has been dead for a long time, too. If you want to have a long-term solution, either choose OSGi or Spring, but do not use the two together. Reason: Spring is monolith, while OSGi is modular – Balazs Zsoldos Aug 07 '18 at 16:18

1 Answers1

0

If you really really really need to use Spring MVC, you can use the ServerOsgiBundleXmlWebApplicationContext class, it will work. But i must warn you, spring under an osgi environment is quite hackish, gemini will often mess up with the bundles lifecycle and it will break aries-blueprint bundles unless you apply a patch i've created for it.

Cλstor
  • 445
  • 3
  • 11
  • okay, I had tried that also but it seems org.eclipse.virgo.web.dm was not available on maven. it seems it is a dead project now. I found a jar of that and could see that jar also supports upto Spring 4 only. with KARAF 4.2.0, it installs spring 5.0.4 version. – Munish Gupta Aug 09 '18 at 02:04
  • Can you please suggest me the alternatives here, I am currently using spring MVC in OSGI, what could be options here for me? Can I completely come out of Spring and use any other technology to support it? – Munish Gupta Aug 09 '18 at 04:27
  • You can create a simple jar with the ServerOsgiBundleXmlWebApplicationContext class only, it does not have any dependencies with virgo, just with gemini and spring. Are you using the MVC part just to serve Rest Services or pages as well? – Cλstor Aug 09 '18 at 11:11
  • I am using MVC part for pages as well. – Munish Gupta Aug 09 '18 at 11:55
  • As you already suggested, spring under an osgi environment is quite hackish, what alternative options you can suggest? i think it would be better in that case not to use spring and try something else in osgi to meet same purpose. – Munish Gupta Aug 09 '18 at 12:12
  • In your case, i would go with aries-blueprint as an IOC container, and use the whiteboard approach to serve pages and services. Take a look [here](https://github.com/cschneider/Karaf-Tutorial) , there are plenty of examples using aries-blueprint with cxf, servlets an so on. – Cλstor Aug 09 '18 at 13:30
  • Thank you Castor for giving me the pointers. Let me go though it and see how can i replace it with spring-mvc. – Munish Gupta Aug 09 '18 at 15:20