Standard serialization Java and OSGi do not mix well because of class visibility problems, and since RMI is built on top of serialization ...
If you google around, you will find many people asking about RMI and OSGi, but a little in the way of specific solutions.
I did not sit down to investigate the specific problems of RMI and OSGi, but I solved the problem of using Spring HTTPInvoker , which still uses the Java serialization mechanism.
The problem boils down to one class: ObjectInputStream
This is the guy responsible for de-serializing - and to de-serialize an object, you need the visibility of its class. If you have a modern IDE, you can look at the inheritance hierarchy of this class and see that there are many extensions, including a couple of classes specific to RMI.
My solution was to use Spring's extensible implementation of ObjectInputStream and plug in the classloader from my package so that de-serialization will have access to the classloader that my classes could see.
You can play with system packages, but it really is a hack, and I would not recommend it for long-term use.
Unfortunately, OSGi still has some nasty angles that require you to dig up levels of abstraction in order to find the problem and fix it - RMI is one of those.
Paremus guys claim to have a solution in their server fabric Service Fabric (OSGi-based server) for RMI, and this can be configured to work with Felix (I think Eclipse Equinox is the default).
source share