Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351483 - NotSerializableException when using DistributedEventAdmin with remote services
Summary: NotSerializableException when using DistributedEventAdmin with remote services
Status: RESOLVED INVALID
Alias: None
Product: ECF
Classification: RT
Component: ecf.remoteserviceadmin (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: ecf.core-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-07 14:45 EDT by Ajay CLA
Modified: 2011-08-09 00:27 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ajay CLA 2011-07-07 14:45:31 EDT
Build Identifier: 3.5.0

When using the Distributed Event Admin as described in the example here:
http://wiki.eclipse.org/Distributed_EventAdmin_Service
in conjunction with remote services (ecf.generic), I get a NotSerializableException when the event admin tries to send the IMPORT_SERVICE event.

org.osgi.framework.ServiceException: send exception to target=null eventToSend=org.osgi.service.event.Event [topic=org/osgi/service/remoteserviceadmin/IMPORT_REGISTRATION] messageParams=null
	at org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin.handleSendMessageException(DistributedEventAdmin.java:304)
	at org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin.sendMessage(DistributedEventAdmin.java:209)
	at org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin.postEvent(DistributedEventAdmin.java:165)
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.postRemoteServiceAdminEvent(RemoteServiceAdmin.java:1088)
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.postEvent(RemoteServiceAdmin.java:986)
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.publishEvent(RemoteServiceAdmin.java:901)
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.publishImportEvent(RemoteServiceAdmin.java:1019)
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.importService(RemoteServiceAdmin.java:309)
Caused by: java.io.NotSerializableException: Cannot serialize property value of name=clientBundle.version and value=1.0.0.qualifier
	at org.eclipse.ecf.remoteservice.eventadmin.EventMessage.createPropertiesFromEvent(EventMessage.java:51)
	at org.eclipse.ecf.remoteservice.eventadmin.EventMessage.<init>(EventMessage.java:35)
	at org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin.createMessageDataFromEvent(DistributedEventAdmin.java:249)
	at org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin.sendMessage(DistributedEventAdmin.java:205)
	... 21 more

Am I doing something wrong?

Reproducible: Always
Comment 1 Scott Lewis CLA 2011-07-07 14:59:40 EDT
From the stack trace provided...i.e.
Caused by: java.io.NotSerializableException: Cannot serialize property value of
name=clientBundle.version and value=1.0.0.qualifier
    at
org.eclipse.ecf.remoteservice.eventadmin.EventMessage.createPropertiesFromEvent(EventMessage.java:51)
    at
org.eclipse.ecf.remoteservice.eventadmin.EventMessage.<init>(EventMessage.java:35)
    at
org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin.createMessageDataFromEvent(DistributedEventAdmin.java:249)
    at
org.eclipse.ecf.remoteservice.eventadmin.DistributedEventAdmin.sendMessage(DistributedEventAdmin.java:205)
...

it seems that the failure is in the serialization of one of your properties in the Event...specifically the property 'clientBundle.version'.   First question: this is one of the properties you added to the event, isn't it?  Something to note:  Every one of the the event properties must be Serializable...so that the Event itself can be serialized and distributed (with the generic provider).

It seems likely to me that the value of this property (which is reported in the stack trace as value=1.0.0.qualifier) is actually of type org.osgi.framework.Version (gotten from Bundle.getVersion()?)...which is *not* Serializable.  This fits with the error message:  Cannot serialize property value of name=clientBundle.version and value=1.0.0.qualifier

If the value is converted from org.osgi.framework.Version to...e.g...a String...e.g. String bundleVersionValue = bundle.getVersion().toString();
then it then should be Serializable.
Comment 2 Scott Lewis CLA 2011-08-09 00:27:45 EDT
Resolving, as this seems to be problem with one of the event properties being not serializable rather than a problem with ECF distributed event admin.