简体   繁体   English

尝试将 xmi 反序列化为 CAS 对象时出现 XCASParsingException

[英]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;我已经让 Ruta 脚本从 Java 运行,并将生成的 CAS 对象转换为一个 xmi 文件,如下所示;

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;当我尝试将其转换回 CAS 对象(在另一台服务器上)时,如下所示;

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 CAS 转 XMI

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

XMI to CAS XMI 转 CAS

CasIOUtils.load(fileInputStream, cas);

This issue occurs when there's really something wrong with your XMI file.当您的 XMI 文件确实有问题时,就会出现此问题。

Tip: Another way of opening XMI files might be by using XmiReader .提示:另一种打开 XMI 文件的方法可能是使用XmiReader

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试反序列化对象时出错 - Error while trying to deserialize object 尝试反序列化序列化的 object 时发生 ClassCastException - ClassCastException occurs while trying to deserialize the serialized object 如何将自定义注释转换为UIMA CAS结构并将它们序列化为XMI - How to convert custom annotations to UIMA CAS structures and serialize them to XMI 如何将输出xmi / cas传递给UIMA Ruta引擎? - How to pass an output xmi/cas to UIMA Ruta engine? 尝试反序列化json时获取NullPointerException - Getting NullPointerException while trying to deserialize json 尝试反序列化通过蓝牙发送的对象 - Trying to deserialize object sent over bluetooth 尝试在Jackson中反序列化时获取“无法构造实例” - Getting 'cannot construct instance' while trying to deserialize in Jackson 尝试反序列化日期对象时出现Hazelcast序列化异常 - Hazelcast Serialization Exception when trying to deserialize date object “无法反序列化对象”在点火缓存中插入对象时发生错误 - “Failed to deserialize object” Error occured while inserting object in ignite cache 从Firestore读取嵌套对象时出现“RuntimeException:无法反序列化对象” - “RuntimeException: Could not deserialize object” while reading nested object from Firestore
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM