Я пытаюсь преобразовать объект JCas (org. apache .uima.jcas.JCas) в строку json, используя Джексон ObjectMapper следующим образом.
public Map<String, List<CuiResponse>> process(final String text) throws ServletException {
JCas jcas = null;
Map<String, List<CuiResponse>> resultMap = null;
if (text != null) {
try {
jcas = _pool.getJCas(-1);
jcas.setDocumentText(text);
_engine.process(jcas);
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(jcas);
resultMap = formatResults(jcas);
_pool.releaseJCas(jcas);
} catch (Exception e) {
throw new ServletException(e);
}
}
return resultMap;
}
Но я получаю бесконечную рекурсию исключение, как показано ниже
"timestamp": "2020-02-04T10:41:33.342+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Infinite recursion (StackOverflowError) (through reference chain: org.apache.uima.cas.impl.TypeSystemImpl[\"features\"]->org.apache.uima.cas.impl.FeatureImpl[\"range\"]->org.apache.uima.cas.impl.TypeImpl[\"typeSystem\"]->org.apache.uima.cas.impl.TypeSystemImpl[\"features\"]->org.apache.uima.cas.impl.FeatureImpl[\"range\"]->org.apache.uima.cas.impl.TypeImpl[\"typeSystem\"]->org.apache.uima.cas.impl.TypeSystemImpl[\"features\"]->org.apache.uima.cas.impl.FeatureImpl[\"range\"]->org.apache.uima.cas.impl.TypeImpl[\"typeSystem\"]->org.apache.uima.cas.impl.TypeSystemImpl[\"features\"]->org.apache.uima.cas.impl.FeatureImpl[\"range\"]->org.apache.uima.cas.impl.TypeImpl[\"typeSystem\"]->org.apache.uima.cas.impl.TypeSystemImpl[\"features\"]->org.apache.uima.cas.impl.FeatureImpl[\"range\"]->org.apache.uima.cas.impl.TypeImpl[\"typeSystem\"]->org.apache.uima.cas.impl.TypeSystemImpl[\"features\"]->org.apache.uima.cas.impl.FeatureImpl[\"range\"]->org.apache.uima.cas.impl.TypeImpl[\"typeSystem\"]->org
Кто-нибудь может предложить решение?