The toolkit uimaFIT allows you to design annotation types in the so-called Component Descriptor Editor, save the descriptor as XML and generate the corresponding Java classes. When you run an analysis engine that makes use of these annotations uimaFit checks whether it finds the type system descriptor XML file on the classpath. In certain circumstances, it may happen that it falls short of finding this file and will abort with the following error message:
Caused by: org.apache.uima.cas.CASRuntimeException:
JCas type "de.tudarmstadt.ukp.teaching.nlp4web.ml.type.NamedEntity" used in Java code, but was not declared in the XML type descriptor.
at org.apache.uima.jcas.impl.JCasImpl.getType(JCasImpl.java:412)
at org.apache.uima.jcas.cas.TOP.<init>(TOP.java:92)
at org.apache.uima.jcas.cas.AnnotationBase.<init>(AnnotationBase.java:53)
at org.apache.uima.jcas.tcas.Annotation.<init>(Annotation.java:54)
In this case you need to explicitly point uimaFIT to the location of your type descriptor file. For this to be done, there exist two different ways.
Solution via VM argument
As a quick and dirty solution you add the following VM argument which in Eclipse is configured in the Launch Configuration dialog
-Dorg.uimafit.type.import_pattern=classpath*:desc/types/**/*.xml
In my case, I stored the XML file in src/main/resources/desc/types/TypeSystem.xml where src/main/resources is set to be a source folder in Eclipse (Maven project layout).
Solution via types.txt (suggested)
The issue with the solution above is that your code will break if other people try to execute it without knowing about the VM parameter. There exists a more stable way to solve this issue. uimaFIT looks into the file
- <classpath>/META-INF/org.uimafit/types.txt (for uimaFit until 1.4.x, still supported by the uimafit-legacy-support package)
- <classpath>/META-INF/org.apache.uima.fit/types.txt (for uimaFit 2.0.0 and above)
in order to find out where to search for the XML type descriptor files (In a Maven context META-INF should be located in src/main/resources). Each line in this types.txt file describes one search pattern. In our example, types.txt should contain one line:
classpath*:desc/types/**/*.xml
Links
- [1] uimaFit Guide and Reference – 8.1. Making types auto-detectable
- [2] DKPro tutorial (UIMA part): Type System Auto-Discovery (Slide 37)
- [3] TypeDescriptorDetection