I can reproduce this with a simple bit of top level code; the failure seems to depend on an unusual order of making Feature Structures, and setting up the DocumentAnnotation instance.
I'll take a look. -Marshall On 2/6/2014 7:38 AM, Peter Klügl wrote: > I can fix the xmiCAS if I change the address of the DocumentAnnotation > to be lower than the Year... > > Peter > > Am 06.02.2014 13:23, schrieb Peter Klügl: >> Hi, >> >> if I open the following xmiCAS in the CAS Editor, remove the Year >> annotation and try to save the file, then I get the same exception. The >> other annotations are removable... >> >> <?xml version="1.0" encoding="UTF-8"?> >> <xmi:XMI xmlns:Title="http:///uima/ruta/example/Title.ecore" >> xmlns:cas="http:///uima/cas.ecore" >> xmlns:type="http:///org/apache/uima/ruta/type.ecore" >> xmlns:xmi="http://www.omg.org/XMI" >> xmlns:Author="http:///uima/ruta/example/Author.ecore" >> xmlns:tcas="http:///uima/tcas.ecore" >> xmlns:example="http:///uima/ruta/example.ecore" xmi:version="2.0"> >> <cas:NULL xmi:id="0"/> >> <cas:Sofa xmi:id="1" sofaNum="1" sofaID="_InitialView" >> mimeType="text" sofaString="Ogren, P.V., Wetzler, P.G., Bethard, S.: >> ClearTK: A UIMA Toolkit for Statistical Natural Language Processing. In: >> UIMA for NLP workshop at LREC 08. (2008) "/> >> <example:Year xmi:id="8" sofa="1" begin="148" end="154"/> >> <example:Author xmi:id="12" sofa="1" begin="0" end="40"/> >> <example:Title xmi:id="16" sofa="1" begin="41" end="109"/> >> <tcas:DocumentAnnotation xmi:id="20" sofa="1" begin="0" end="156" >> language="x-unspecified"/> >> <cas:View sofa="1" members="8 12 16 20"/> >> </xmi:XMI> >> >> >> Peter >> >> Am 06.02.2014 12:56, schrieb Peter Klügl: >>> Hi, >>> >>> has anyone seen the following exception. I have no idea what can cause >>> this problem. (the typeCode is 0 or something causing the feats int >>> array to be null). I added the method that causes the problem below. It >>> just removes some annotations dependent of its type. >>> >>> I was thinking that the problem is caused by removing annotations that >>> are indexed and are the value of the feature of another indexed >>> annotation. However, that works for almost all types. I would assume >>> that this functionality would not depend on the actual type or the order >>> in the type system, right? >>> >>> Any ideas is greatly appreciated. >>> >>> java.lang.NullPointerException >>> at >>> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.enqueueFeatures(XmiCasSerializer.java:593) >>> at >>> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.enqueueFeaturesOfIndexed(XmiCasSerializer.java:521) >>> at >>> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.serialize(XmiCasSerializer.java:241) >>> at >>> org.apache.uima.cas.impl.XmiCasSerializer$XmiCasDocSerializer.access$700(XmiCasSerializer.java:108) >>> at >>> org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1551) >>> at >>> org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1616) >>> at >>> org.apache.uima.cas.impl.XmiCasSerializer.serialize(XmiCasSerializer.java:1567) >>> at >>> org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler.writeXmi(RerunActionHandler.java:652) >>> at >>> org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler.access$0(RerunActionHandler.java:647) >>> at >>> org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler$RerunHandlerJob.writeCleanInputFiles(RerunActionHandler.java:378) >>> at >>> org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler$RerunHandlerJob.evalRutaWithClassPathScript(RerunActionHandler.java:196) >>> at >>> org.apache.uima.ruta.testing.ui.handlers.RerunActionHandler$RerunHandlerJob.run(RerunActionHandler.java:182) >>> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) >>> >>> >>> private void prepareCas(CAS cas) { >>> if (!includedTypes.isEmpty()) { >>> // exclude all other types if there are some included types >>> excludedTypes = new ArrayList<String>(); >>> List<Type> types = >>> cas.getTypeSystem().getProperlySubsumedTypes(cas.getAnnotationType()); >>> for (Type type : types) { >>> if (!includedTypes.contains(type.getName())) { >>> excludedTypes.add(type.getName()); >>> } >>> } >>> } >>> if (includedTypes.isEmpty() && excludedTypes.isEmpty()) { >>> // remove all annotation in default settings >>> String documentText = cas.getDocumentText(); >>> cas.reset(); >>> cas.setDocumentText(documentText); >>> } else { >>> List<AnnotationFS> toRemove = new LinkedList<AnnotationFS>(); >>> AnnotationIndex<AnnotationFS> annotationIndex = >>> cas.getAnnotationIndex(); >>> for (AnnotationFS annotationFS : annotationIndex) { >>> Type type = annotationFS.getType(); >>> String typeName = type.getName(); >>> if (includedTypes.contains(typeName) || >>> !excludedTypes.contains(typeName)) { >>> toRemove.add(annotationFS); >>> } >>> } >>> for (AnnotationFS each : toRemove) { >>> if (!cas.getDocumentAnnotation().equals(each)) { >>> cas.removeFsFromIndexes(each); >>> } >>> } >>> } >>> } >>> >
