Jaroslaw Cwiklik wrote:
> Marshall, I cant close https://issues.apache.org/jira/browse/UIMA-1531 yet.
> Over the weekend I've discovered why the Logger ignores uima
> formatter defined in  Logger.properties and logs entries using the default
> formatter (xml). It turns out that the java LogManager uses system
> classloader to load the formatter class. Here is the method where this magic
> occurs:
> Formatter getFormatterProperty(String name, Formatter defaultValue) {
> String val = getProperty(name);
> try {
> if (val != null) {
> Class clz = ClassLoader.getSystemClassLoader().loadClass(val);
> return (Formatter) clz.newInstance();
> }
> } catch (Exception ex) {
> // We got one of a variety of exceptions in creating the
> // class or creating an instance.
> // Drop through.
> }
> // We got an exception. Return the defaultValue.
> return defaultValue;
> }
> 
> It surprising that that this java component silently ignores errors. Since
> the uima formatter class is not loaded into the system classloader by the
> UimaBootstrap, the LogManager returns a default formatter from the method
> above.
> 
> I dont know how to fix this problem yet. One possibility is to change
> UimaBootstrap to load jars/classes into the system classloader. Another
> possibility is to load this one class into the system classloader although
> I've failed trying to do this. I attempted to augment
> the system classloader using reflection to inject a new URL like so:
> 
>       URL url = new
> URL("jar:file:/C:/uima/releases/2.3.3-04/apache-uima/lib/uima-core.jar!/java/util/logging/XMLFormatter.class");
> 
>         Class[] parameters = new Class[]{URL.class};
>         URLClassLoader sysloader = (URLClassLoader)
> ClassLoader.getSystemClassLoader();
>         Class sysclass = URLClassLoader.class;
>         try {
>            Method method = sysclass.getDeclaredMethod("addURL", parameters);
>            method.setAccessible(true);
>            method.invoke(sysloader, new Object[]{url});
>         } catch (Throwable t) {
>            t.printStackTrace();
>            throw new IOException("Error, could not add URL to system
> classloader");
>         }//end try catch
> 
> Again, for some reason this doesnt work.I can inject jar files into the
> system classloader using the above technique but not individual classes from
> jars.

Because the system classloader only understands jars
and directories.  You can load the class file into
memory and feed the byte[] to the classloader with
the same kind of reflection techniques you use above.

Note that I'm _not_ recommending this, simply pointing
it out.

--Thilo

> 
> 
> Jerry
> 
> 
> On Sun, Oct 18, 2009 at 4:22 PM, Marshall Schor <m...@schor.com> wrote:
> 
>> Hi everyone,
>>
>> I'm "itching" to get the 2.3.0 release done.
>>
>> Of the issues that are open, reopened, or in-progress, most are now
>> being deferred to past this release.
>>
>> The ones left that may need to be worked on before the release is done
>> include:
>>
>> (Joern)     UIMA-1619 <https://issues.apache.org/jira/browse/UIMA-1619>
>> Clarify that a Cas Editor Project is required to use the Cas Editor in
>> the documentation <https://issues.apache.org/jira/browse/UIMA-1619>
>> (Eddie)    UIMA-1611 <https://issues.apache.org/jira/browse/UIMA-1611>
>> UimacppServiceControlled need to implement isStopped()
>> <https://issues.apache.org/jira/browse/UIMA-1611>
>> (Marshall) UIMA-1539 <https://issues.apache.org/jira/browse/UIMA-1539>
>> Update READMEs for 2.3.0 release
>> <https://issues.apache.org/jira/browse/UIMA-1539>
>> (Jerry)     UIMA-1153 <https://issues.apache.org/jira/browse/UIMA-1153>
>> thread safety issue with sample flow controller
>> AdvancedFixedFlowController
>> <https://issues.apache.org/jira/browse/UIMA-1153>
>> (Eddie)    UIMA-1038
>> <https://issues.apache.org/jira/browse/UIMA-1038>setUimaClasspath.sh
>> should export library paths for interoperability with UIMA C++
>> <https://issues.apache.org/jira/browse/UIMA-1038>
>> (Jerry)     UIMA-1531
>> <https://issues.apache.org/jira/browse/UIMA-1531>Need a script to launch
>> a UIMA-AS service via RunWithJarPath
>> <https://issues.apache.org/jira/browse/UIMA-1531>
>> (Jerry)     UIMA-1484 <https://issues.apache.org/jira/browse/UIMA-1484>
>> Update UIMA-AS Documentation
>> <https://issues.apache.org/jira/browse/UIMA-1484>
>>
>> Could the people in (parenthesis) take the lead in looking at these and
>> try and close out these issues?
>>
>> Thanks! -Marshall
>>
> 

Reply via email to