uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Eckart de Castilho (JIRA)" <...@uima.apache.org>
Subject [jira] [Commented] (UIMA-3253) TypeSystemDescription throws ClassCastException
Date Mon, 09 Sep 2013 10:48:56 GMT

    [ https://issues.apache.org/jira/browse/UIMA-3253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13761759#comment-13761759
] 

Richard Eckart de Castilho commented on UIMA-3253:
--------------------------------------------------

Do I understand correctly that you create an engine from the aggregate builder, call process(jCas)
on it and then try to access the result of the aggregate in your main code using your step
4?

You could try to call the UIMA CasCreationUtils directly to set your classloader on the jCas

{noformat}
JCas jCas = CasCreationUtils.(typeSystemDescription, null, null, null, resourceMananger)
{noformat}

but I do not think that it would make it better, because your main programm still may not
use this classloader. If you main programm used this classloader, then it should not be necessary
to create and configure your own ResourceManager + Classloader in the first place.

In the place (*), it looks like Word.class was loaded using one class loader and Annotation.class
was loaded using another, unrelated one. Thus, Word cannot be cast to Annotation, even though
Word would "normally" inherit from Annotation.

I'm afraid, I don't know what chapter 5.6.7 of the UIMA Tutorial you reference. There is no
such chapter here: http://uima.apache.org/d/uimaj-2.4.2/tutorials_and_users_guides.html
                
> TypeSystemDescription throws ClassCastException
> -----------------------------------------------
>
>                 Key: UIMA-3253
>                 URL: https://issues.apache.org/jira/browse/UIMA-3253
>             Project: UIMA
>          Issue Type: Bug
>          Components: uimaFIT
>            Reporter: alina
>
> Hi all!
> We have received a strange Exception from the Type system of uimafit maybe you can help
us to fix it.
> 1. First we loaded the type system from different xml-files like this:
> typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
>                     "app/models/linguistic/descriptors/LexicalUnits.xml",
>                     "app/models/linguistic/descriptors/Punctuation.xml",
>                     "app/models/linguistic/descriptors/Word.xml",
>                     ...);
> 2. Then we created JCAS document 
> JCas jCas = JCasFactory.createJCas(typeSystemDescription);      
> 3. Then we loaded the pipeline through aggregator like this: 
> AggregateBuilder builder = new AggregateBuilder();
>         // create resource manager
>         SimpleNamedResourceManager resourceManager = new SimpleNamedResourceManager();
       resourceManager.setExtensionClassPath(Play.application().classloader(), "", true);
>         // build pipeline
>         builder.add(createPrimitiveDescription(LanguageAnnotator.class));
> 4. And then we wanted to iterate the annotations of the daugther type which was created
in one of the annotators:
> Collection<Word> col = JCasUtil.select(jCas, Word.class);
> (*) for (Word word: col){...}
> => In this place (* ) the system threw the ClassCastException, that Annotation.class
cannot be casted to Word.class.
> Inside any annotator the same lines don't throw any exception, this happens in the main
program only. 
> What could we do wrong?
> The problem may lay in the resource loading, since we use ResourceManager which loads
the classes for the types from the PLAY (Web framework) Class loader. Maybe we have to set
the ResourceManager also for JCas? 
> Maybe our problem is described in chapter 5.6.7 of the UIMA Tutorial but in this case
we also don't understand what to do.
> We use IntelliJ IDEA and MacOS.
> Thank you for your help.    

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message