Getting Started with OSGi
The following is a list of links to my tutorial series Getting Started with OSGi which is currently running on EclipseZone.
Unfortunately on EclipseZone the new posts push the older ones off the front page, so if you want to refer back to an earlier item in the series then you have to go digging through the forums. Therefore for convenience I will be maintaining links to all parts of the series on this page.
- Part 1: Your first bundle (PDF)
- Part 2: Interacting with the Framework (PDF)
- Part 3: Dependencies between Bundles
- Part 4: Registering a Service
- Part 5: Consuming a Service
- Part 6: Dynamic Service Tracking
- Part 7: Introducing Declarative Services
- Part 8: Declarative Services and Dependencies
You may also be interested in my more advanced article, A Comparison of Eclipse Extensions and OSGi Services (PDF).
If you have any feedback on any of these articles, please either comment below or on the relevant EclipseZone thread. Thanks!


Glyn Normington:
Thanks for the list of links - just the ticket!
BTW why isn’t this blog entry in the Java category?
Glyn
February 21, 2007, 2:17 pmNeil:
Thanks Glyn. This is a “page” rather than a “post”, because it lives outside the timeline of blog posts. It doesn’t seem to be possible in Wordpress to add a category to a “page”. At least, I can’t work out how to do it!
Neil
February 21, 2007, 3:12 pmYao Huang:
Excellent tutorial on Eclipse Equinox. It is better to have a print version to the serials.
February 21, 2007, 9:45 pmAlex:
Just started digging into OSGi when I came across your articles. Very clear and understandable, can’t wait for more. Thank you!
February 22, 2007, 7:09 amIan Skerrett:
Great series Neil. When is the booking coming?
February 27, 2007, 7:38 pmPeter Muys:
Hello Neil, I think you have made a very clean and nice introduction on using osgi. In fact, I think I will use this in my own application.
Thanks.
March 13, 2007, 3:23 amJutta Albrecht:
Hi Neil,
thanks a lot for this excellent introduction to OSGi services! Do you plan by any chance to add a post about Declarative Services as well?
Regards Jutta
March 28, 2007, 2:04 pmNeil:
Hi Jutta,
Thanks for your comment. Yes, I plan to talk about Declarative Services. Sorry for the break in service - there will be more soon.
Regards, Neil
March 28, 2007, 2:09 pmAsaf:
I am new to OSGi so bare with me
I have a couple of Questions:
1.. What are the prerequisites for running OSGi bundles? Does it require the JVM to bootstrap the bundles directly (like it shows in Part 1)? Or is it possible to load the OSGi framework within an existing JVM (in my own main() function)? 2.. I am developing a web application and running it on a Tomcat 5.5 server I found the following link: http://www.eclipse.org/equinox/server/httpincontainer.php and couldn’t figure out whether its possible or not to load OSGi bundles under an already existing web application?
April 5, 2007, 6:58 pmAlbert Strasheim:
We want more! We want more! I’m really looking forward to Part 7. Thanks very much for this great series of articles.
April 8, 2007, 10:42 amwolverine.my:
Can you also touch a little bit on logging? How do I log the bundle’s messages and the best practise of logging?
In addition, it would be good to describe how a bundle will read the resource, e.g. reading the configuration from XML or Properties.
I’m looking forward the next coming tutorials!
Thank you!
April 13, 2007, 1:44 amFrederic Esnault:
Hi Neil !
Thanks for the great work with OSGi tutorials on EclipseZone, I enjoyed each one of them. I also read your excellent article about comparison of extensions and services.
I am currently looking for a good tutorial about Eclipse Equinox extension and extension points. Are you planning something about this?
thanks again! Frederic
April 17, 2007, 10:02 amJay Simonini:
Neil:
No matter how well conceived and constructed a framework is, it will fail without some sort of social boot strap! Your articles are serving in this very vital capacity.
One of the reasons that the Spring Framework has been so successful is the abudenent, high quality, documentation, user forums and books.
When evaluating new technology paradigms for my team, company or enterprise, ease of use, learning curve and availablity of documentation play a huge part in getting management buy-in.
Thank you for taking some of the sting out of learning what looks to be an emergent and highly important advancement in the way that both client and server applications can by crafted, deployed and managed.
-jay-
May 10, 2007, 1:30 amTensegrity:
OSGi Tutorials…
Neil has put up a summary of the parts of his excellent OSGi tutorials at the EclipseZone. Part 1: Your first bundle Part 2: Interacting with the Framework Part 3: Dependencies between Bundles Part 4: Registering a Service Part 5:……
June 1, 2007, 5:22 pmGlyn Normington:
Glad to see the DS tutorials emerging. Nice work Neil!
June 4, 2007, 12:47 pmJohn Brinnand:
Great series of articles. Thanks.
John
June 11, 2007, 7:01 pmBruno:
dear Neil, we are following your osgi tutorial, but in the lesson: Dependencies between Bundles we obtain the error show below. we have made all the previous instructions without errors. can you help us please.
C:Osgi>javac -classpath MovieInterface.jar osgitut/movies/impl/BasicMovieFinder Impl.java osgitutmoviesimplBasicMovieFinderImpl.java:5: cannot find symbol symbol: class MovieFinder public class BasicMovieFinderImpl implements MovieFinder ^ osgitutmoviesimplBasicMovieFinderImpl.java:7: cannot find symbol symbol : class Movie location: class osgitut.movies.impl.BasicMovieFinderImpl private static final Movie[] MOVIES = new Movie[] { ^ osgitutmoviesimplBasicMovieFinderImpl.java:12: cannot find symbol symbol : class Movie location: class osgitut.movies.impl.BasicMovieFinderImpl public Movie[] findAll() { return MOVIES; } ^ osgitutmoviesimplBasicMovieFinderImpl.java:7: cannot find symbol symbol : class Movie location: class osgitut.movies.impl.BasicMovieFinderImpl private static final Movie[] MOVIES = new Movie[] { ^ osgitutmoviesimplBasicMovieFinderImpl.java:8: cannot find symbol symbol : class Movie location: class osgitut.movies.impl.BasicMovieFinderImpl new Movie(”The Godfather”, “Francis Ford Coppola”), ^ osgitutmoviesimplBasicMovieFinderImpl.java:9: cannot find symbol symbol : class Movie location: class osgitut.movies.impl.BasicMovieFinderImpl new Movie(”Spirited Away”, “Hayao Miyazaki”) ^ 6 errors
June 19, 2007, 6:43 pmAlex Zhang:
Very nice series, Neil! The DS ones are really exciting. We are using these tutorials for internal training. I also read your comparison of Eclipse extension and OSGi services… cleared a lot of confusions I had about plugins and osgi. One particular question:
We have a few core business bundles that we would like to use in both an RCP application and a web service. Is it possible to use one set of DS configuration between these core bundles in both cases? If so, would you mind giving an example, maybe in your upcoming series, showing how may this be done? Thanks a lot.
June 25, 2007, 2:18 amTolliver:
Very nice. Could you put all entries as the series online as pdf? Printing out the EclipseZone Html just doesn’t work.
I know it is off-topic, but every website and blog run by a single person has some “print-version” button - only JavaLobby/Eclipsezone doesn’t. Any clue why that is?
September 9, 2007, 12:14 pmAbhishek:
Fantastic series of articles, very useful and a must-read for OSGi beginners. Thanks a lot Neil !!
i had a question: If a bundle Y is using a service of a bundle X, and i do “update X” on the OSGi console, bundle Y loses its reference to X. What is the prescribed way in which Y should handle this situation? i assume this will be done via Listeners, but what exactly should be done? The only way i could get Y to work properly was by updating Y itself in the Listener when X reregistered. But what is the prescribed way of handling this situation?
TIA, -abhishek
September 21, 2007, 10:43 amcyberman:
Hi. Great tutorial!! Can you post a book about this that can help me??Thank’s a lot. Luigi.
January 14, 2008, 10:48 amNeil:
Thanks Luigi.
Actually I am working on a book at the moment: see the announcement.
Regards, Neil
January 14, 2008, 11:10 amDouglas:
Hey Neil! Great series on OSGi bundles! I have great interest in using OSGi R4 implementations, but what I really miss is a tutorial on a tool to create bundles. I heard Maven (with extensions) does it, and also that there are some Ant tasks with Knopflerfish, but I really need a walkthrough to a complete bundle write and build cycle to get started. (BTW, I’m not considering Eclipse PDE development because I really need something that can be automated — ant or maven would fit nicely). Any pointers? Cheers, Doug
January 16, 2008, 2:05 pmSimon Kelly:
Hi Neil, thanks for the great articles, really got me going on OSGi. One thing that I am really struggling to info on is how to integrate OSGi into an existing application. I’ve gotten as far us using org.eclipse.core.runtime.adaptor.EclipseStarter to get a BundleContext which I can use to install bundles etc.
Do you know of any info that would give me a head start here?
Thanks much!
February 23, 2008, 3:54 pmSam Kass:
Hi Neil, thanks from me also on the great articles. They’ve been a real help in bootstrapping my understanding.
I would love to see an article covering configuration issues. I understand ConfigurationAdmin is the way to go, and that there exist control panels and JMX interfaces and such for it (Felix seems to be ahead of Equinox in that regard, but it’s all one big happy OSGi family, right?) Now that I’ve begun moving a desktop Java application from an old custom monolithic pattern to OSGi, I’m having to transition from command-line arguments to something else and it’s tricky. A tutorial would be wonderful.
March 3, 2008, 9:30 pmTina:
Thank you for your excellent series on OSGI. I’ve been recommending your tutorials and now the draft chapters of your book to new team members.
Do you, by chance, have any pointers to the use of factories (Service and Component) for declarative services? I’m having difficulty translating the spec into actionable code, and have had no luck in my various searches for samples.
April 24, 2008, 1:37 pmSantosh:
Do you have any idea how do I read command line arguments inside an OSGI bundle.
May 9, 2008, 11:10 amChris Kwon:
Hi Neil,
I finished translating your articles to Korean. Also, I uploaded Korean version of PDF files to my blog.
http://xguru.net/blog/451.html ( for Korean readers )
Thanks!
May 12, 2008, 11:41 pmSura Ozdemir:
Dear Neil,
I am so sorry since my account has kind of problem that I haven’t posted in your article.I am a student working on osgi and I have done whatever you follow but I haven’t seen [java.lang.Runnable] service others are working meanly bundles…are okey and run..
What may you think about the problem ?
http://www.eclipsezone.com/eclipse/forums/t96740.html
July 21, 2008, 1:53 pmPeter Götz:
Hi Neil,
I tried to answer directly at the part of the series, but EclipseZone doesn’t seem to want to let me login.
I have tried to follow your guide and it worked out quite nicely - at first.
In article 4 I had problems starting my bundle. I have not used the names and packages you used and therefore the mistake is mine. But I don’t understand it. I have chosen the same package for my interface, the implementation and the activator class. This results in a ClassNotFoundException when starting the bundle. I moved the activator and implementation class to an .impl package and everything worked fine. Can you please explain why this is? I have not changed the import packages in the manifest file, only the bundle-activator package (of course, otherwise it wouldn’t work at all.
).
Thank you very much for your help and keep up the good work!
Peter
August 21, 2008, 12:16 pmSK:
Neil,
Nice compilation on OSGI. I started getting to know on OSGI recently. I wish to know how OSGI helps in ‘remote management’ with respect to embedded environment. Kindly provide me if you know any links on the same.
Thanks SK
September 6, 2008, 3:45 pmMaurizio St:
Hi Neil,
I’m your supporter!!!
I have a problem with Classloader:
java.lang.ClassLoader.loadClass(Unknown Source)
The classes that I want to open are inside the bundles!
Can you help me, please?
September 11, 2008, 8:37 amdracularking:
i like it very much and introduced it to others, thank you very much for your great series
December 9, 2008, 7:55 amRagha:
Hi,
Book is excellent. I want to try with the examples but where can i get the source code ?
regards ragha
December 29, 2008, 1:39 pmUsing OSGi Services in an existing RCP Application « Mike’s Very Occasional Blog:
[...] with dependencies. There are great links to deal with all of this, in particular those supplied by Neil Bartlett. However it is not at all clear how to use declaratively declared services in an existing GUI [...]
January 23, 2009, 3:19 pmtony:
OSGi: The Dynamic Module System for Java - This intensive 4-day course delivered by Neil on will give you a thorough grounding in the core principles of OSGi, the Dynamic Module System for Java. - Guys seats are filling up fast.contact tony at skills matter if you have any queries about the workshop- 02071072620
February 27, 2009, 9:31 pmpłatności internetowe:
Book is excellent. I want to try with the examples but where can i get the source code ?
March 18, 2009, 9:11 pmTish:
Neil, This is one of the best tutorials I’ve seen out there. Not just on OSGi, but on anything. I love that I don’t have to install and configure 10 appliances before I’m able to start the tutorial. I love that I don’t need Maven or svn or eclipse or plugins or anything else. I’ve been able to run through the 1st 3 tutorials in under 20 minutes and I really feel like I’m learning something. I’m even taking notes! Thank you, thank you! Sincerely, Grateful follower
June 18, 2009, 7:41 pmLuís Carlos Moreira:
Book is excellent. Good ! Made in Brazil
Luís Carlos Moreira da Costa Eclipse RAP, RCP, GMF, eRCP and Pentaho Developer tcljava@gmail.com
June 23, 2009, 6:10 pm3 variations on OSGi themes: part 5 « CodingAndBeyond:
[...] practical introduction to DS can be found in Neil Bartlett’s ‘point-free blog’ (see Getting Started with OSGi, parts 7, 8). Reference implementation of DS is provided by Equinox OSGi (see Equinox bundles), so [...]
July 22, 2009, 10:38 pm3 variations on OSGi themes « CodingAndBeyond:
[...] practical introduction to DS can be found in Neil Bartlett’s ‘point-free blog’ (see Getting Started with OSGi, parts 7, 8). Reference implementation of DS provided by Equinox OSGi (see Equinox bundles) [...]
July 25, 2009, 12:48 amBaris Yilmaz:
Thank you very much for sharing your great knowledge and experience, either in form of PDF or tutorials. We appreciate your help. Regards.
September 22, 2009, 11:45 pmMaven: the way forward « www.jillesvangurp.com:
[...] packages were a mistake, which is now widely acknowledged. .Net namespaces are arguably better and OSGi bundles with explicit required and provided APIs as well as API versioning are better still. To [...]
October 24, 2009, 9:06 amMy first look at OSGi | DiversIT Europe:
[...] Getting started with OSGi [...]
November 26, 2009, 10:11 am