Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Communications Framework (ECF) » Simple ECF Application doesnt work
Simple ECF Application doesnt work [message #998062] Wed, 09 January 2013 09:40 Go to next message
Hans Werner is currently offline Hans Werner
Messages: 3
Registered: January 2013
Junior Member
Hello,

I have a Provider Bundle that provides a Service. This is the start method:

public void start(BundleContext bundleContext) throws Exception {

		Hashtable properties = new Hashtable();
		properties.put("service.exported.interfaces", "*");
		properties.put("service.exported.configs", "ecf.generic.server");
		properties.put("org.eclipse.ecf.containerFactoryArgs",
				"ecftcp://localhost:3787/server");
		bundleContext.registerService(ServiceInterface.class.getName(),
				new ServiceImpl(), properties);
	}


The Consumer is in the same eclipse on the same machine (Windows 7). This is the start method:

public void start(BundleContext context) throws Exception {

		ServiceReference containerManagerRef = context
				.getServiceReference(IContainerManager.class.getName());
		IContainerManager containerManager = context
				.getService(containerManagerRef);
		IContainer container = containerManager.getContainerFactory()
				.createContainer("ecf.generic.client");

		IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container
				.getAdapter(IRemoteServiceContainerAdapter.class);

		IRemoteServiceReference[] serviceReferences = containerAdapter
				.getRemoteServiceReferences(
						IDFactory.getDefault().createID(
								container.getConnectNamespace(),
								"ecftcp://localhost:3282/server"),
						ServiceInterface.class.getName(), null);

		IRemoteService remoteService = containerAdapter
				.getRemoteService(serviceReferences[0]);
		ServiceInterface service = (ServiceInterface) remoteService.getProxy();
		System.out.println("Remote Service " + service.getRandomNumber());
	}


If I start Consumer and Provider I got the following Exception in the Consumer-Bundle.

org.eclipse.ecf.core.ContainerConnectException: Exception during connection to ecftcp://localhost:3282/server
	at org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:175)
	at org.eclipse.ecf.provider.generic.SOContext.connect(SOContext.java:112)
	at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.connectToRemoteServiceTarget(RegistrySharedObject.java:558)
	at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.getRemoteServiceReferences(RegistrySharedObject.java:139)
	at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.getRemoteServiceReferences(RegistrySharedObject.java:170)
	at consumer.Activator.start(Activator.java:37)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.resumeBundles(PackageAdminImpl.java:317)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:556)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:251)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:174)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at org.eclipse.ecf.provider.comm.tcp.SocketFactory.createSocket(SocketFactory.java:26)
	at org.eclipse.ecf.provider.comm.tcp.Client.connect(Client.java:182)
	at org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:145)
	... 17 more

!ENTRY org.eclipse.core.jobs 4 2 2013-01-09 10:43:17.641
!MESSAGE An internal error occurred during: "SLP Discovery".
!STACK 0
java.lang.IllegalArgumentException: Invalid service type: awws
	at ch.ethz.iks.slp.ServiceType.<init>(ServiceType.java:74)
	at org.eclipse.ecf.internal.provider.jslp.LocatorDecoratorImpl.getServiceURLs(LocatorDecoratorImpl.java:111)
	at org.eclipse.ecf.internal.provider.jslp.JSLPDiscoveryJob.run(JSLPDiscoveryJob.java:43)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

!ENTRY org.eclipse.equinox.concurrent 4 2 2013-01-09 10:43:17.820
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.equinox.concurrent".
!STACK 0
java.lang.IllegalArgumentException: Invalid service type: awws
	at ch.ethz.iks.slp.ServiceType.<init>(ServiceType.java:74)
	at org.eclipse.ecf.internal.provider.jslp.LocatorDecoratorImpl.getServiceURLs(LocatorDecoratorImpl.java:111)
	at org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer.getServices(JSLPDiscoveryContainer.java:156)
	at org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionLocator$3.run(EndpointDescriptionLocator.java:446)
	at org.eclipse.equinox.concurrent.future.SingleOperationFuture$1.run(SingleOperationFuture.java:96)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.equinox.concurrent.future.SingleOperationFuture.runWithProgress(SingleOperationFuture.java:89)
	at org.eclipse.equinox.concurrent.future.ThreadsExecutor$1.run(ThreadsExecutor.java:49)
	at java.lang.Thread.run(Unknown Source)



What is wrong with my code or is it not possible to start ecf in the same eclipse on the same machine? Thank you for your help.

Greets
Re: Simple ECF Application doesnt work [message #998227 is a reply to message #998062] Wed, 09 January 2013 15:53 Go to previous messageGo to next message
Eclipse User
On 01/09/2013 02:24 PM, Hans Werner wrote:
> Hello,
>
> I have a Provider Bundle that provides a Service. This is the start method:
>
>
> public void start(BundleContext bundleContext) throws Exception {
>
> Hashtable properties = new Hashtable();
> properties.put("service.exported.interfaces", "*");
> properties.put("service.exported.configs", "ecf.generic.server");
> properties.put("org.eclipse.ecf.containerFactoryArgs",
> "ecftcp://localhost:3787/server");
> bundleContext.registerService(ServiceInterface.class.getName(),
> new ServiceImpl(), properties);
> }
>
>
> The Consumer is in the same eclipse on the same machine (Windows 7).
> This is the start method:
>
>
> public void start(BundleContext context) throws Exception {
>
> ServiceReference containerManagerRef = context
> .getServiceReference(IContainerManager.class.getName());
> IContainerManager containerManager = context
> .getService(containerManagerRef);
> IContainer container = containerManager.getContainerFactory()
> .createContainer("ecf.generic.client");
>
> IRemoteServiceContainerAdapter containerAdapter =
> (IRemoteServiceContainerAdapter) container
> .getAdapter(IRemoteServiceContainerAdapter.class);
>
> IRemoteServiceReference[] serviceReferences = containerAdapter
> .getRemoteServiceReferences(
> IDFactory.getDefault().createID(
> container.getConnectNamespace(),
> "ecftcp://localhost:3282/server"),
> ServiceInterface.class.getName(), null);
>
> IRemoteService remoteService = containerAdapter
> .getRemoteService(serviceReferences[0]);
> ServiceInterface service = (ServiceInterface)
> remoteService.getProxy();
> System.out.println("Remote Service " + service.getRandomNumber());
> }
>
>
> If I start Consumer and Provider I got the following Exception in the
> Consumer-Bundle.
>
> org.eclipse.ecf.core.ContainerConnectException: Exception during
> connection to ecftcp://localhost:3282/server
> at
> org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:175)
>
> at
> org.eclipse.ecf.provider.generic.SOContext.connect(SOContext.java:112)
> at
> org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.connectToRemoteServiceTarget(RegistrySharedObject.java:558)
>
> at
> org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.getRemoteServiceReferences(RegistrySharedObject.java:139)
>
> at
> org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.getRemoteServiceReferences(RegistrySharedObject.java:170)
>
> at consumer.Activator.start(Activator.java:37)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
>
> at java.security.AccessController.doPrivileged(Native Method)
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
>
> at
> org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
>
> at
> org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
>
> at
> org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
>
> at
> org.eclipse.osgi.framework.internal.core.PackageAdminImpl.resumeBundles(PackageAdminImpl.java:317)
>
> at
> org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:556)
>
> at
> org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:251)
>
> at
> org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:174)
>
> at java.lang.Thread.run(Unknown Source)
> Caused by: java.net.ConnectException: Connection refused: connect
> at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
> at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
> at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
> at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
> at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
> at java.net.PlainSocketImpl.connect(Unknown Source)
> at java.net.SocksSocketImpl.connect(Unknown Source)
> at java.net.Socket.connect(Unknown Source)
> at
> org.eclipse.ecf.provider.comm.tcp.SocketFactory.createSocket(SocketFactory.java:26)
>
> at org.eclipse.ecf.provider.comm.tcp.Client.connect(Client.java:182)
> at
> org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:145)
>
> ... 17 more
>
> !ENTRY org.eclipse.core.jobs 4 2 2013-01-09 10:43:17.641
> !MESSAGE An internal error occurred during: "SLP Discovery".
> !STACK 0
> java.lang.IllegalArgumentException: Invalid service type: awws
> at ch.ethz.iks.slp.ServiceType.<init>(ServiceType.java:74)
> at
> org.eclipse.ecf.internal.provider.jslp.LocatorDecoratorImpl.getServiceURLs(LocatorDecoratorImpl.java:111)
>
> at
> org.eclipse.ecf.internal.provider.jslp.JSLPDiscoveryJob.run(JSLPDiscoveryJob.java:43)
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
>
> !ENTRY org.eclipse.equinox.concurrent 4 2 2013-01-09 10:43:17.820
> !MESSAGE Problems occurred when invoking code from plug-in:
> "org.eclipse.equinox.concurrent".
> !STACK 0
> java.lang.IllegalArgumentException: Invalid service type: awws
> at ch.ethz.iks.slp.ServiceType.<init>(ServiceType.java:74)
> at
> org.eclipse.ecf.internal.provider.jslp.LocatorDecoratorImpl.getServiceURLs(LocatorDecoratorImpl.java:111)
>
> at
> org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer.getServices(JSLPDiscoveryContainer.java:156)
>
> at
> org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionLocator$3.run(EndpointDescriptionLocator.java:446)
>
> at
> org.eclipse.equinox.concurrent.future.SingleOperationFuture$1.run(SingleOperationFuture.java:96)
>
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at
> org.eclipse.equinox.concurrent.future.SingleOperationFuture.runWithProgress(SingleOperationFuture.java:89)
>
> at
> org.eclipse.equinox.concurrent.future.ThreadsExecutor$1.run(ThreadsExecutor.java:49)
>
> at java.lang.Thread.run(Unknown Source)
>
>
>
> What is wrong with my code or is it not possible to start ecf in the
> same eclipse on the same machine? Thank you for your help.
>
> Greets


Hi Hans Werner,

the problem lies within the ECF discovery provider you are using (SLP).
It chokes on an invalid service type "awws" and subsequently causes the
remote service lookup to fail. Is "awws" a service you announce
explicitly or picked up on the network?

Thanks
Markus
Re: Simple ECF Application doesnt work [message #998583 is a reply to message #998227] Thu, 10 January 2013 09:54 Go to previous messageGo to next message
Hans Werner is currently offline Hans Werner
Messages: 3
Registered: January 2013
Junior Member
Hello Markus,

thank you for your reply. No I am a step further. This error described above no more exist. I have a running version with this provider:
public void start(BundleContext bundleContext) throws Exception {

		//"ecf.r_osgi.peer"
		Hashtable properties = new Hashtable();
		properties.put("service.exported.interfaces", "*");
		properties.put("service.exported.configs", "ecf.r_osgi.peer");		
		bundleContext.registerService(ServiceInterface.class.getName(),
				new ServiceImpl(), properties);
}


And this is the consumer:

public void start(BundleContext context) throws Exception {

		ServiceReference containerManagerRef = context
				.getServiceReference(IContainerManager.class.getName());
		IContainerManager containerManager = context
				.getService(containerManagerRef);
		IContainer container = containerManager.getContainerFactory()
				.createContainer("ecf.r_osgi.peer");

		IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container
				.getAdapter(IRemoteServiceContainerAdapter.class);

		IRemoteServiceReference[] serviceReferences = containerAdapter
				.getRemoteServiceReferences(
						IDFactory.getDefault().createID(
								container.getConnectNamespace(),
								"r-osgi://localhost:9278"),
						ServiceInterface.class.getName(), null);

		System.out.println(serviceReferences);
		IRemoteService remoteService = containerAdapter
				.getRemoteService(serviceReferences[0]);
		ServiceInterface service = (ServiceInterface) remoteService.getProxy();
		System.out.println("Remote Service " + service.getRandomNumber());

}


But I want to use the ecf.generic protocol. If I change the parameter to ecf.generic.client respective ecf.generic.server, the consumer doesnt create an connection. I got the following exception:

org.eclipse.ecf.core.ContainerConnectException: Exception during connection to ecftcp://localhost:3282/server
	at org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:175)
	at org.eclipse.ecf.provider.generic.SOContext.connect(SOContext.java:112)
	at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.connectToRemoteServiceTarget(RegistrySharedObject.java:558)
	at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.getRemoteServiceReferences(RegistrySharedObject.java:139)
	at org.eclipse.ecf.provider.remoteservice.generic.RegistrySharedObject.getRemoteServiceReferences(RegistrySharedObject.java:170)
	at consumer.Activator.start(Activator.java:40)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
	at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.resumeBundles(PackageAdminImpl.java:317)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:556)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:251)
	at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:174)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
	at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.SocksSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at org.eclipse.ecf.provider.comm.tcp.SocketFactory.createSocket(SocketFactory.java:26)
	at org.eclipse.ecf.provider.comm.tcp.Client.connect(Client.java:182)
	at org.eclipse.ecf.provider.generic.ClientSOContainer.connect(ClientSOContainer.java:145)
	... 17 more



What is wrong? Why can i not use the ecf.generic protocol?

Thanks in advance.

Here the code of the provider:

public void start(BundleContext bundleContext) throws Exception {

		Hashtable properties = new Hashtable();
		properties.put("service.exported.interfaces", "*");
		properties.put("service.exported.configs", "ecf.generic.server");
		properties.put("org.eclipse.ecf.containerFactoryArgs",
				"ecftcp://localhost:3282/server");
		bundleContext.registerService(ServiceInterface.class.getName(),
				new ServiceImpl(), properties);
}


Code from the consumer:

public void start(BundleContext context) throws Exception {

		ServiceReference containerManagerRef = context
				.getServiceReference(IContainerManager.class.getName());
		IContainerManager containerManager = context
				.getService(containerManagerRef);
		IContainer container = containerManager.getContainerFactory()
				.createContainer("ecf.generic.client");

		IRemoteServiceContainerAdapter containerAdapter = (IRemoteServiceContainerAdapter) container
				.getAdapter(IRemoteServiceContainerAdapter.class);

		IRemoteServiceReference[] serviceReferences = containerAdapter
				.getRemoteServiceReferences(
						IDFactory.getDefault().createID(
								container.getConnectNamespace(),
								"ecftcp://localhost:3282/server"),
						ServiceInterface.class.getName(), null);

		System.out.println(serviceReferences);
		IRemoteService remoteService = containerAdapter
				.getRemoteService(serviceReferences[0]);
		ServiceInterface service = (ServiceInterface) remoteService.getProxy();
		System.out.println("Remote Service " + service.getRandomNumber());

}

[Updated on: Thu, 10 January 2013 11:02]

Report message to a moderator

Re: Simple ECF Application doesnt work [message #998614 is a reply to message #998583] Thu, 10 January 2013 10:53 Go to previous messageGo to next message
Eclipse User
On 01/10/2013 10:54 AM, Hans Werner wrote:
> Hello Markus,
>
> no the awws Service is not a Service from me. I think this Service is
> from jSLP - I dont know.


Hi Hans Werner,

the service most definitely is not announced by jSLP but merely
discovered by it (meaning somebody on your local LAN announces an "awws"
service).


> If the problem comes from jSLP, how can I use Zookeeper in a fast way?
> Which code is necessary to use Zookeeper. I read the wiki but I dont
> understand how to change it exactly to Zookeeper in an easy and fast way.
>
> I know, I have to use a Container. But how can I merge this to a
> Service-Call with a further container which uses "ecf generic" for the
> service call.


You might as well try jmDNS as a LAN-based discovery provider. It is
just a matter of unplugging (un-deploying) the jSLP discovery provider
and replace it with the jmDNS one. You do not have to go and change the
service-invocation level. ECF separates service discovery and service
invocation.

HTH
Markus

P.S.: You might wanna file a bug against ECF remoteservices [1]. It
should not fail when discovery stumbles over a broken service announcement.

[1] https://bugs.eclipse.org/bugs/enter_bug.cgi?product=ECF
Re: Simple ECF Application doesnt work [message #998621 is a reply to message #998614] Thu, 10 January 2013 11:08 Go to previous messageGo to next message
Hans Werner is currently offline Hans Werner
Messages: 3
Registered: January 2013
Junior Member
Hello Markus,

thank you for your fast response. A little bit to fast perhaps Confused . I have edited my last question. Sorry for that.

I think jSLP is now not the problem. If discovery and service-calls are seperated from each other, the code above should not work, but with r-osgi it works.

[Updated on: Thu, 10 January 2013 11:40]

Report message to a moderator

Re: Simple ECF Application doesnt work [message #998636 is a reply to message #998621] Thu, 10 January 2013 11:50 Go to previous message
Eclipse User
On 01/10/2013 12:08 PM, Hans Werner wrote:
> Hello Markus,
>
> thank you for your fast response. A little bit to fast perhaps :? . I
> have edit my last question. Sorry for that.
>
> I think jSLP is now not the problem. If discovery and service-calls are
> seperated from each other, the code above should not work, but with
> r-osgi it works.

It might simply be the case that whatever service announces "awws" is
currently off the LAN and once it reappears interferes with discovery.

Anyway, a connection refused exception indicates that the generic server
cannot be reached by the consumer. Thus, I suggest you first verify that
the provider listens on port 3282 once started and that e.g. telnet or
nc can connect (at least open a connection).

From your code snippets I also take, that the consumer explicitly tries
to lookup the server/provider. With discovery this isn't necessary as
discovery will notify the consumer automatically once the service
provider goes live and connects the consumer to the provider. The
advantage is, that you won't have to deal with startup order.

Thanks
Markus
Previous Topic:[ECF/R-OSGi] java.lang.IllegalAccessError after 16 remote service calls
Next Topic:ECF doesn't remember IM providers from one eclipse session to the next
Goto Forum:
  


Current Time: Sat Oct 25 06:27:24 GMT 2014

Powered by FUDForum. Page generated in 0.03913 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software