uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <...@apache.org>
Subject Re: ClassCastException when passing String[] parameters to external resource.
Date Fri, 10 Apr 2015 18:41:48 GMT
Hi,

there are different variations of shared/external resources:

* based on Resource_ImplBase - currently only supports String values
* based on SharedResourceObject - should support the typical value types also supported for
readers and AEs

Unfortunately, the support for the SharedResourceObject-kind is not (yet) great. 
It requires some hacking around. Both approaches are documented in the Guide:

http://uima.apache.org/d/uimafit-current/tools.uimafit.book.html#d5e485

For more "examples", you could check out the ExternalResourceFactoryTest in the uimaFIT code
base.

Cheers,

-- Richard

On 10.04.2015, at 20:29, José Tomás Atria <jtatria@gmail.com> wrote:

> Hello all,
> 
> I'm getting this error when trying to pass values to a
> @ConfiugrationParameter over a String[] field in a Resource
> implementation...
> 
> Exception in thread "main" java.lang.ClassCastException:
> [Ljava.lang.String; cannot be cast to java.lang.String
> at
> org.apache.uima.fit.factory.ExternalResourceFactory.createExternalResourceDescription(ExternalResourceFactory.java:177)
> at
> org.apache.uima.fit.factory.ExternalResourceFactory.createExternalResourceDescription(ExternalResourceFactory.java:122)
> 
> In the debugger, I can see that starting at line 175 in
> ExternalResourceFactory:
> 
>          Parameter param = new Parameter_impl();
>          param.setName((String) aParams[i * 2]);
>          param.setValue((String) aParams[i * 2 + 1]);
>          params.add(param);
> 
> aParams[i * 2] correctly resolves to the param key, while aParams[i * 2 +
> 1] resolves to the full string array, so param.setValue( (String) aParams[i
> * 2 + 1 ]) fails with the above class cast exception.
> 
> I remember it being possible to pass String[]'s as values for
> ConfigurationParameters passed to AnalysisEngineFactory... is this usage
> not supported for external resources or am i doing something wrong?
> 
> Thanks!
> ​jta​
> 
> -- 
> entia non sunt multiplicanda praeter necessitatem


Mime
View raw message