You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by "Michael Baessler (JIRA)" <ui...@incubator.apache.org> on 2007/11/13 12:33:50 UTC

[jira] Closed: (UIMA-633) Class loading issue with ResourceBundle when using the UIMAClassloader

     [ https://issues.apache.org/jira/browse/UIMA-633?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Baessler closed UIMA-633.
---------------------------------

    Resolution: Fixed

> Class loading issue with ResourceBundle when using the UIMAClassloader
> ----------------------------------------------------------------------
>
>                 Key: UIMA-633
>                 URL: https://issues.apache.org/jira/browse/UIMA-633
>             Project: UIMA
>          Issue Type: Bug
>          Components: Core Java Framework
>    Affects Versions: 2.2
>            Reporter: Michael Baessler
>            Assignee: Michael Baessler
>             Fix For: 2.3
>
>
> currently we have the issue with UIMA components that custom messages in exception cannot be resolved when the UIMAClassloader is used to load the custom component. This is the case when using the PEAR runtime. To work around this issue we say that the custom components can throw own exception class that is derived from the UIMA exception classes. This should work because we thought that the method ResourceBundle.|getBundle(baseName, locale) |use the Classloader of the current object to resolve the messages. That's also what the JavaDoc says:
> "Gets a resource bundle using the specified base name and locale, and the caller's class loader.
> Calling this method is equivalent to calling |getBundle(baseName, locale, this.getClass().getClassLoader())| ...."
> But unfortunately this is not true in any case. So it does also not work for out UIMA case.
> If we have the custom exception example below, let's see what happens.
> public MyException extends AnnotatorPrcoessException {
>   public MyException (String aMessageKey, Object[] aArguments) {
>      super("myExceptionMessages", aMessageKey, aArguments);
>   }
> }
> when the exception message is localized, the method getLocalizedMessage() is called on the MyException object. The getLocalizedMessage() method is not implemented in the MyException class, it is inherited from the InternationalizedException class.
>      public String getLocalizedMessage() {
>      ....
>      ResourceBundle.getBundle(bundleName, locale);
>      ....
>    }
> If getLocalizedMessage() method is called, the getBundle(bundleName, locale) method resolves the classloader that is used to resolve the bundleName. In our case the classloader of the class InternationalizedException is used here since there the getLocalizedMessage() method is defined. But this is in case of the UIMAClassloader usage not the classloader of the MyException object that should be used here, at least if we trust the JavaDocs. To solve this issue we can easily hand over the MyException object classloader to the getBundle() method like:
>    ResourceBundle.getBundle(bundleName, locale, this.getClass().getClassloader());
> The fix is done in the InternationalizedException class so it work for all derived exceptions. 

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