OSGi Manifest headers

3 views
Skip to first unread message

rwallace

unread,
Apr 11, 2009, 2:43:02 AM4/11/09
to guiceyfruit
Hey guys,

Great work getting the Guice 2.0 Mavenized and doing the work on all
the extensions. One thing that is missing are OSGi manifest headers.
Stuart did a bunch of excellent work getting Guice to be usable in an
OSGi environment and I very much want to use the guice-all jar you all
have, but I need it to be a proper OSGi bundle. Any reason you
haven't already done this or is it just something you haven't gotten
around to?

Rich

James Strachan

unread,
Apr 14, 2009, 9:45:54 AM4/14/09
to guice...@googlegroups.com
2009/4/11 rwallace <rwalla...@gmail.com>:

> Hey guys,
> Great work getting the Guice 2.0 Mavenized and doing the work on all
> the extensions.

Thanks!

> One thing that is missing are OSGi manifest headers.

Yeah good point. I've raised issues for this...
http://code.google.com/p/guiceyfruit/issues/detail?id=17
http://code.google.com/p/guiceyfruit/issues/detail?id=18


> Stuart did a bunch of excellent work getting Guice to be usable in an
> OSGi environment and I very much want to use the guice-all jar you all
> have, but I need it to be a proper OSGi bundle.  Any reason you
> haven't already done this or is it just something you haven't gotten
> around to?

BTW we recently ditched our painful to maintain svn/svm/svk mirror of
Guice and just started using regular guice created jars (using Guice's
Ant build to avoid the maintenance pain of keeping the mvn build
working). e.g. dealing with the jarjar stuff that Guice does to rename
google collections & cglib into its own package structure etc.

Though due to one or two issues not being addressed yet in trunk of Guice
http://code.google.com/p/google-guice/issues/detail?id=354
http://code.google.com/p/google-guice/issues/detail?id=351

the 2.0-beta-6 release went out with a patched Guice. To check if it
was easy to do I've created a mirror of Guice on github...
http://github.com/jstrachan/guicey/tree/master

which we can use for 2.0-beta-7 of GuiceyFruit. So I can easily add in
any OSGi manifest stuff to the Guice jars in that release.

Do you have a link to the work Stuart did adding OSGi metadata to the jars?

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Richard Wallace

unread,
Apr 14, 2009, 7:07:54 PM4/14/09
to guice...@googlegroups.com
On Tue, Apr 14, 2009 at 6:45 AM, James Strachan
<james.s...@gmail.com> wrote:
> BTW we recently ditched our painful to maintain svn/svm/svk mirror of
> Guice and just started using regular guice created jars (using Guice's
> Ant build to avoid the maintenance pain of keeping the mvn build
> working). e.g. dealing with the jarjar stuff that Guice does to rename
> google collections & cglib into its own package structure etc.
>
> Though due to one or two issues not being addressed yet in trunk of Guice
> http://code.google.com/p/google-guice/issues/detail?id=354
> http://code.google.com/p/google-guice/issues/detail?id=351
>
> the 2.0-beta-6 release went out with a patched Guice. To check if it
> was easy to do I've created a mirror of Guice on github...
> http://github.com/jstrachan/guicey/tree/master
>
> which we can use for 2.0-beta-7 of GuiceyFruit. So I can easily add in
> any OSGi manifest stuff to the Guice jars in that release.
>

Awesome, I was thinking of doing something similar because I want to
get some other patches around OSGi support applied to the jars I'm
using. Specifically,

http://code.google.com/p/google-guice/issues/detail?id=311
http://code.google.com/p/google-guice/issues/detail?id=337
http://code.google.com/p/google-guice/issues/detail?id=343

With your stuff now on github that should be much much easier. :)

> Do you have a link to the work Stuart did adding OSGi metadata to the jars?
>

Absolutely, http://code.google.com/p/google-guice/issues/detail?id=121

Thanks,
Rich

James Strachan

unread,
Apr 15, 2009, 1:45:19 PM4/15/09
to guice...@googlegroups.com
2009/4/15 Richard Wallace <rwalla...@gmail.com>:

>
> On Tue, Apr 14, 2009 at 6:45 AM, James Strachan
> <james.s...@gmail.com> wrote:
>> BTW we recently ditched our painful to maintain svn/svm/svk mirror of
>> Guice and just started using regular guice created jars (using Guice's
>> Ant build to avoid the maintenance pain of keeping the mvn build
>> working). e.g. dealing with the jarjar stuff that Guice does to rename
>> google collections & cglib into its own package structure etc.
>>
>> Though due to one or two issues not being addressed yet in trunk of Guice
>> http://code.google.com/p/google-guice/issues/detail?id=354
>> http://code.google.com/p/google-guice/issues/detail?id=351
>>
>> the 2.0-beta-6 release went out with a patched Guice. To check if it
>> was easy to do I've created a mirror of Guice on github...
>> http://github.com/jstrachan/guicey/tree/master
>>
>> which we can use for 2.0-beta-7 of GuiceyFruit. So I can easily add in
>> any OSGi manifest stuff to the Guice jars in that release.
>>
>
> Awesome, I was thinking of doing something similar because I want to
> get some other patches around OSGi support applied to the jars I'm
> using. Specifically,
>
> http://code.google.com/p/google-guice/issues/detail?id=311
> http://code.google.com/p/google-guice/issues/detail?id=337
> http://code.google.com/p/google-guice/issues/detail?id=343
>
> With your stuff now on github that should be much much easier. :)

I'm just atttempting to apply these now; have done 311 and 343 - will
report back when they're all done...

>> Do you have a link to the work Stuart did adding OSGi metadata to the jars?
>>
>
> Absolutely, http://code.google.com/p/google-guice/issues/detail?id=121

BTW form the comment it looks like this patch has already been applied
(in June 08)?

James Strachan

unread,
Apr 15, 2009, 2:05:05 PM4/15/09
to guice...@googlegroups.com
2009/4/15 James Strachan <james.s...@gmail.com>:

It seems 337 is a bit out of date - do you fancy figuring out a new patch?
http://code.google.com/p/google-guice/issues/detail?id=337

It might be easier to clone my git repo and fix it there then I can
easily pull in your changes?
http://github.com/jstrachan/guicey/tree/master

>>> Do you have a link to the work Stuart did adding OSGi metadata to the jars?
>>>
>>
>> Absolutely, http://code.google.com/p/google-guice/issues/detail?id=121
>
> BTW form the comment it looks like this patch has already been applied
> (in June 08)?

Does patch 311 work with the 121 patch? It looks from 121 that BND is
being used to generate the OSGi metadata?

Richard Wallace

unread,
Apr 15, 2009, 2:07:10 PM4/15/09
to guice...@googlegroups.com
On Wed, Apr 15, 2009 at 10:45 AM, James Strachan
<james.s...@gmail.com> wrote:
>> Awesome, I was thinking of doing something similar because I want to
>> get some other patches around OSGi support applied to the jars I'm
>> using. Specifically,
>>
>> http://code.google.com/p/google-guice/issues/detail?id=311
>> http://code.google.com/p/google-guice/issues/detail?id=337
>> http://code.google.com/p/google-guice/issues/detail?id=343
>>
>> With your stuff now on github that should be much much easier. :)
>
> I'm just atttempting to apply these now; have done 311 and 343 - will
> report back when they're all done...
>

Awesome! That's just so great! :)

>>> Do you have a link to the work Stuart did adding OSGi metadata to the jars?
>>>
>>
>> Absolutely, http://code.google.com/p/google-guice/issues/detail?id=121
>
> BTW form the comment it looks like this patch has already been applied
> (in June 08)?
>

Yup, it was applied. The issue came up because, before beta-6 at
least, you were repackaging guice using Maven. Now, I think the issue
has shifted so that it's just the guice-all jar that needs the OSGi
manifest headers. This looks like it could be an upstream problem
though, since you're just deploying the guice-with-deps.jar. Maybe it
isn't getting the headers added to the manifest properly and we need
to file an issue in the Guice project.

Rich

James Strachan

unread,
Apr 15, 2009, 2:11:15 PM4/15/09
to guice...@googlegroups.com
2009/4/15 Richard Wallace <rwalla...@gmail.com>:

Ah I see now :)

I went with the guice-with-deps as I figured using the low-dependency
version (using the internal versions of google collections / cglib
etc) was gonna be easier to reuse on projects.

I guess we need a new Guice issue raising to fix this jar's OSGi metadata.

Richard Wallace

unread,
Apr 15, 2009, 2:36:58 PM4/15/09
to guice...@googlegroups.com
On Wed, Apr 15, 2009 at 11:05 AM, James Strachan
Sure, no problem. I'll take a look at this tonight.

>>>> Do you have a link to the work Stuart did adding OSGi metadata to the jars?
>>>>
>>>
>>> Absolutely, http://code.google.com/p/google-guice/issues/detail?id=121
>>
>> BTW form the comment it looks like this patch has already been applied
>> (in June 08)?
>
> Does patch 311 work with the 121 patch? It looks from 121 that BND is
> being used to generate the OSGi metadata?
>

It should and it does. It looks like there is something missing. The
Fragment-Host has been added to each of the build.properties files,
but there is nothing in the common.xml build file pulling that value
in for BND. I'll see about making a new patch for that issue too.

Rich

James Strachan

unread,
Apr 15, 2009, 2:40:11 PM4/15/09
to guice...@googlegroups.com
Great stuff, many thanks!

Incidentally Pax Exam looks great:
http://wiki.ops4j.org/display/paxexam/Pax+Exam

I've hacked up a simple test harness for OSGi...
http://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit-osgi-test/

so we can hopefully have an integration test that shows things work

Richard Wallace

unread,
Apr 16, 2009, 12:14:56 AM4/16/09
to guice...@googlegroups.com
Ok, I was wrong. It does get picked up. Looks like the bnd task
checks build properties for known OSGi manifest headers and adds them
to the manifest file. So no worries there. I'll look at the other
patch next.

Richard Wallace

unread,
Apr 16, 2009, 12:35:10 AM4/16/09
to guice...@googlegroups.com
On Wed, Apr 15, 2009 at 11:05 AM, James Strachan
I updated the patch and attached it to the issue
<http://code.google.com/p/google-guice/issues/detail?id=337#c2>.

Richard Wallace

unread,
Apr 16, 2009, 12:41:22 AM4/16/09
to guice...@googlegroups.com
On Wed, Apr 15, 2009 at 11:11 AM, James Strachan

Ok, it looks like probably the guice-with-deps.jar isn't the jar we
should be using. I think if you change the deploy script to deploy
the build/dist/guice-snapshot.jar that contains all the deps and has
the OSGi manifest headers.

James Strachan

unread,
Apr 16, 2009, 2:59:57 AM4/16/09
to guice...@googlegroups.com
2009/4/16 Richard Wallace <rwalla...@gmail.com>:

Aha! Great stuff thanks for the heads up; I've patched git. Next build
will pick this change up when I've applied the other patch...

James Strachan

unread,
Apr 16, 2009, 3:40:29 AM4/16/09
to guice...@googlegroups.com
2009/4/16 Richard Wallace <rwalla...@gmail.com>:

Great stuff - many thanks! Patch applied.

The 2.0-SNAPSHOT version in the maven repo of GuiceyFruit now has all
the OSGi related patches applied I think. I'll cut 2.0-beta-7 next
week with all this stuff in. It'd be great if you could double check
there's nothing else missing it'd be great; I think all the patches
you've mentioned are resolved now. If you use the 2.0-SNAPSHOT version
in your pom.xml's you should be able to give Guice/GuiceyFruit a try
in OSGi

James Strachan

unread,
Apr 16, 2009, 6:15:55 AM4/16/09
to guice...@googlegroups.com
BTW I've switched GuiceyFruit to use the OSGi bundle version of the
aopalliance jar (from ServiceMix Kernel - soon to be Apache Karaf);
I've also got the OSGi test case using Pax Exam to try use
GuicyFruit/Guice within Equinox; though am getting:

java.lang.NoClassDefFoundError: org/guiceyfruit/support/GuiceyFruitModule

not sure yet if there's something wrong with the OSGi manifest stuff
or if its a Pax Exam issue :). At least the other bundles seem to get
deployed into OSGi OK.

James Strachan

unread,
Apr 16, 2009, 9:33:41 AM4/16/09
to guice...@googlegroups.com
2009/4/16 James Strachan <james.s...@gmail.com>:

> BTW I've switched GuiceyFruit to use the OSGi bundle version of the
> aopalliance jar (from ServiceMix Kernel - soon to be Apache Karaf);
> I've also got the OSGi test case using Pax Exam to try use
> GuicyFruit/Guice within Equinox; though am getting:
>
> java.lang.NoClassDefFoundError: org/guiceyfruit/support/GuiceyFruitModule
>
> not sure yet if there's something wrong with the OSGi manifest stuff
> or if its a Pax Exam issue :). At least the other bundles seem to get
> deployed into OSGi OK.

Aha - made some progress. When using Felix as the runtime container it
gives more meaningful errors than with Equinox.

ERROR: Error starting
file:bundles/org.guiceyfruit.guiceyfruit-core_2.0.0.SNAPSHOT.jar
(org.osgi.framework.BundleException: Unresolved constraint in bundle
5: package; (package=com.google.inject.internal))

I'd been using guice's internal package to avoid folks having 2 lots
of google collections on the classpath. I guess with OSGi, we're gonna
have to either move guiceyfruit to using its own google collections;
or export the com.google.inject.internal package.

The downside with the former is double the classes on the classpath
for google collections; and its another dependency to add to the mix;
the up side is we don't have to mess with the OSGi headers of Guice
(and can work with our Guice fork or any other Guice - lifecycle
limitations allowing).

Thoughts?

James Strachan

unread,
Apr 16, 2009, 10:02:38 AM4/16/09
to guice...@googlegroups.com
2009/4/16 James Strachan <james.s...@gmail.com>:

Ah it seems we're quite tied to com.google.inject.internal for various
things (most notably dealing with error messages and
BindingImpl/Scopes for lifecycles) so our OSGi options seem to be
either

* we make com.google.inject.internal exported (which would only work
on our guicey fork)
* we make guiceyfruit a fragment as described here...
http://code.google.com/p/google-guice/issues/detail?id=311

am about to try the latter (having never even known about fragments :)

James Strachan

unread,
Apr 16, 2009, 10:44:40 AM4/16/09
to guice...@googlegroups.com

I tried fragments which don't work in Felix; as Felix doesn't support
a fragment which has an export. So I've gone with the former for now.
I've patched the Guicey fork to export the com.google.inject.internal
package.

The Pax Exam based OSGi integration test now works perfectly deploying
GuiceyFruit & Guice into Felix and Equinox - yay!

I wonder if we should try get the internal package exported in the
Guice distro too?

Reply all
Reply to author
Forward
0 new messages