Hi Jonathan,

Do you have a serialization exception (HazelcastSerializationException for instance) ?

Can you share your code in order for me to investigate and reproduce ? I guess that your classes/interfaces are Serializable, right ?

Regards
JB

On 07/28/2017 12:57 AM, jonathanknez wrote:
I am experienced with OSGi but new to distributed OSGi. Karaf provides Cellar
for DOSGi so I am starting with that one, though at this point I am still
open to any DOSGi implementation. I have followed the  Karaf - Cellar -
Greeter DOSGi example
<https://github.com/apache/karaf-cellar/tree/master/samples/dosgi-greeter>
and it works correctly. I even read the Learning Karaf Cellar book to get
more information on that specific example. I am now trying to write my own
code that does something similar. I always end up with a *Hazelcast
ClassNotFoundException serialization error that makes no sense*. I am hoping
someone here can point me in the right direction.

I have three bundles, just like the Greeter example; API, Publisher, and
Subscriber.
*API*
The API bundle defines the IPublisher interface. It also includes a concrete
class called Sub that IPublisher takes as an argument on some functions.

*Publisher*
The Publisher bundle contains a Publisher class that implements IPublisher.
For the sake of completeness, here is the majority of the Publisher class.


The publisher bundle also contains another class that is an OSGi component
that gets a reference to IPublisher, and successfully registers a "Sub"
instance.

*Subscriber*
This bundle has a class that is an OSGi component, gets a reference to
IPublisher, and tries to register a "Sub" instance.

I have a cluster of two nodes.
1. I successfully install the *API *bundle into the cluster. It is local on
both nodes.
2. I successfully install the *Publisher *bundle on the first node. That
works. The Sub that is local inside the Publisher bundle is successfully
registered.
3. I successfully install the *Subscriber *bundle on the second node. The
bundle is successfully activated but there are issues. My class successfully
gets a reference to IPublisher. It successfully creates an instance of Sub
(from the API package). It then attempts to pass Sub to the IPublisher in
the registerSubscriber() I created. That fails every time. It does not fail
in the second node. It actually fails on the first node, the node that has
the Publisher bundle loaded (and API).

The error message is as follows:


To me this error means that "Sub" couldn't be deserialized on Node A, as if
the class has not been loaded yet. That is bogus though because the Pub
bundle already created an instance of Sub itself and it worked fine. Plus,
Sub is defined in the API bundle that is loaded everywhere. I am baffled as
to why I am getting a serialization error, yet the Greeter example works
correctly.

If I take out Sub, and instead just invoke some methods on the IPublisher
which take primitives, they work fine. I only run into problems when passing
classes I have defined, regardless of whether they are in the API bundle or
not.

I know this problem is wordy. I appreciate any help you can provide.



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Serialization-error-when-using-DOSGi-with-Karaf-Cellar-4-1-1-tp4051114.html
Sent from the Karaf - User mailing list archive at Nabble.com.


--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to