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.

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!

44 Comments

  1. Glyn Normington:

    Thanks for the list of links - just the ticket!

    BTW why isn’t this blog entry in the Java category?

    Glyn

  2. Neil:

    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

  3. Yao Huang:

    Excellent tutorial on Eclipse Equinox. It is better to have a print version to the serials.

  4. Alex:

    Just started digging into OSGi when I came across your articles. Very clear and understandable, can’t wait for more. Thank you!

  5. Ian Skerrett:

    Great series Neil. When is the booking coming?

  6. Peter 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.

  7. Jutta 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

  8. Neil:

    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

  9. Asaf:

    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?

  10. Albert Strasheim:

    We want more! We want more! I’m really looking forward to Part 7. Thanks very much for this great series of articles.

  11. wolverine.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!

  12. Frederic 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

  13. Jay 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-

  14. Tensegrity:

    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:……

  15. Glyn Normington:

    Glad to see the DS tutorials emerging. Nice work Neil!

  16. John Brinnand:

    Great series of articles. Thanks.

    John

  17. Bruno:

    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

  18. Alex 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.

  19. Tolliver:

    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?

  20. Abhishek:

    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

  21. cyberman:

    Hi. Great tutorial!! Can you post a book about this that can help me??Thank’s a lot. Luigi.

  22. Neil:

    Thanks Luigi.

    Actually I am working on a book at the moment: see the announcement.

    Regards, Neil

  23. Douglas:

    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

  24. Simon 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!

  25. Sam 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.

  26. Tina:

    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.

  27. Santosh:

    Do you have any idea how do I read command line arguments inside an OSGI bundle.

  28. Chris 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!

  29. Sura 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

  30. Peter 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

  31. SK:

    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

  32. Maurizio 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?

  33. dracularking:

    i like it very much and introduced it to others, thank you very much for your great series

  34. Ragha:

    Hi,

    Book is excellent. I want to try with the examples but where can i get the source code ?

    regards ragha

  35. Using 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 [...]

  36. tony:

    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

  37. płatności internetowe:

    Book is excellent. I want to try with the examples but where can i get the source code ?

  38. Tish:

    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

  39. Luí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

  40. 3 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 [...]

  41. 3 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) [...]

  42. Baris Yilmaz:

    Thank you very much for sharing your great knowledge and experience, either in form of PDF or tutorials. We appreciate your help. Regards.

  43. Maven: 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 [...]

Leave a comment