[ 
https://issues.apache.org/jira/browse/UIMA-1714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12798772#action_12798772
 ] 

Marshall Schor commented on UIMA-1714:
--------------------------------------

After some more investigation, I think a better fix is to change the way the 
resource bundles are looked up for error messages.  Right now, the logic is 
spread across multiple classes. 

For instance, for the JSR47 logger, part is in JSR47Logger_impl, in the method 
getExtensionClassLoader which returns the ResourceManager's extension class 
loader or null if there is none.  Then, the I18nUtil.localizeMessage method has 
logic to use the passed-in extensionClassLoader (which might be null) and if it 
is null, it uses the class loader that loaded the I18nUtil class or the 
"system" classloader if it gets "null" for I18nUtil.class.getClassLoader() call.

I think that a better strategy would be to, in essence, try a series of class 
loaders, until one succeeds, or all of them fail.  The order would go something 
like:
# ResourceManager's extension class loader
# the thread's contextClassLoader
# the class loader that loaded the I18nUtil class
# the class loader that loaded the caller of the localizeMessage method
# the class loader that loaded the 2nd previous caller
# the class loader that loaded the 3rd previous caller
etc.

Of course, you would only try a class loader if it was different from one 
already tried.

This approach allows frameworks to find and load resources they cannot see with 
their own class loaders, but which belong with class-loader-isolated 
components.  Here's one article that tries to explain why this is a good idea:  
http://www.javaworld.com/javaworld/javaqa/2003-06/01-qa-0606-load.html 

Another similar approach is used by the Eclipse plugin mechanism when it is 
trying to find classes or resources to load that might belong to user code - 
sets up a ContextClassLoader to do the work of running up the chain of callers, 
as above, trying them to see if they can load the thing requested.  See 
http://wiki.eclipse.org/Context_Class_Loader_Enhancements.  Eclipse defines a 
new class loader which implements this kind of algorithm - see 

Java has a method which returns the set of classes on the call stack, in order: 
 aSecurityManagerInstance.getClassContext(). 



> Message Bundles not visible when loaded under a UIMA Resource Manager class 
> loader
> ----------------------------------------------------------------------------------
>
>                 Key: UIMA-1714
>                 URL: https://issues.apache.org/jira/browse/UIMA-1714
>             Project: UIMA
>          Issue Type: Bug
>          Components: Core Java Framework
>    Affects Versions: 2.3
>            Reporter: Marshall Schor
>
> UIMA-AS has message bundles.  When uima-as classes are loaded under a 
> resource manager class loader, the message bundle is not visible when logging 
> occurs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to