[ https://issues.apache.org/jira/browse/UIMA-6243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17141557#comment-17141557 ]
Marshall Schor edited comment on UIMA-6243 at 6/24/20, 1:24 PM: ---------------------------------------------------------------- [~schor] wrote: Running this gave errors on all 3 test cases: Caused by: org.apache.uima.cas.CASRuntimeException: The JCAS cover class "org.apache.uima.cas.test.Token_Type" could not be loaded. at Caused by: java.lang.ClassCastException: org.apache.uima.jcas.tcas.Annotation cannot be cast to org.apache.uima.cas.test.Token at Caused by: java.lang.ClassCastException: org.apache.uima.jcas.tcas.Annotation cannot be cast to org.apache.uima.cas.test.Token at Fixing the likely little typo bug in IsolatingClassLoader redefining(...), to add the pattern to "redefineClassesPatterns", makes 2 of the tests pass, and the one that fails now fails with: Caused by: java.lang.ClassCastException: org.apache.uima.cas.test.Token cannot be cast to org.apache.uima.cas.test.Token at -Looking at this code, it is attempting to cast to the Token class, which is being loaded by the class loader that loaded the JCasClassLoaderTest code itself, which I'm guessing is different from the test's version of that class which was probably loaded with the IsolatingClassLoader (I haven't traced the code, so this is just an educated guess). This of course would cause a class cast exception.- -Perhaps the test needs to a) not do a class cast, b) do instead a test to see if the object is the expected class, using some test for example, from the "Class" class: isAssignableFrom or isInstance, and not use any reference to "Token" in the testcase as a class itself.- -WDYT?- I see this test-case issue was fixed in subsequent versions. Continuing to investigate. I suspect this is an actual bug - thanks for the clever test case... was (Author: rec): [~schor] wrote: Running this gave errors on all 3 test cases: Caused by: org.apache.uima.cas.CASRuntimeException: The JCAS cover class "org.apache.uima.cas.test.Token_Type" could not be loaded. at Caused by: java.lang.ClassCastException: org.apache.uima.jcas.tcas.Annotation cannot be cast to org.apache.uima.cas.test.Token at Caused by: java.lang.ClassCastException: org.apache.uima.jcas.tcas.Annotation cannot be cast to org.apache.uima.cas.test.Token at Fixing the likely little typo bug in IsolatingClassLoader redefining(...), to add the pattern to "redefineClassesPatterns", makes 2 of the tests pass, and the one that fails now fails with: Caused by: java.lang.ClassCastException: org.apache.uima.cas.test.Token cannot be cast to org.apache.uima.cas.test.Token at -Looking at this code, it is attempting to cast to the Token class, which is being loaded by the class loader that loaded the JCasClassLoaderTest code itself, which I'm guessing is different from the test's version of that class which was probably loaded with the IsolatingClassLoader (I haven't traced the code, so this is just an educated guess). This of course would cause a class cast exception.- -Perhaps the test needs to a) not do a class cast, b) do instead a test to see if the object is the expected class, using some test for example, from the "Class" class: isAssignableFrom or isInstance, and not use any reference to "Token" in the testcase as a class itself.- -WDYT?- I see this was fixed in subsequent versions. Continuing to investigate. I suspect this is an actual bug - thanks for the clever test case... > 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)