JAX-RS (RESTEasy, Jersey) + Spring + OSGi - spring

I'm working on transitioning of existing Java application to OSGi service which is using Spring (injections, AOP) and exposes REST API via JAX-RS (RESTEasy in particular). I was looking around on internet on how to make work this combination together, but didn't find any good solution yet.
a) Spring supports OSGi by Blueprint project.
b) RESTEasy integrates with Spring via resteasy-spring plugin. But there is no resteasy-blueprint or anything which could enable OSGi+Spring support for RESTEasy.
c) The same applies to Jersey. You can use it as a bundle or integrate it with spring using jersey-spring plugin. But not both.
Any suggestions?
Thanks!

Related

Spring Boot App - Reference external code during runtime that isn't part of the bundled WAR?

I have a Spring Boot+React application that is packaged as a bundled WAR.
This works well for most cases, but we need to be able to drop-in functionality in some cases that is not part of the bundle (such as via a JAR).
I knew OSGI exists for this case, but not sure of any usage with Spring Boot. Is there another way to do this as well?
If your use case is a kind of small plugin functionality for your spring boot app then you could start an OSGi framework inside spring boot and load bundles from a separate directory. You plugins could then offer their service via an interface that is provided by the spring boot app and an OSGi service with that interface.
You need some good OSGi knowledge for this to work.

BPMN for spring boot 2

We have started new project on spring stack and using latest versions. But we have workflow requirement and I used activiti in past. But as I see there is no spring boot 2 support for activiti and camunda. Can anybody suggest which BPM is best that can be integrated with spring boot 2.
You will find a bunch of Spring Boot 2 starters in the Flowable github repo.
The documentation explains step-by-step how to create a BPM enabled Spring Boot application. There is also the blog post The road to Spring Boot 2.0 that the improved support for Flowable within Spring Boot as part of the Flowable 6.3.0 release.
You ask for suggestions on which BPM is best. Well, I cannot be objective since I am part of the Flowable Team, but I can say that our Spring Boot implementation is pretty neat:
All engines are supported (BPMN, CMMN, DMN), both embedded and exposing their respective REST APIs.
There is an automatic configuration of Spring Security to use the Flowable IDM engine (in case no other custom security is configured).
There is no "EE" version of the starter. Flowable provides Spring Boot 2 support 100% Open Source.
The Spring Actuator integration is quite powerful.
Did I mention Open Source? ;-)
In order to get the all engines you would need to use the flowable-spring-boot-starter(-rest) dependency. The (-rest) needs to be used if you want the Flowable REST APIs to be automatically configured.
There is also the option to run the BPMN, CMMN or DMN engines in standalone mode. For that you would need one of the following dependencies:
flowable-spring-boot-starter-process(-rest)
flowable-spring-boot-starter-cmmn(-rest)
flowable-spring-boot-starter-dmn(-rest)
So, compare for yourself, but for me, it's pretty clear and of course I am open to discussion.
The Activiti is working on Activiti Cloud fully based on Spring Boot 2 and Spring Cloud Finchley (targeting kubernetes deployments, but it can be used outside kubernetes if that is not your thing) if you are looking for a BPMN runtime for Cloud Native applications. We are working hard on releasing the first Beta1 release at the moment, and we will very welcome feedback about it. Hope this helps.
If you use the camunda-bpm-spring-boot-starter you can write self contained services running camunda process engine with spring boot 2.

Spring 4 and OSGI

I want to use Spring in an application which loads several modules using OSGi. I want to be able to inject beans exposed by bundle A into targets exposed by bundle B.
I saw blueprint which seems to require Spring 3, and eclipse gemini which supports Spring 4 but seems pretty abandoned.
What's the latests on using OSGi with Spring 4?
Thanks
BLueprint is independent from spring. For example Aries Blueprint does not need any spring dependency. I am not sure about Gemini but I think it also does not require spring. Blueprint is optimized for OSGi and works well. It does not provide all spring features though.
Spring never worked well in OSGi. Spring 4 now even is not delivered as bundles. So I would not suggest to use spring in OSGi at all.
That said Apache Karaf offers spring 4 bundles but I am not sure how well they work. In any case I doubt you will get any OSGi support from spring source.

Guice + Jersey + Spring data

I am planning to use Guice(for DI) and Jersey( for rest). They integrate very well but I also want to leverage what spring-data provides. But it seems like we need to integrate spring first to use Spring data*. Is there any way i can integrate spring-data* without using spring ioc container.
Yes. I did it. it seems spring data related beans should be manually wired.

How do I make JaxWsPortProxyFactoryBean use JAX-WS 2.1?

I'm working on a project that delivers web services using Jersey, which has a dependency on JAXB 2.1. I have to add a feature that fetches data from another web service. The way this has been implemented elsewhere uses a Spring JaxWsPortProxyFactoryBean.
When Spring tries to initialize this bean it fails with a : ClassCastException (com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.bind.api.JAXBRIContext).
It appears that this is because JavaSE6 includes JAX-WS 2.0 API.
The only solution I have found suggests putting the 2.1 jars in the JRE endorsed directory. This isn't an option - I'm sharing a server with other application teams so I can't mess with the JRE.
Does anybody know of another way to make Spring use the 2.1 jars?

Resources