Comment #42 on issue 94 by mcculls: Support OSGi classloading in Guice
http://code.google.com/p/google-guice/issues/detail?id=94

Be aware there are a couple of OSGi patches that are not in Guice 2.0:

    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

These are all scheduled for release 2.1

Only issue 343 relates to the core Guice jar (the others are related to  
extensions,
such as AssistedInject) and 343 is the issue relating to Anne's example, so  
there's
no need to re-open this particular issue as there are existing issues  
already open.

Issue 343 only applies if you are attempting to proxy a system class like  
Anne was
(in Anne's case it was java.util.Random) - however you will see the same  
exception
stack about not finding FastClass whenever Guice is not able to bridge  
between the
client type and the CGLIB code.

In particular, if you try to proxy a *package-private* type then it is  
impossible for
Guice to bridge the client and CGLIB code together due to security  
restrictions in
Java's classloading mechanism as explained in the wiki:

    http://code.google.com/p/google-guice/wiki/OSGi

So please check the failing binding and make sure the types are protected  
or public.

If you want a copy of Guice 2.0 with the patch for issue 343 applied then  
you can get
this from the peaberry project at http://code.google.com/p/peaberry/ (look  
at the
Maven dependencies in the wiki, or check out the trunk and look in  
lib/build). But
remember this is only necessary if you need to proxy system types and I  
have several
OSGi projects that successfully use Guice 2.0 without needing this patch.

To use extensions like AssistedInject in OSGi you will either have to wait  
for the
2.1 release (which won't be as long a wait as 2.0) or you can download the  
Guice 2.0
source, apply the patches from the issues listed above, and rebuild the  
distribution.

As for the AOP Alliance jar, the version distributed with Guice does not  
have OSGi
metadata because it's the original binary - whether Guice should ship a  
modified
version has never really come up before as you can easily get an OSGi  
version of this
jar from other distributions like peaberry or the Spring bundle repository.

But if you want OSGi metadata added to Guice's AOP Alliance jar feel free  
to open a
new issue to cover this - the one question is where this modified jar  
should then be
put on the Maven repository, as it is clearly not the official jar once  
modified and
should therefore probably go under a different groupId (this is why it's  
much better
for the *original* distributor to add OSGi metadata rather than get all  
downstream
distributors to add it and use different bundle symbolic names, like Spring  
does).

In summary: check the bindings for private types, try out the Guice binary  
from the
peaberry project to make sure you're not running into Issue 343 - if all  
else fails
send a note to the Guice-OSGi mailing list at guice-o...@googlegroups.com  
along with
more details about your code and perhaps even a testcase.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to google-guice-dev@googlegroups.com
To unsubscribe from this group, send email to 
google-guice-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to