Part 9 of my Galileo Reviews around Target Platforms. An Overview of this blog series can be found here.
This blog entry reports some problems and how to solve them:
- Use clauses
- No Schema Definition (Source Code Bundles not found)
- Reload problems
I like cycling with my bike, but developing OSGI applications I dont like cycles.
And if ever possible you should avoid cycles between bundles. But the world isn’t easy if you have to integrate 3rd party bundles and there are cycles.
What are cycles in this case ? An example is if you’re using SLF4J and Logback. We dont want to talk about the reason why there are cycles and if there’s a way to design it without cycles. Much discussion on this in the Logback-user mailing list. You can also look at my blog series about “Logging in OSGI applications“.
The Graph Plug-in Dependency View (see part 8 of the blog series) shows a cycle between slf4j.api and logback.classic (watch the arrows on both sides of the connection)
If you select a slf4j.api Bundle in your Plug-ins View, then right-click Open Dependencies:
The Plug-in Dependencies View (see part 8 of the blog series) is reporting “Cycles Detected“) and looking at the Dependency – tree you see:
slf4j.api has a dependency to logback.classic and logback.classic has a dependency back to slf4j.api.
The Toolbar of Plug-in Dependency View contains a “Show Cycles” Button:
Hitting this Button you get an information about the Cycles:
If you look at your Target Platform State View (see part 8 of the blog series) using a Search Filter “org.slf4j” you also see the cycling between Import Package Dependencies:
OK – you know you should avoid Cycles and the Plug-in Development Views we talked about the last blogs help you to detect Cycles and to analyze the reasons. Sometimes (in Eclipse – OSGI – universe) Buddy policy is used for bi-directional Dependencies.
Back to our example above:
Equinox has no problem to run OSGI Application with cycles. But if you try to wrap those 3rdParty Jars and Export the Bundle as deployable Plug-in using PDE in Ganymede an Error was reported if there’s a cycle detected. Galieo has a new option to allow PDE exporting Bundles containing cycles. We’ll talk later about this in my Galileo – PDE – Review blogs.
If Bundles with Cycles are in your workspace, then you run into some problems:
Oh – whats that: Cycle – Errors.
- Equinox as OSGI Framework runs Applications with cycles
- PDE (in Galileo) can export Bundles with cycles
- The Java Compiler reports Errors if Cycles detected ?
Don’t panic – open Eclipse – Preferences – Java – Compiler – Building:
set “Circular dependencies” to “Warning“:
Another Eclipse Preferences if dealing with cycles you’ll find under Eclipse – Preferences – Workspace – Build Order :
To avoid endless recursive builds, you set the max iterations – default is 10.
Now you can compile, deploy, run (launch), rebuild using cycles🙂
2. Use clauses
You know the Use-clauses ? HowTo calculate them using PDE ?
Open your MANIFEST editor:
Beside your Exported Packages (Runtime – tab) the “Calculate Uses” Button does the job. It may happen that you change code and exported packages but forget to hit the “Calculate Uses” button – then the Use-clauses are wrong. (There’s already a discussion to calculate them automatically if MANIFEST file was saved.)
If the Use-clauses are wrong, then Equinox cannot resolve the Plug-in (bundle) and you get an error. Here’s an example how the error is reported from “Target Platform State” View (see part 8 of this blog series).
If its your own bundle then you know how to fix it: Open MANIFEST, “Calculate uses” again and save.
But what to do if its a 3rd Party bundle ? You can repair and wrap it or report this as a bug to the bundle – provider and edit your eclipse.ini.
if you insert into your eclipse.ini:
and restart Eclipse the bundles is resolved, because now Equinox ignores all use-clauses.
BTW: If dealing with large Target Platforms you’ll also notice a much faster startup-time because Equinox has nothing to do with all the use-clauses. But attention: you loose the control to get errors if your own use-clauses are wrong, so dont forget to start without the clause before deploying your own plug-ins.
Duplicate Bundles: Duplicates in Target Platform definitions were sometimes problematic in Ganymede, but not in Galileo🙂 It doesnt matter getting some duplicate plug-ins (bundles) if you perhaps get content from two overlapping software update sites. Behind the scene P2 stores all into the bundle_pool (see part 8 of the series) – this means if one bundle is already there, this won’t be downloaded a second time. The most important to know for you: Equinox can deal with duplicate bundles.
Duplicate Fragments: Maybe if same fragments are from some different sources, then Equinox reports this error:
you can just ignore this error: Equinox only reports that another fragment was selected.
Duplicate Package exports: This is no problem – its up to OSGI to choose one of the bundles exporting the package. If you’re creating Launch Configs its up to you to select the right bundles so OSGI can choose the right ones for Runtime – classpath. But while developing (and compiling) against a Target Platform there may be some conflicting situations where automatic – wiring fails and chooses (from your POV) the wrong bundle in Development – classpath.
But as always: PDE is flexible and you can tell Equinox, which bundle should be used. Open your MANIFEST,
…go to Dependencies tab, at the left bottom you’ll find “Automated Management of Dependencies“. Simply add the bundle you want Equinox to choose in Development classpath. Save and you’re done. the good thing: this is only used while development and nothing was written into your MANIFEST file.
BTW: I’ll talk in more detail about “Automated Management of Dependencies” in my upcoming PDE – Galileo – Reviews. …stay tuned…
4. No Schema Definition
While following the Milestones and nightly builds from Ganymede of course I made many changes to my Target Platform definitions. Suddenly I was surprised about this warning:
uups: no schema found ? I know, that to get the schemas I need the Source Bundles, but the Source Bundles are part of my Target Platform.
The reason was, that some time ago I had Bundles without Source Bundles in my Target Platform and later I added another location including Source Bundles. This causes the trouble – eclipse was confused and chooses plug-ins without corresponding source bundles.
This is a bug (bugzilla 279495) – and this is the workaround if this should happen to you: after restart eclipse you have to reload the Target Platform. (Preferences – Target Platform – reload
5. Reload problems
While testing the Galileo Nightly builds I used the staging update site. As galileo was released, the staging site wasn’t available anymore.
If then doing a reload of your Target Platform, the site wasn’t found and the selected content was empty.
You should always have in mind, that Update sites can go away and to store your Target definitions in workspace under source control to have a backup and “remember” what you selected.
We have talked much about IDE and Target Platform, but sometimes there’s something between – you enter the twilight zone😉 Lets talk in the next blog entry about the pseudo-runtime SWTDesigner is building while creating a preview without launching a real Launch configuration.