6

I have been trying to start with studying OSGI for quiet a few days now. I've tried many tutorials to work on eclipse especially to start with apache felix or Equinox but the step by step tutorials never take me to the end of creating even one bundle.

I even tried the console commands with no luck. Is OSGI out dated? All the tutorials on the alliance web site are also extremely old and I couldn't follow them to the end. I also tried the BndTools Totorial here but on eclipse it couldn't resolve "@Component" when I reach 4.3 so I stopped there. When following Osgi Book Preview, I also couldn't find "Make Bundle" so I stopped again. I'm really frustrated. Isn't there a way for beginners to get into OSGI?

UPDATE:

For other people who are interested in getting started with OSGI, I found the book Osgi in Action as very helpful and a good guide for beginners.

Excite
  • 484
  • 1
  • 5
  • 19
  • Could you please report the detail of the problem with the bndtools tutorial? We would really like to fix this. Thanks. – Neil Bartlett Apr 19 '14 at 09:31
  • In bndtools tutorial 'section 4.3 Write an implementation' part. In "ExampleComponent" class code, 'import aQute' and '@Component' could not be resolved & it shows error. So in section 4.4 the "Junit test" couldn't run. It runns when I comment out those 2 lines. In section 4.5, in the generated bundle org.example.impls.provider.jar, does not contain OSGI-INF/....xml rather it contains OSGI-OPT/src/org/example/ExampleComponent.java (I don't know if this has effect in building the bundle). Finally .. – Excite Apr 19 '14 at 11:53
  • in section 5, when I click 'Run OSGI' inside the run.bndrun editor an error pops up saying 'No OSGi framework has been added to the run path' followed by other warnings such as 'cannot find/error/osgi.cmpn;version=0 Not found in...' and others. I try to search osgi.cmpn under source repository but there is nothing under the "source" repository. It's empty – Excite Apr 19 '14 at 11:53
  • It sounds like the repository configuration has an error, this would be the reason that no classes or bundles can resolve. I'd like to help, can you contact me directly (nbartlett@fastmail.net) or use the Bndtools mailing list(http://bndtools.org/community.html)? Many thanks! – Neil Bartlett Apr 19 '14 at 11:55
  • For those people who had a problem on proceeding with 'Bndtools' tutorial, if you were having the same problem as I had, I was suggested to look at here. In short inside 'eclipse.ini' insert "-Djsse.enableSNIExtension=false after “-vmargs” line. This solved my problem and resolved the errors. Thank you Mr. Schneider & Mr. Pishchukhin, I have not finished the other tutorials you suggested but they are well documented and I'll go through them once I'm done with the BndTools. – Excite Apr 19 '14 at 23:35

6 Answers6

3

The Bndtools tutorial was mentioned and dismissed in the original question; however we were able to resolve the issue. So I post this as an answer for others who might be looking for an introductory OSGi tutorial: check out the Bndtools Tutorial!

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77
3

Actually there are two questions being posed here, which I asked myself recently as well, one in the title and one in the content. The question in the title seems mostly rhetorical. It expresses a notional answer for the real question that you find at the end of the text: "I'm really frustrated. Isn't there a way for beginners to get into OSGI?"

Answer: There are ways, but they aren't as easy as they should be. The "update" to the question mentions "OSGi in Action". This is a good book (which I discovered too late, it's not really on the top of the search results), but quite outdated with respect to tooling (e.g. Bndtools appears in the appendix only).

Finding no easy way for beginners, I eventually started to dig my way through the topic using an eclectic selection of resources found on the web. I documented my experience in what you might call a log of my (ongoing) journey in the hope that it may be helpful to others. I'll leave it to you to judge whether this can be considered a shy "yes" to the question, after all.

Not having reached "the end of my journey" yet, I'm not perfectly sure why there are so few up-to-date resources for beginners to get into OSGi. I suppose that the attention that OSGi got from a lot of people because it was used in Eclipse was one of the first problems. The attempt of the OSGi alliance to align with enterprise edition features was another (there are references for this, but I'm not allowed to post more than 2 links). Both incidents led first to hype (and lots of articles) and then to disappointment. In the time following, experts understood the technology better and better and applied it successfully to the problem domains where it is of use. (And these are fewer than the initial hype suggested -- or different, OSGi may regain some attention with the IoT.) But as it is often the case in such cases, the (now) experts never felt tempted to write the kind of introductions that you find during the hype-phase of a new technology.

Which brings me back to the question from the title, after all: "Is there a new standard?" (which implies whether it is worth to spend time on looking into OSGi). The answer depends on what aspects of OSGi are important to you. Project JigSaw aims to bring modules to the Java platform and to developers. With a target date of March 2017 for the central JSR 376 I'd say this might be called an "upcoming standard" (provided it gets finished). But OSGi is more than just modules. Other key features are dynamic configuration (I can't see any competing standard regarding this feature) and micro-Services (be careful about that term, it seems to have two different interpretations currently). Eventually, you have to look a bit into OSGi yourself to decide on its usefulness for your project.

Michael Lipp
  • 341
  • 3
  • 8
2

You can check tutorials that help you start with OSGi OSGi Tutorial: From project structure to release and OSGi Tutorial: 4 ways to activate code in OSGi bundle

Dmytro Pishchukhin
  • 2,369
  • 1
  • 14
  • 19
2

There's a lot of outdated tutorials out there, outdated documentation, and stuff which is deep in the Java EE thinking bog - incomprehensible if you're not familiar with the problems arising from the solution to the problems arising from the solution to some obscure Java decision in the previous millennium, which you're now stuck with in your mammoth EE app.

Today, there is the OSGi enRoute projects which provides a set of pretty nice tutorials, along with an OSGi "distribution" which makes dependency resolution easier. My understanding is that a lot of the additional services in enRoute are en route (ha!) to becoming the OSGi Release 7 standard.

If you want to do new development in OSGi, it's what I would go to for sure. In fact, even if you want to use OSGi in some legacy-support function, I'd read up on the enRoute way first, before getting into all the ugly compromises needed for legacy's sake.

  • As of 2019 this remains the correct answer to the question, though I think the enRoute tutorials may have changed a little since this answer was posted. Currently they present a Maven-centric approach. These are the "official" OSGi endorsed beginner tutorials. That said, the Bndtools tutorials mentioned elsewhere are by no means out of date and may be preferred by users who prefer to work with Gradle. – Elias Vasylenko Feb 07 '19 at 16:13
1

If you are mainly looking for server side OOGi then using maven and the maven bundle plugin works very well. See http://www.liquid-reality.de/display/liquid/2011/02/15/Karaf+Tutorial+Part+1+-+Installation+and+First+application

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
1

Apache Karaf is an OSGi container that I believe makes OSGi, 'easier,' to understand and work with. You might consider getting this installed and just try it out. Documentation is pretty good as well. Take some time learning about a running OSGi container; watch it run first trying out a few commands and then deploy some simple bundles while putting a tail on the karaf.log.

Seeing Karaf running will help you understand more about OSGi and what it takes to get a bundle built and deployed/running.

IMHO: Both BndTools and Maven Bundle plugin are fantastic resources for OSGi development.

Tony
  • 345
  • 1
  • 4
  • 11