GWT-Dispatch with OSGi/Peaberry

100 views
Skip to first unread message

Evan Ruff

unread,
Aug 21, 2012, 9:11:05 AM8/21/12
to gwt-di...@googlegroups.com
Hey guys,

Has anyone attempted to get GWT-Dispatch working with Peaberry in a Felix/OSGi container? I'm getting some errors around finding the ActionHandler:

java.lang.NoClassDefFoundError: net/customware/gwt/dispatch/server/guice/ActionHandlerModule

I'm a total newbie to the OSGi/Peaberry world, so my first inclination would be to think I need to OSGi-fy the JAR, so I'll try that, but I figured I'd post in case someone has experience with the error/config.

Thanks!

E

David Peterson

unread,
Aug 21, 2012, 9:21:28 AM8/21/12
to gwt-di...@googlegroups.com
Yeah, I suspect you will need to export the gwt-dispatch package. Simplest way is probably via the bnd plugin for Maven, in the project pom.xml file.

I don't have time to dig into it myself currently, but if you log an issue and supply a patch, I can get it into the trunk.

Regards,

David Peterson

Robert Munteanu

unread,
Aug 21, 2012, 9:27:41 AM8/21/12
to gwt-di...@googlegroups.com
On Tue, Aug 21, 2012 at 4:11 PM, Evan Ruff <evan...@gmail.com> wrote:
> Hey guys,
>
> Has anyone attempted to get GWT-Dispatch working with Peaberry in a
> Felix/OSGi container?

Nope.

> I'm getting some errors around finding the
> ActionHandler:
>
> java.lang.NoClassDefFoundError:
> net/customware/gwt/dispatch/server/guice/ActionHandlerModule

No bundle exports that package, so it's expected.

>
> I'm a total newbie to the OSGi/Peaberry world, so my first inclination would
> be to think I need to OSGi-fy the JAR, so I'll try that, but I figured I'd
> post in case someone has experience with the error/config.

You should look into the maven-bundle-plugin [0] which makes it really
easy to OSGify existing maven project. You might have to mark some
imports optional though ( appengine comes into mind ).

Robert


0: http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html

>
> Thanks!
>
> E



--
Sent from my (old) computer

Evan Ruff

unread,
Aug 21, 2012, 9:55:52 AM8/21/12
to gwt-di...@googlegroups.com
hey guys,

Thanks for the pointer to the BND stuff.

I'm not sure if I'm doing it right. I first attempted to do the bnd.jar wrap gwt-dispatch-1.2.0.jar and create a gwt-dispatch-osgi.jar. I installed that into my local maven and switched the dependency over. This didn't present any change, as I am still getting that NoClassDefFound error.

My next attempt was to use the maven-bundle-plugin. This already existed in my POM file (someone else developed it). I attempted to export-package net.customware.gwt.dispatch.server.guice, but that just told me "superflous export" and had no change. When I added it to the Import-Package list, that gave me:

Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package; (osgi.wiring.package=net.customware.gwt.dispatch.server.guice))

So, I guess I'm still not exporting it into the OSGi container?

Clearly, I'm missing something quite fundamental here...

Any direction is much appreciated!

Thanks,

E

Robert Munteanu

unread,
Aug 21, 2012, 9:58:21 AM8/21/12
to gwt-di...@googlegroups.com
On Tue, Aug 21, 2012 at 4:55 PM, Evan Ruff <evan...@gmail.com> wrote:
> hey guys,
>
> Thanks for the pointer to the BND stuff.
>
> I'm not sure if I'm doing it right. I first attempted to do the bnd.jar wrap
> gwt-dispatch-1.2.0.jar and create a gwt-dispatch-osgi.jar. I installed that
> into my local maven and switched the dependency over. This didn't present
> any change, as I am still getting that NoClassDefFound error.
>
> My next attempt was to use the maven-bundle-plugin. This already existed in
> my POM file (someone else developed it). I attempted to export-package
> net.customware.gwt.dispatch.server.guice, but that just told me "superflous
> export" and had no change.

The maven-bundle-plugin automatically adds all exports and imports so
your first attempt should be to configure nothing.

> When I added it to the Import-Package list, that
> gave me:
> Unable to resolve 5.0: missing requirement [5.0] osgi.wiring.package;
> (osgi.wiring.package=net.customware.gwt.dispatch.server.guice))


Can you post the META-INF/MANIFEST.MF file from your bundle?

Robert

Evan Ruff

unread,
Aug 21, 2012, 10:00:35 AM8/21/12
to gwt-di...@googlegroups.com
Sure!

Here it is. I notice that the GWT-Dispatch stuff is in the ignore part. That CANNOT be good!

E
MANIFEST.MF

pillingworthz

unread,
Oct 16, 2012, 11:53:02 AM10/16/12
to gwt-di...@googlegroups.com
Just hit the same problem.

I created an OSGi version of gwt-dispatch using bnd (via the maven-bundle-plugin).

The issue is because net.customware.gwt.dispatch.server.guice.ActionHandlerModule uses com.google.inject.internal.UniqueAnnotations which is not exported by Guice.

Not quite sure how to work around this.

Robert Munteanu

unread,
Oct 16, 2012, 12:46:39 PM10/16/12
to gwt-di...@googlegroups.com
Can't you inline that class in the gwt-dispatch bundle?

Paul Illingworth

unread,
Oct 17, 2012, 5:54:21 AM10/17/12
to gwt-di...@googlegroups.com
By inline you mean take the source for the UniqueAnnotations and drop it into the gwt-dispatch library? Or do you mean using some maven-bundle-plugin magic that can pull in packages from dependencies like Guice and include those? I am not too sure if it can be used for individual classes.

As I see it I have a couple of options

1) Update the pom for gwt-dispatch; change from jar packaging to bundle packaging and use the maven-bundle-plugin to generate the manifest. Also copy/paste the UniqueAnnotations class from Guice. Submit this back to the gwt-dispatch project and hopefully get it in the next version of gwt-dispatch.

2) Do this externally to gwt-dispatch - create my own gwt-dispatch-osgi project that has gwt-dispatch as dependency, also add the code for UniqueAnnotations from Guice and then repackage it and generate the manifest.

I am not too sure about the legalities of "pinching" and redistributing the Guice UniqueAnnotations code. I guess as it uses the Apache 2 licence this is ok.

Option 1 is better for me long term. Option 2 I can do on my own.

Thoughts?

Robert Munteanu

unread,
Oct 17, 2012, 5:57:46 AM10/17/12
to gwt-di...@googlegroups.com
On Wed, Oct 17, 2012 at 12:54 PM, Paul Illingworth
<pillin...@gmail.com> wrote:
> By inline you mean take the source for the UniqueAnnotations and drop it
> into the gwt-dispatch library? Or do you mean using some maven-bundle-plugin
> magic that can pull in packages from dependencies like Guice and include
> those? I am not too sure if it can be used for individual classes.

It's a configuration option for the maven-bundle-plugin, which
delegates to bnd. I'm not sure of the exact syntax right now.

>
> As I see it I have a couple of options
>
> 1) Update the pom for gwt-dispatch; change from jar packaging to bundle
> packaging and use the maven-bundle-plugin to generate the manifest. Also
> copy/paste the UniqueAnnotations class from Guice. Submit this back to the
> gwt-dispatch project and hopefully get it in the next version of
> gwt-dispatch.
>
> 2) Do this externally to gwt-dispatch - create my own gwt-dispatch-osgi
> project that has gwt-dispatch as dependency, also add the code for
> UniqueAnnotations from Guice and then repackage it and generate the
> manifest.
>
> I am not too sure about the legalities of "pinching" and redistributing the
> Guice UniqueAnnotations code. I guess as it uses the Apache 2 licence this
> is ok.
>
> Option 1 is better for me long term. Option 2 I can do on my own.
>
> Thoughts?

I'd be happy to accept a contribution, given that the jar remains
usable for non-OSGi environments.

Robert

>
>
> On Tuesday, 21 August 2012 14:11:05 UTC+1, Evan Ruff wrote:
>>
>> Hey guys,
>>
>> Has anyone attempted to get GWT-Dispatch working with Peaberry in a
>> Felix/OSGi container? I'm getting some errors around finding the
>> ActionHandler:
>>
>> java.lang.NoClassDefFoundError:
>> net/customware/gwt/dispatch/server/guice/ActionHandlerModule
>>
>> I'm a total newbie to the OSGi/Peaberry world, so my first inclination
>> would be to think I need to OSGi-fy the JAR, so I'll try that, but I figured
>> I'd post in case someone has experience with the error/config.
>>
>> Thanks!
>>
>> E



Paul Illingworth

unread,
Oct 19, 2012, 9:31:59 AM10/19/12
to gwt-di...@googlegroups.com
I have created a clone (http://code.google.com/r/pillingworthz-gwt-dispatch-osgi/) and put my changes in there.

The changes are

1) Use the maven-bundle-plugin to do the packaging to get the OSGi import/exports etc defined
2) I have added the source for UniqueAnnotations to gwt-dispatch. I didn't want to pull in the class as I could foresee issues in non OSGi environments. Also because of the nature of this class generating unique annotations having two instances is likely to lead to problems? I didn't really want to do this but couldn't see an alternative.
3) Added a servlet filter class that can be used to swap the thread context class loader for one that can see other bundles classes to get the GWT RPC to work.

It all seems to work but I'll give it a more thorough testing over the coming week.

In terms of a non OSGi environment the jar works just as it did before - there are just some additional classes and some extra OSGi entries in the manifest file.

Robert Munteanu

unread,
Oct 29, 2012, 5:46:45 PM10/29/12
to gwt-di...@googlegroups.com
Nice! The changes look good to me and the approach is sound. I still
need a little time to test them though.

Robert

On Fri, Oct 19, 2012 at 4:31 PM, Paul Illingworth

Robert Munteanu

unread,
Nov 10, 2012, 3:09:54 PM11/10/12
to gwt-di...@googlegroups.com
It took more time to get re-aquainted with Mercurial than to verify
the changes, but overall this looks good.

I've merged the changes into the main repository.

Thanks!

On Fri, Oct 19, 2012 at 4:31 PM, Paul Illingworth
Reply all
Reply to author
Forward
0 new messages