On 5/20/09 3:32 PM, Bill Shannon wrote:
> Richard S. Hall wrote:
>>
>>
>> On 5/19/09 4:08 PM, Peter Williams wrote:
>>> I'm investigating a JavaMail failure in V3 that is caused by the
>>> current OSGi configuration and I'm trying to figure out how to fix it.
>>>
>>> The issue is this: Code in the JDK (JAF in this case) is calling
>>> getResources() on the current context classloader (web app
>>> classloader in my test case, but probably could another one) to
>>> locate any available mailcap files. It's trying to find
>>> META-INF/mailcap.default in javax.mail.jar. This fails, the code
>>> breaks. Outside of OSGi, this all works fine.
>>>
>>> So what needed to happen here to make this work? Should
>>> javax.mail.jar be exporting META-INF? How? Does the JDK have to
>>> import this? (how?!)
>>
>> If I understand correctly, it sounds like JAF expects to be able to
>> access every available JAR file by accessing the context class
>> loader. This is a recipe for failure in OSGi.
>>
>> Typically, these sorts of situations involve some sort of extender
>> listening for bundles with mailcap files and then the information in
>> them can be injected where appropriate.
>>
>> Unfortunately, I don't know enough about JAF to say in detail how
>> this might work.
>
> This is a fairly common pattern in the JDK, and one we've recommended
> in Java EE for quite a few years. This is essentially the same as
> java.util.ServiceLoader.
Yes, I am aware of that. GF already uses the pattern I briefly describe
above to deal with the ServiceLoader case.
> It's fine if an OSGi bundle has to explicitly export these classes so
> they can be loaded by (e.g.) JAF, but JAF needs to be able to load these
> classes using the context class loader.
Well, if that's the only way it can happen, then it will require a
different approach to get it to work. The only other thing I can think
of off the top of my head is to modify GF's web app class loader to
automatically search all bundles for resources. This would work for web
apps deployed as web apps into GF, but it wouldn't work for bundles,
since they don't use the web app class loader.
-> richard
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>