[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] Issue adding custom serialization to ecf provider

hi all,

i'm currently trying to implement custom serialization for the ecf generic remote service provider using the kryo library.
A problem occurs with deserializing instances of org.eclipse.ecf.remoteservice.RemoteServiceRegistrationImpl.Properties. Thats an inner class derived from java.util.Hastable. There occurs a NullPointer Exception when Kryo tries to add Elements to this Map (Hastable.class around Line 465).

The Reason: the field table of Hashtable does not get initialized. Initialization is done in the constructor. But because the derived Properties class hides the no-arg constructor of hastable the deserialization framework creates an instance of the class Properties "magically", but of course without calling the no-op Constructor of hastable. So the member table is null and leads to that problem.

Of course this is in the first step a problem with the non-java-default serialization, but it's an more or less obvious issue for a DTO Object...

Has anyone experienced this problem or has any ideas on how to workaround this?

Any ideas, comments or suggestions are more than welcome!

My Setup:
I registered custom IHostContainerSelector and IConsumerContainerSelector where i'm registering a custom serializer ~like this:

protected IRemoteServiceContainer createContainer(final ContainerTypeDescription containerTypeDescription,
final String containerTypeDescriptionName, @SuppressWarnings("rawtypes") final Map properties)
throws SelectContainerException {
final IRemoteServiceContainer serviceContainer = super.createContainer(containerTypeDescription,
containerTypeDescriptionName, properties);

final ISharedObjectContainer container = (ISharedObjectContainer) serviceContainer.getContainer();
container.setSharedObjectMessageSerializer(new KryoSharedMessageSerializer());

The MessageSerializer:

public class KryoSharedMessageSerializer implements ISharedObjectMessageSerializer {

    Kryo kryo = new Kryo();
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();

public KryoSharedMessageSerializer() {
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

public byte[] serializeMessage(final ID sharedObjectID, final Object message) throws IOException {
final Output output = new Output(baos);
kryo.writeClassAndObject(output, message);
return baos.toByteArray();

public Object deserializeMessage(final byte[] data) throws IOException, ClassNotFoundException {
return kryo.readClassAndObject(new Input(data));

Thanks, bye Peter