Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[ecf-dev] How to catch an Exception while registering a remote service?

Hi Everybody,

Thanks Wim und Scott for the input on my earlier questions regarding network failures. That helped a lot!

Today I am trying to tackle something else that sometimes happens during startup: A service is not correctly registered as a remote service because the address used for the binding is already in use (stack trace see [1]). This happens on site from time to time and I would like to show an error message if it does but I don't know how to catch this event.

I register the service with:
	ServiceRegistration<?> registration = bundleContext.registerService(clazz, service, props);
This leads to an exception being logged, but I can't catch it. Actually it looks to me like the returned registration is valid, and it probably is locally.

Is there a setting I could use to have registerService fail if the remote registration fails? Or some other way to detect this error? In my case, the service is only used remotely, so I would really like to know if it couldn't be registered for some reason.

ECF Version 3.12.0.v20151130-0157
Distribution Provider: generic
Discovery provider: zeroconf

In case you want to know why this can happen although everything is configured correctly, here is the explanation: An application using remote services is running and works ok. For some reason the user closes the application and restarts it right away. Unfortunately, after the window is gone the application takes some time (2-3 seconds) to actually shut down. If it is restarted to early, the data area is already free (otherwise equinox would already through an error) but the remote binding address is not. Since the error is only logged the restarted application window is shown, but the remote services are not available. From the users point of view it is currently impossible to detect this problem without looking into the log (which our default game operator won't do).

Thanks for your help!

Cheers,
Christoph

[1] Stacke Trace

15:12:50.963 ERROR o.e.ecf.osgi.services.distribution - FrameworkEvent ERROR
org.osgi.framework.ServiceException: Exception in org.eclipse.ecf.internal.osgi.services.distribution.BasicTopologyManagerComponent.event()
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHookPrivileged(ServiceRegistry.java:1288) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHooksPrivileged(ServiceRegistry.java:1263) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyEventListenerHooksPrivileged(ServiceRegistry.java:1235) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:841) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225) ~[na:na]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464) ~[na:na]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482) ~[na:na]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:998) ~[na:na]
	at de.kware.pi.core.component.RemoteServiceComponent.registerService(RemoteServiceComponent.java:105) ~[na:na]
	at de.kware.app.agent.bomb.internal.BombActivator.start(BombActivator.java:60) ~[na:na]
	...
Caused by: java.lang.IllegalArgumentException: Failed to select, create, or configure ECF host container
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.exportService(RemoteServiceAdmin.java:324) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractTopologyManager.handleServiceRegistering(AbstractTopologyManager.java:442) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractTopologyManager.handleEvent(AbstractTopologyManager.java:404) ~[na:na]
	at org.eclipse.ecf.internal.osgi.services.distribution.BasicTopologyManagerImpl.event(BasicTopologyManagerImpl.java:119) ~[na:na]
	at org.eclipse.ecf.internal.osgi.services.distribution.BasicTopologyManagerComponent.event(BasicTopologyManagerComponent.java:57) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry$6.call(ServiceRegistry.java:1238) ~[na:na]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.notifyHookPrivileged(ServiceRegistry.java:1280) ~[na:na]
	... 42 common frames omitted
Caused by: org.eclipse.ecf.osgi.services.remoteserviceadmin.SelectContainerException: Exception creating or configuring container
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractContainerSelector.createContainer(AbstractContainerSelector.java:153) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractHostContainerSelector.createRSContainer(AbstractHostContainerSelector.java:333) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractHostContainerSelector.createMatchingContainer(AbstractHostContainerSelector.java:319) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractHostContainerSelector.createAndConfigureHostContainers(AbstractHostContainerSelector.java:244) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.HostContainerSelector.selectHostContainers(HostContainerSelector.java:77) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin$1.run(RemoteServiceAdmin.java:315) ~[na:na]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_60]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.exportService(RemoteServiceAdmin.java:312) ~[na:na]
	... 48 common frames omitted
Caused by: org.eclipse.ecf.core.ContainerCreateException: Create of containerType=ecf.generic.server failed.
	at org.eclipse.ecf.provider.generic.GenericContainerInstantiator.createInstance(GenericContainerInstantiator.java:303) ~[na:na]
	at org.eclipse.ecf.core.ContainerFactory.createContainer(ContainerFactory.java:296) ~[na:na]
	at org.eclipse.ecf.core.ContainerFactory.createContainer(ContainerFactory.java:592) ~[na:na]
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractContainerSelector.createContainer(AbstractContainerSelector.java:147) ~[na:na]
	... 55 common frames omitted
Caused by: java.net.BindException: Address already in use: JVM_Bind
	at java.net.TwoStacksPlainSocketImpl.socketBind(Native Method) ~[na:1.8.0_60]
	at java.net.TwoStacksPlainSocketImpl.socketBind(TwoStacksPlainSocketImpl.java:137) ~[na:1.8.0_60]
	at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) ~[na:1.8.0_60]
	at java.net.TwoStacksPlainSocketImpl.bind(TwoStacksPlainSocketImpl.java:110) ~[na:1.8.0_60]
	at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190) ~[na:1.8.0_60]
	at java.net.ServerSocket.bind(ServerSocket.java:375) ~[na:1.8.0_60]
	at java.net.ServerSocket.<init>(ServerSocket.java:237) ~[na:1.8.0_60]
	at org.eclipse.ecf.provider.comm.tcp.Server.<init>(Server.java:42) ~[na:na]
	at org.eclipse.ecf.provider.generic.TCPServerSOContainerGroup.putOnTheAir(TCPServerSOContainerGroup.java:71) ~[na:na]
	at org.eclipse.ecf.provider.generic.TCPServerSOContainer.<init>(TCPServerSOContainer.java:94) ~[na:na]
	at org.eclipse.ecf.provider.generic.GenericContainerInstantiator.createServerContainer(GenericContainerInstantiator.java:282) ~[na:na]
	at org.eclipse.ecf.provider.generic.GenericContainerInstantiator.createInstance(GenericContainerInstantiator.java:297) ~[na:na]
	... 58 common frames omitted


Back to the top