Referencing o.e.osgi packages w/o creating clash with Felix

111 views
Skip to first unread message

Alain Picard

unread,
Jun 14, 2018, 9:52:43 AM6/14/18
to bndtools-users
As part of our move from PDE to Bnd, we are trying to also remove any hard dependencies to Equinox, as suggested in the talk from Juergen Albert from EclipseCon 2017 and given that Felix should be first with DS 1.4.

We make heavy use of some basic eclipse osgi classes to manage status (IStatus, Status, MultiStatus) and all of our i18N such as NLS, etc. Some of these classes are for example in o.e.osgi and o.e.equinox.common. From Juergen's video, it is clear that OSGI doesn't allow 2 framework to run and that a require-bundle of o.e.osgi makes it non portable. But I'm trying to simply add o.e.osgi as a run requirement, but in Felix it fails with:

Failed to start bundle org.eclipse.osgi-3.8.2.v20130124-134944, exception activator error org.eclipse.osgi.framework.internal.core.SystemBundleActivator cannot be cast to org.osgi.framework.BundleActivator from: org.apache.felix.framework.Felix:createBundleActivator#4512
org
.osgi.framework.BundleException: Activator start error in bundle org.eclipse.osgi [18].
    at org
.apache.felix.framework.Felix.activateBundle(Felix.java:2290)
    at org
.apache.felix.framework.Felix.startBundle(Felix.java:2146)
    at org
.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
    at aQute
.launcher.Launcher.startBundles(Launcher.java:517)
    at aQute
.launcher.Launcher.activate(Launcher.java:423)
    at aQute
.launcher.Launcher.run(Launcher.java:301)
    at aQute
.launcher.Launcher.main(Launcher.java:147)
Caused by: java.lang.ClassCastException: org.eclipse.osgi.framework.internal.core.SystemBundleActivator cannot be cast to org.osgi.framework.BundleActivator
    at org
.apache.felix.framework.Felix.createBundleActivator(Felix.java:4512)
    at org
.apache.felix.framework.Felix.activateBundle(Felix.java:2221)
   
... 6 more

What is the solution to this ? Is there a clever way to make these packages available without forcing a clash?

Thanks
Alain

Peter Kriens

unread,
Jun 14, 2018, 9:59:23 AM6/14/18
to via bndtools-users
I am not sure what you’re setup is but it sure looks like a wet dream of a masochist … :-)

I have very good experiences with a setup where one project in the workspace exports these ‘orphan’ packages. This is quite trivial in bnd. Just put the source (for example the equinox framework) on your -buildpath and then do Export-Package for ONLY those packages that you really depend on.

I strongly advice not to solve this with any class loader hacks. OSGi can be as sweet as a sirens song but it is a dragon when you try to make it do something it was not designed to do. And hussling multiple frameworks in one class it was not designed to do.

Kind regards,

Peter Kriens

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alain Picard

unread,
Jun 14, 2018, 10:01:32 AM6/14/18
to bndtool...@googlegroups.com
Wow, that sounds so trivial, thanks for the quick pointer.

Alain

Peter Kriens

unread,
Jun 14, 2018, 10:08:14 AM6/14/18
to via bndtools-users
It actually is … I’ve a customer where we had a greenfield application that we could setup in the ideal way for bndtools and OSGi. A separate API project and service APIs between all bundles. It really works fantastic and there are multiple products based on this code base now. When we started the team did not even have any Java experience …

Most of the problems I see people are having with OSGi is because they run into the brick wall of modularity because they focus on a shortcut or want to do it the way they always did it.

Ah well, good luck. Kind regards,

Peter Kriens

Neil Bartlett

unread,
Jun 14, 2018, 10:08:38 AM6/14/18
to bndtool...@googlegroups.com
Another possibility exists, in case you find yourself going down a deep rabbit hole of wrapping more and more packages from Eclipse:

IStatus, Status, and MultiStatus are all in the bundle 'org.eclipse.equinox.common'. That bundle does not Require-Bundle:org.eclipse.osgi, but it does import several packages like org.eclipse.equinox.log, org.eclipse.osgi.util, etc. In Eclipse these packages are exported by the system bundle, but in Felix you can install a bundle named org.eclipse.equinox.supplement, which should export everything you need. The supplement bundle is specifically intended for this purpose: exporting Equinox packages on a non-Equinox framework implementation.

Neil

Peter Kriens

unread,
Jun 14, 2018, 10:10:03 AM6/14/18
to via bndtools-users
Ah, that is even better. But isn’t that that bundle that is always so hard to find?

Kind regards,

Peter Kriens

Neil Bartlett

unread,
Jun 14, 2018, 10:14:55 AM6/14/18
to bndtool...@googlegroups.com
True, Equinox bundles are not always available on Maven Central. Though in this case it looks like there is a relatively recent version available, from Oct 2018.

It can also be downloaded directly from here (expand the twisty next to "Add-on Bundles"): http://download.eclipse.org/equinox/drops/R-Oxygen.3a-201803300640/index.php

On Thu, Jun 14, 2018 at 3:09 PM, Peter Kriens <peter....@aqute.biz> wrote:
Ah, that is even better. But isn’t that that bundle that is always so hard to find?

Kind regards,

Peter Kriens


On 14 Jun 2018, at 16:08, Neil Bartlett <njbar...@gmail.com> wrote:

Another possibility exists, in case you find yourself going down a deep rabbit hole of wrapping more and more packages from Eclipse:

IStatus, Status, and MultiStatus are all in the bundle 'org.eclipse.equinox.common'. That bundle does not Require-Bundle:org.eclipse.osgi, but it does import several packages like org.eclipse.equinox.log, org.eclipse.osgi.util, etc. In Eclipse these packages are exported by the system bundle, but in Felix you can install a bundle named org.eclipse.equinox.supplement, which should export everything you need. The supplement bundle is specifically intended for this purpose: exporting Equinox packages on a non-Equinox framework implementation.

Neil

Peter Kriens

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

Neil Bartlett

unread,
Jun 14, 2018, 10:15:19 AM6/14/18
to bndtool...@googlegroups.com
Err I mean Oct 2017...

Alain Picard

unread,
Jun 14, 2018, 10:19:45 AM6/14/18
to bndtool...@googlegroups.com
That is probably even better, I'll check it out. Thank you so much.

Alain


Peter Kriens


Peter Kriens

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

Alain Picard

unread,
Jun 14, 2018, 10:25:33 AM6/14/18
to bndtool...@googlegroups.com
It took only a few minutes and was totally painless, thanks Neil and Peter

Alain 

Reply all
Reply to author
Forward
0 new messages