[
https://issues.apache.org/jira/browse/ARIES-41?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769256#action_12769256
]
Alasdair Nottingham commented on ARIES-41:
------------------------------------------
I just want to describe why this is a problem. One of the key usage scenarios
for the JNDI spec in OSGi is for use from a web application bundle. While the
web container may be able to put the servlets classloader on the thread (which
of course is a bundle classloader) things can be different for JSPs. Web
containers often support JSP recompilation, i.e. you update a JSP, save it and
all of a sudden the update is usable, no app or server restart. A common way to
do this is to load the JSP class in a classloader whose parent is the WAB
classloader. As a result the thread context classloader will not implement
BundleReference, but a parent will.
Given we look to the parent we absolutely need to search the whole hierarchy,
after all who knows what other tricks a web container may be pulling.
> In JNDI ServiceHelper we should also check for the current thread's context
> classloader's parent
> ------------------------------------------------------------------------------------------------
>
> Key: ARIES-41
> URL: https://issues.apache.org/jira/browse/ARIES-41
> Project: Aries
> Issue Type: Bug
> Components: JNDI
> Reporter: Lin Sun
> Assignee: Alasdair Nottingham
> Priority: Minor
>
> Hi,
> In the ServiceHelper.getBundleContext(), if the current thread's context
> classloader is not an instance of BundleReference, we should also try to
> check its parent to see if it is an instance of BundleReference. If it is,
> then grab the bundle context accordingly. What do people think?
> Proposed change:
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> if (cl instanceof BundleReference) {
> result = ((BundleReference)cl).getBundle().getBundleContext();
> + } else if (cl.getParent() instanceof BundleReference) {
> + result =
> ((BundleReference)cl.getParent()).getBundle().getBundleContext();
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.