Thanks for the reply. Im actually trying to instantiate the build-in  
org.apache.uima.jcas.tcas.Annotation

        public static <T extends Annotation> List<T>  selectCovered(JCas jCas, 
final Class<T> type, int begin, int end) 
        {
                Annotation aT = new Annotation(jCas, begin, end);  <- Throws 
exception 

                
                List<T> t = null;
                
                try
                {
                        t = JCasUtil.selectCovered(jCas, type, aT);
                        
                } catch (Exception e)
                {
                        //ignore
                        logger.warn("Temporal annotation error:["+ begin + "," 
+ end + "]");
                }
                finally {
                        
                // Remove temporal annotation
                aT.removeFromIndexes();
                }
        
                return t;
        }



Caused by: org.apache.uima.cas.CASRuntimeException: JCas type 
"org.apache.uima.jcas.tcas.Annotation" used in Java code,  but was not declared 
in the XML type descriptor.
        at 
org.apache.uima.cas.impl.TypeSystemImpl.throwMissingUIMAtype(TypeSystemImpl.java:2665)
        at 
org.apache.uima.cas.impl.TypeSystemImpl.getJCasRegisteredType(TypeSystemImpl.java:2647)
        at 
org.apache.uima.cas.impl.FeatureStructureImplC.<init>(FeatureStructureImplC.java:220)
        at org.apache.uima.jcas.cas.TOP.<init>(TOP.java:87)
        at 
org.apache.uima.jcas.cas.AnnotationBase.<init>(AnnotationBase.java:92)
        at org.apache.uima.jcas.tcas.Annotation.<init>(Annotation.java:162)

From the stack trace it seems it is failing TypeSystemImpl here.
  public TypeImpl getJCasRegisteredType(int i) {
    // first try without sync lock 
https://issues.apache.org/jira/browse/UIMA-6249
    TypeImpl ti = (i >= jcasRegisteredTypes.size()) ? null : 
jcasRegisteredTypes.get(i);
    if (ti != null) {
      return ti;
    }
    synchronized(jcasRegisteredTypes) {
      ti = (i >= jcasRegisteredTypes.size()) ? null : 
jcasRegisteredTypes.get(i);
    }
    if (null == ti) {
      throwMissingUIMAtype(i);
    }
    return ti;
  }

When I step into the code to check jcasRegisteredTypes 
org.apache.uima.jcas.tcas.Annotation is not in the List. But, I didn’t think it 
would be since it is a subtype of AnnotationBase which is in the list.. 


At the point of failure many annotators have fired. I did upgrade my jcasgen 
maven plugin to create my custom annotations and they seem to be getting into 
the type system.

Daniel Cosio
dcco...@gmail.com



> On Apr 12, 2022, at 2:39 AM, Richard Eckart de Castilho <r...@apache.org> 
> wrote:
> 
> org.apache.uima.jcas.tcas.Annotation

Reply via email to