Can I still use the ServiceTracker from OSGi? Or should I use the ServiceTracker bundle provided by you? And is this a difference? (except of the performance issues of course). I've placed your servicetracker bundle with the other bundles from osgi, and in my Eclipse project (with CTE) I see it under the "Concierge Bundles". So when I use ServiceTracker now, will it be your bundle, or the normal OSGi ServiceTracker?
And are there some specific items that I should know concerning the ServiceTracker? I'm using it now, but it seems that it isn't working properly? Since when I do:
the OSGi implementation and my tweaked version are equivalent. I have just optimized the OSGi implementation a bit.
If you have both bundles, you can choose one in your run configuration. Otherwise, the first installed wins.
I have no clue why your tracker does not return from the open() call. Do you have any idea which one you use?
Cheers,
Jan.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've no clue which i'm using... I thought it was the org.osgi.util.servicetracker or something like that. I don't know if your's is in the same package? And I don't have the source code here neither since that's a part of my job and I'm at home for the weekend now... I'll check it on monday and see what could be causing the problem...
Thanks
Jan Pannecoeck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've just tried it again at home, but now it isn't working at all!
java.lang.NoClassDefFoundError: org/osgi/util/tracker/ServiceTracker
at serviceuser.Activator.start(Activator.java:13)
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:459)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
Caused by: java.lang.ClassNotFoundException: org.osgi.util.tracker.ServiceTracker
at ch.ethz.iks.concierge.framework.BundleClassLoader.findClass(BundleClassLoader.java:608)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
... 6 more
org.osgi.framework.BundleException: Error starting bundle Bundle [3]: file:./ServiceUser_1.0.0.jar
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:473)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
What I've done is quite simple, I just created two Concierge Projects, One providing a simple Service and one using a ServiceTracker to get that Service and use it!
The code to get the Service:
import org.osgi.util.tracker.ServiceTracker;
...
ServiceTracker tracker = new ServiceTracker(context, IService.class.getName(), null);
tracker.open();
IService service = (IService)tracker.getService();
System.out.println("Name: " + service.getName());
But now the ServiceTracker isn't found as a class? I'm launching everything using the console with an init.xargs file:
-init
-istart shell-1.0.0.RC2.jar
-istart Service_1.0.0.jar (This is the ServiceProvider)
-istart ServiceUser_1.0.0.jar
Do you have any clue what this problem could be causing???
Thanks in advance... I believe I'm doing everything as I did before so I've no Idea why it isn't working with Concierge... :s Have you done this before and could give me some example or help???
Jan Pannecoeck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, different to other OSGi implementations, Concierge does not implement the service tracker in the core framework but has it as a separate bundle that you have to install when you want to use it. Within CTE, the service tracker is one of the default bundles that are added to your run configuration if you don't explicitly disable it but from the console, you have to manually add it to your init.xargs file. You can find the most recent version of the service tracker bundle on the Concierge homepage.
Cheers,
Jan.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well the funny part is that I did enable the ServiceTracker service in the init.xargs file! I did a istart from that file so that should work I assume?
I'll check back tomorrow when I'm at work. I'll get back to you.
But already thanks for the advise!
Cheers,
Jan Pannecoeck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well this is strange! I'm back at work trying my project to run again with the ServiceTracker that wasn't working on friday... Now it's all working... I've no clue why but well I'm happy that it's working... :-)
Probably some files that needed to be reloaded in Eclipse and needed a restart from Eclipse or something like that!
Thanks anyway for trying to solve my problem, but it solved itself :-) That's the nice thing about Software programming... Sometimes it's just solving its own problems... :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, well I said two hours ago that everything was working properly, and it is, when I use Eclipse CTE.
But since I'm writing for an embedded system, I would like to be able to start this all from the console also, and that's giving me some troubles... The same as I said before...
My exception:
Concierge> STARTING file:./service-tracker-1.0.0.RC2.jar
STARTING file:./model_1.0.0.jar
STARTING file:./swt_1.0.0.jar
STARTING file:./.serial_1.0.0.jar
STARTING file:./scpi_1.0.0.jar
SCPIService started
java.lang.NoClassDefFoundError: org/osgi/util/tracker/ServiceTracker
at scpi.osgi.Activator.start(Activator.java:15)
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:459)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
Caused by: java.lang.ClassNotFoundException: org.osgi.util.tracker.ServiceTracker
at ch.ethz.iks.concierge.framework.BundleClassLoader.findClass(BundleClassLoader.java:608)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 6 more
org.osgi.framework.BundleException: Error starting bundle Bundle [6]: file:./scpi_1.0.0.jar
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:473)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
Any clue what this problem could cause? And how I could solve it? As you can see, the service tracker bundle is started so that shouldn't be giving me any problems?
Thanks,
Jan Pannecoeck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are you sure that your scpi bundle is correctly package-importing org.osgi.util.tracker? If this is the case, you can first try the -Dch.ethz.iks.concierge.debug.packages=true option to find out if the import is correctly wired to the service tracker bundle and then maybe even the full -Dch.ethz.iks.concierge.debug=true to see if the delegation works properly. Or, you can just send me the bundles and I will have a look :-)
Thanks,
Jan.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Since this is for my job, I can't try this out in the next two weeks since I'm on vacation now! But I'll try it later this week with some other bundles to see if it's working!
Thanks for the reply, a merry Christmas and well for next week a Happy NewYear!
Jan Pannecoekc
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I finally found some time to try your solution, but I'm still not able to get everything working!
So I've now multiple Concierge OSGi Projects and they have all the ServiceTracker bundle in their Buildpath (service-tracker-1.0.0.RC2.jar)...Now I should add the org.osgi.util.tracker to the Import-Package part in the Manifest file. But this isn't working for all the projects! Sometime it does work and I'm able to add it as an Import-Package, but there are 2-3 projects where I can't add it
The exception: "No available bundle exports package org.osgi.util.tracker".
Do you have any idea what this could be causing? Since I think all my Concierge OSGi projects are build up the same, this should be working in all the different projects...
Can I solve this in a different way? I've tried to add the service-tracker direct to the buildpath but that still isn't working...
Kind regards,
Jan Pannecoeck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
that's most likely a problem of CTE working together with PDE. But you can always open the manifest as a text file and add the import. I will let the Buglabs folks know about the issue.
Cheers,
Jan.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, thanks for the reply but adding the import to the manifest isn't working neither... When I try to do it in Eclipse, it's already giving me an error that it can't find an org.osgi.util.tracker exported by an other bundle. But when I ignore that error and export the bundles to jar files that isn't complaining. So then I try to run everything with
I've been able to solve this problem. Probably it was my own stupidity that caused this problem. I've no clue how I've solved it, I've just checked if everything was at the right place and after that it worked. So probably I was still missing some import line...
But now it's all working properly!
Thanks for your help!! Concierge OSGi is running now on an embedded device without any problems!
Kind regards,
Jan Pannecoeck
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Can I still use the ServiceTracker from OSGi? Or should I use the ServiceTracker bundle provided by you? And is this a difference? (except of the performance issues of course). I've placed your servicetracker bundle with the other bundles from osgi, and in my Eclipse project (with CTE) I see it under the "Concierge Bundles". So when I use ServiceTracker now, will it be your bundle, or the normal OSGi ServiceTracker?
And are there some specific items that I should know concerning the ServiceTracker? I'm using it now, but it seems that it isn't working properly? Since when I do:
ServiceTracker tracker = new ServiceTracker(context, SomeInterface.class.getName(), null);
tracker.open();
System.out.println("Tracker == null: " + (tracker == null));
the last line isn't printed!!
Maybe I'm doing something wrong here? Or I'm not using the right ServiceTracker??
Kind regards,
Jan Pannecoeck
Hi Jan,
the OSGi implementation and my tweaked version are equivalent. I have just optimized the OSGi implementation a bit.
If you have both bundles, you can choose one in your run configuration. Otherwise, the first installed wins.
I have no clue why your tracker does not return from the open() call. Do you have any idea which one you use?
Cheers,
Jan.
Hello,
I've no clue which i'm using... I thought it was the org.osgi.util.servicetracker or something like that. I don't know if your's is in the same package? And I don't have the source code here neither since that's a part of my job and I'm at home for the weekend now... I'll check it on monday and see what could be causing the problem...
Thanks
Jan Pannecoeck
Hello,
I've just tried it again at home, but now it isn't working at all!
java.lang.NoClassDefFoundError: org/osgi/util/tracker/ServiceTracker
at serviceuser.Activator.start(Activator.java:13)
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:459)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
Caused by: java.lang.ClassNotFoundException: org.osgi.util.tracker.ServiceTracker
at ch.ethz.iks.concierge.framework.BundleClassLoader.findClass(BundleClassLoader.java:608)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
... 6 more
org.osgi.framework.BundleException: Error starting bundle Bundle [3]: file:./ServiceUser_1.0.0.jar
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:473)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
What I've done is quite simple, I just created two Concierge Projects, One providing a simple Service and one using a ServiceTracker to get that Service and use it!
The code to get the Service:
import org.osgi.util.tracker.ServiceTracker;
...
ServiceTracker tracker = new ServiceTracker(context, IService.class.getName(), null);
tracker.open();
IService service = (IService)tracker.getService();
System.out.println("Name: " + service.getName());
But now the ServiceTracker isn't found as a class? I'm launching everything using the console with an init.xargs file:
-init
-istart shell-1.0.0.RC2.jar
-istart Service_1.0.0.jar (This is the ServiceProvider)
-istart ServiceUser_1.0.0.jar
Do you have any clue what this problem could be causing???
Thanks in advance... I believe I'm doing everything as I did before so I've no Idea why it isn't working with Concierge... :s Have you done this before and could give me some example or help???
Jan Pannecoeck
Yes, different to other OSGi implementations, Concierge does not implement the service tracker in the core framework but has it as a separate bundle that you have to install when you want to use it. Within CTE, the service tracker is one of the default bundles that are added to your run configuration if you don't explicitly disable it but from the console, you have to manually add it to your init.xargs file. You can find the most recent version of the service tracker bundle on the Concierge homepage.
Cheers,
Jan.
Well the funny part is that I did enable the ServiceTracker service in the init.xargs file! I did a istart from that file so that should work I assume?
I'll check back tomorrow when I'm at work. I'll get back to you.
But already thanks for the advise!
Cheers,
Jan Pannecoeck
Well this is strange! I'm back at work trying my project to run again with the ServiceTracker that wasn't working on friday... Now it's all working... I've no clue why but well I'm happy that it's working... :-)
Probably some files that needed to be reloaded in Eclipse and needed a restart from Eclipse or something like that!
Thanks anyway for trying to solve my problem, but it solved itself :-) That's the nice thing about Software programming... Sometimes it's just solving its own problems... :-)
Ok, well I said two hours ago that everything was working properly, and it is, when I use Eclipse CTE.
But since I'm writing for an embedded system, I would like to be able to start this all from the console also, and that's giving me some troubles... The same as I said before...
My init.xargs file:
-init
-istart shell.jar
-istart service-tracker-1.0.0.RC2.jar
-istart model_1.0.0.jar
-istart swt_1.0.0.jar
-istart serial_1.0.0.jar
-istart scpi_1.0.0.jar
-istart view_1.0.0.jar
My exception:
Concierge> STARTING file:./service-tracker-1.0.0.RC2.jar
STARTING file:./model_1.0.0.jar
STARTING file:./swt_1.0.0.jar
STARTING file:./.serial_1.0.0.jar
STARTING file:./scpi_1.0.0.jar
SCPIService started
java.lang.NoClassDefFoundError: org/osgi/util/tracker/ServiceTracker
at scpi.osgi.Activator.start(Activator.java:15)
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:459)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
Caused by: java.lang.ClassNotFoundException: org.osgi.util.tracker.ServiceTracker
at ch.ethz.iks.concierge.framework.BundleClassLoader.findClass(BundleClassLoader.java:608)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 6 more
org.osgi.framework.BundleException: Error starting bundle Bundle [6]: file:./scpi_1.0.0.jar
at ch.ethz.iks.concierge.framework.BundleImpl.startBundle(BundleImpl.java:473)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.setLevel(Framework.java:2495)
at ch.ethz.iks.concierge.framework.Framework$SystemBundle.access$000(Framework.java:2037)
at ch.ethz.iks.concierge.framework.Framework.startup(Framework.java:474)
at ch.ethz.iks.concierge.framework.Framework.main(Framework.java:304)
And my code to create the servicetracker:
import org.osgi.util.tracker.ServiceTracker;
System.out.println("SCPIService started");
ServiceTracker tracker = new ServiceTracker(context, IBackplaneService.class.getName(), null);
tracker.open();
System.out.println("Tracker == null: " + (tracker == null));
IBackplaneService service = (IBackplaneService) tracker.getService();
System.out.println("Service == null: " + (service == null));
new SCPIServiceTest(service);
Any clue what this problem could cause? And how I could solve it? As you can see, the service tracker bundle is started so that shouldn't be giving me any problems?
Thanks,
Jan Pannecoeck
Are you sure that your scpi bundle is correctly package-importing org.osgi.util.tracker? If this is the case, you can first try the -Dch.ethz.iks.concierge.debug.packages=true option to find out if the import is correctly wired to the service tracker bundle and then maybe even the full -Dch.ethz.iks.concierge.debug=true to see if the delegation works properly. Or, you can just send me the bundles and I will have a look :-)
Thanks,
Jan.
Hello,
Since this is for my job, I can't try this out in the next two weeks since I'm on vacation now! But I'll try it later this week with some other bundles to see if it's working!
Thanks for the reply, a merry Christmas and well for next week a Happy NewYear!
Jan Pannecoekc
Hello,
Here I'm again...
I finally found some time to try your solution, but I'm still not able to get everything working!
So I've now multiple Concierge OSGi Projects and they have all the ServiceTracker bundle in their Buildpath (service-tracker-1.0.0.RC2.jar)...Now I should add the org.osgi.util.tracker to the Import-Package part in the Manifest file. But this isn't working for all the projects! Sometime it does work and I'm able to add it as an Import-Package, but there are 2-3 projects where I can't add it
The exception: "No available bundle exports package org.osgi.util.tracker".
Do you have any idea what this could be causing? Since I think all my Concierge OSGi projects are build up the same, this should be working in all the different projects...
Can I solve this in a different way? I've tried to add the service-tracker direct to the buildpath but that still isn't working...
Kind regards,
Jan Pannecoeck
Hi Jan,
that's most likely a problem of CTE working together with PDE. But you can always open the manifest as a text file and add the import. I will let the Buglabs folks know about the issue.
Cheers,
Jan.
Hello, thanks for the reply but adding the import to the manifest isn't working neither... When I try to do it in Eclipse, it's already giving me an error that it can't find an org.osgi.util.tracker exported by an other bundle. But when I ignore that error and export the bundles to jar files that isn't complaining. So then I try to run everything with
>java -jar concierge-1.0.0.jar
And I get the following error:
purging storage ...
INSTALLING shell.jar
INSTALLING service-tracker-1.0.0.RC2.jar
INSTALLING com.mgb.tidestation.serial_1.0.0.jar
INSTALLING com.mgb.tidestation.settings_1.0.0.jar
INSTALLING org.eclipse.swt.linux.x86_1.0.0.jar
INSTALLING com.mgb.tidestation.model_1.0.0.jar
INSTALLING com.mgb.tidestation.scpi_1.0.0.jar
INSTALLING com.mgb.tidestation.view_1.0.0.jar
STARTING file:./shell.jar
Concierge> STARTING file:./service-tracker-1.0.0.RC2.jar
STARTING file:./com.mgb.tidestation.serial_1.0.0.jar
TestSerialCommunication
Path: /usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.07/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
STARTING file:./com.mgb.tidestation.settings_1.0.0.jar
java.lang.ClassNotFoundException: Unsatisfied import org.util.osgi.tracker
at ch.ethz.iks.concierge.framework.BundleClassLoader.resolveBundle(BundleClassLoader.java:420)
With my init.xargs:
-init
-istart shell.jar
-istart service-tracker-1.0.0.RC2.jar
-istart com.mgb.tidestation.serial_1.0.0.jar
-istart com.mgb.tidestation.settings_1.0.0.jar
-istart org.eclipse.swt.linux.x86_1.0.0.jar
-istart com.mgb.tidestation.model_1.0.0.jar
-istart com.mgb.tidestation.scpi_1.0.0.jar
-istart com.mgb.tidestation.view_1.0.0.jar
So I do start and install the service-tracker is this necessary? Or should this all be done in an other way?
Thanks for all your help!
Jan Pannecoeck
Hello,
I've been able to solve this problem. Probably it was my own stupidity that caused this problem. I've no clue how I've solved it, I've just checked if everything was at the right place and after that it worked. So probably I was still missing some import line...
But now it's all working properly!
Thanks for your help!! Concierge OSGi is running now on an embedded device without any problems!
Kind regards,
Jan Pannecoeck
That's good news.
Cheers,
Jan.