This is an automated email from the ASF dual-hosted git repository. rec pushed a commit to branch bugfix/235-Misleading-error-message-when-JCas-type-is-not-registered in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
commit 2f6316ecd14487724e79d37114ecd1b8e1e482c1 Author: Richard Eckart de Castilho <[email protected]> AuthorDate: Fri Jul 29 13:46:41 2022 +0200 Issue #235: Misleading error message when JCas type is not registered - Add new message - Use this message when an unregistered but defined type is being used --- .../src/main/java/org/apache/uima/cas/CASRuntimeException.java | 7 +++++++ .../src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java | 2 +- .../resources/org/apache/uima/UIMAException_Messages.properties | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java b/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java index 643ce8c6b..47e4282f9 100644 --- a/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java +++ b/uimaj-core/src/main/java/org/apache/uima/cas/CASRuntimeException.java @@ -121,11 +121,18 @@ public class CASRuntimeException extends UIMARuntimeException { * supertypes "{3}". */ public static final String JCAS_MISMATCH_SUPERTYPE = "JCAS_MISMATCH_SUPERTYPE"; + /** * JCas type "{0}" used in Java code, but was not declared in the XML type descriptor. */ public static final String JCAS_TYPE_NOT_IN_CAS = "JCAS_TYPE_NOT_IN_CAS"; + /** + * JCas type "{0}" defined in CAS type system and used in Java code, but was not registered in + * JCasRegistry. + */ + public static final String JCAS_TYPE_NOT_IN_CAS_REGISTRY = "JCAS_TYPE_NOT_IN_CAS_REGISTRY"; + /** * CAS type system type "{0}" defines field "{1}" with range "{2}", but JCas class has range * "{3}". diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java b/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java index 1bea514f8..2c31e9b5d 100644 --- a/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java +++ b/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java @@ -2736,7 +2736,7 @@ public class TypeSystemImpl implements TypeSystem, TypeSystemMgr, LowLevelTypeSy "Missing UIMA type, JCas Class name: %s, index: %d, jcasRegisteredTypes size: %d%n", className, typeindex, jcasRegisteredTypes.size()); dumpTypeSystem(); - throw new CASRuntimeException(CASRuntimeException.JCAS_TYPE_NOT_IN_CAS, className); + throw new CASRuntimeException(CASRuntimeException.JCAS_TYPE_NOT_IN_CAS_REGISTRY, className); } else { throw new CASRuntimeException(CASRuntimeException.JCAS_UNKNOWN_TYPE_NOT_IN_CAS); } diff --git a/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties b/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties index 1898db0ed..71df49ed0 100644 --- a/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties +++ b/uimaj-core/src/main/resources/org/apache/uima/UIMAException_Messages.properties @@ -557,6 +557,7 @@ JCAS_CAS_NOT_V3 = JCas Class "{0}", loaded from "{1}", is missing required const JCAS_MISSING_FIELD_ACCESSOR = JCas Class "{0}" is missing required field accessor, or access not permitted, for field "{1}" during {2} operation. JCAS_CAS_MISMATCH = CAS type system doesn''t match JCas Type definition for type "{0}". JCAS_TYPE_NOT_IN_CAS = JCas type "{0}" used in Java code, but was not declared in the XML type descriptor. +JCAS_TYPE_NOT_IN_CAS_REGISTRY = JCas type "{0}" defined in CAS type system and used in Java code, but was not registered in JCasRegistry. JCAS_UNKNOWN_TYPE_NOT_IN_CAS = Unknown JCas type used in Java code but was not declared or imported in the XML descriptor for this component. JCAS_FIELD_MISSING_IN_TYPE_SYSTEM = JCAS class "{0}" defines a UIMA field "{1}" but the UIMA type doesn''t define that field. JCAS_FIELD_ADJ_OFFSET_CHANGED = In JCAS class "{0}", UIMA field "{1}" was set up when this class was previously loaded and initialized, to have an adjusted offset of "{2}" but now the feature has a different adjusted offset of "{3}"; this may be due to something else other than type system commit actions loading and initializing the JCas class, or to having a different non-compatible type system for this class, trying to use a common JCas cover class, which is not supported.
