简体   繁体   中英

XCASParsingException while trying to deserialize xmi into CAS object

I have made Ruta scripts run from Java and have converted the resulting CAS object into an xmi file as below;

FileOutputStream fileOutputStream = new FileOutputStream(outputXmiFile);
XmiCasSerializer.serialize(cas, fileOutputStream);

When I try to convert it back into a CAS object (on another server), as below;

FileInputStream fileInputStream = new FileInputStream(xmiFile);
XmlCasDeserializer.deserialize(fileInputStream, cas);

I get the below exception ;

XCASParsingException: Error parsing XCAS or XMI-CAS from source <unknown> at line <unknown>, column <unknown>: unknown type: NULL.

A snapshot of the exception. 在此处输入图片说明

Ya Thanks ! It worked !

import org.apache.uima.util.CasIOUtils;

CAS to XMI

CasIOUtils.save(cas, fileOutputStream, SerialFormat.XMI);

XMI to CAS

CasIOUtils.load(fileInputStream, cas);

This issue occurs when there's really something wrong with your XMI file.

Tip: Another way of opening XMI files might be by using XmiReader .

File xmlFile = new File("/path/to/file.xmi");
CollectionReaderDescription description = createReaderDescription(
   XmiReader.class,
   XmiReader.PARAM_SOURCE_LOCATION, xmlFile
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM