You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by José Tomás Atria <jt...@gmail.com> on 2015/04/10 20:29:12 UTC
ClassCastException when passing String[] parameters to external resource.
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
Re: ClassCastException when passing String[] parameters to external resource.
Posted by José Tomás Atria <jt...@gmail.com>.
Hi Richard,
Thanks a lot for the pointers. I'll take a look at the code and docs and
figure out how best to procede.
Best,
jta
On Fri, Apr 10, 2015 at 2:41 PM, Richard Eckart de Castilho <re...@apache.org>
wrote:
> 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 <jt...@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
>
>
--
entia non sunt multiplicanda praeter necessitatem
Re: ClassCastException when passing String[] parameters to external resource.
Posted by Richard Eckart de Castilho <re...@apache.org>.
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 <jt...@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