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

Richard Eckart de Castilho commented on UIMA-6243:
--------------------------------------------------

... more analysis and thoughts about how to address the issue ...

*PEAR*
 - Precondition : Classes which come from the PEAR context are loaded through 
the PEAR's UIMAClassLoader
 - Consequence : IF the classloader of a JCas wrapper class in the PEAR context 
is the PEAR's UIMAClassLoader,
 THEN we can deduce that the PEAR provides an override

*OSGI*
 - Precondition 1: classes which are provided by an OSGI bundle are loaded 
through the bundle's classloader
 - Precondition 2: The bundle's classloader is provided as an extension 
classloader to the ResourceManager which in turn wraps it as an UIMAClassLoader.
 However, the UIMAClassLoader does not define the JCas wrapper class, it only 
provides access to it by delegating to the bundle classloader!
 - Precondition 3: The JCas classloader set in the CAS when the CAS was first 
created had no access to the bundle classloader.
 - Consequence 1 : The classloader of the JCas wrapper is always the same (i.e. 
the bundle classloader).
 So the existing logic to detect an "override" does not trigger.
 - Consequence 2 : Since the bundle classloader with the JCas wrappers was not 
available when creating the JCas (PRE-3),
 the base generators generate instances of Annotation for custom annotation 
types

*Solution(?)*
 _WHEN_ switching classloaders (e.g. via CASImpl.switchClassLoaderLockCasCL())
 _THEN_ we must check whether the base generator creates the same JCas wrapper 
as a generator with the switched loader would create to decide if a new 
generator must be created for the current classloader (i.e. if there is an 
"override")

> JCas returns Annotation when asked for a specific subtype
> ---------------------------------------------------------
>
>                 Key: UIMA-6243
>                 URL: https://issues.apache.org/jira/browse/UIMA-6243
>             Project: UIMA
>          Issue Type: Bug
>          Components: UIMA
>    Affects Versions: 2.10.4SDK
>            Reporter: Richard Eckart de Castilho
>            Priority: Major
>
> In a specific classloader topology, a fully initialized JCas with theoretic 
> access to the JCas wrappers of a given type will not return that type but 
> instead returns an instance of {{Annotation}}. This leads to an exception 
> like this:
> {code}
> org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator 
> processing failed.    
>       at 
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:427)
>       at 
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.innerCall(PrimitiveAnalysisEngine_impl.java:329)
>       at 
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:321)
>       at 
> org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:269)
>       at 
> org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:284)
>       at 
> org.apache.uima.cas.test.JCasClassLoaderTest.thatTypeSystemCanComeFromItsOwnClassLoader(JCasClassLoaderTest.java:126)
>       ... snip ...
> Caused by: java.lang.ClassCastException: org.apache.uima.jcas.tcas.Annotation 
> cannot be cast to org.apache.uima.cas.test.Token
>       at java.util.Iterator.forEachRemaining(Iterator.java:116)
>       at 
> org.apache.uima.cas.test.JCasClassLoaderTest$FetchTheTokenAnnotator.process(JCasClassLoaderTest.java:166)
>       at 
> org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
>       at 
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:411)
>       ... 28 more
> {code}
> Looks like this is a UIMAv2 issue only. When running the test against the 
> UIMAv3 master (commit 0211057ad), I do not get any ClassCastException.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to