Simple ECF Application doesnt work [message #998062] |
Wed, 09 January 2013 04:40  |
Eclipse User |
|
|
|
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 10:53   |
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 04:54   |
Eclipse User |
|
|
|
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 06:02] by Moderator
|
|
|
|
|
Re: Simple ECF Application doesnt work [message #998636 is a reply to message #998621] |
Thu, 10 January 2013 06:50  |
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
|
|
|
Powered by
FUDForum. Page generated in 0.04369 seconds