You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by John Cabral <jo...@gmail.com> on 2008/03/12 04:11:32 UTC

JCasGen - Feature not Defined for Type error

I've run into a very odd error that is being thrown by my code.  I
have used the Eclipse plugin to define a type system and then used the
JCasGen tool to generate the .java files for the types.  I added 18
features to one of the types.  When I try to use the set*() methods
for them, it works in 7 cases but in the other 11 cases I will get an
error similar to this:

     [java] Exception in thread "main"
org.apache.uima.cas.CASRuntimeException: Feature "reason" is not
defined for type "amps.featurestructures.ddms.Security".
     [java]     at
org.apache.uima.jcas.impl.JCasImpl.throwFeatMissing(JCasImpl.java:996)
     [java]     at
amps.featurestructures.ddms.Security.setReason(Unknown Source)
     [java]     at amps.test.Test.main(Unknown Source)

Any ideas?  I've been reviewing the code and so far cannot tell any
difference between the methods that are working and those that are
failing.

Thank you.

Re: JCasGen - Feature not Defined for Type error

Posted by John Cabral <jo...@gmail.com>.
Well, we can close this ticket.  It turns out it was an error in the
ant file I was using.  It was pointing to an old version of the type
system descriptor file.  So, while I was updating the file I intended
to use, the ant file was looking at an old version of it. D'oh!

Thank you for the explanation and hints, Thilo.

-JC

Re: JCasGen - Feature not Defined for Type error

Posted by Thilo Goetz <tw...@gmx.de>.
John Cabral wrote:
> I've tried out that theory.  I had copied over the <typedescription>
> element for that type into the type system descriptor file used by my
> engine.  All 18 components are there and I can't see anything else in
> the file that would need to be copied over.  Actually, I just realized
> something.  The code I am using is running outside of an annotator.
> So, I just wired something together so that I can get a JCas create a
> feature structure and then add them to the JCas for the purposes of
> testing.  Is there a background assumption that feature structures
> should only be added only within an Annotator?

No, that should work outside the annotator just
as well.

Try the following: on the JCas that you're working
with (and that throws the error), grab the type
system (with getTypeSystem()) and print it out.
Something like
System.out.println(jcas.getTypeSystem());

It's not the easiest format to read, but you
should see all the features there.  If you
don't see the "reason" feature, you know that
it's not been loaded from the descriptor for
some reason.  If you do see the feature and
you still get the error, then maybe there's
an issue with your extra-annotatorial code ;-)

--Thilo


Re: JCasGen - Feature not Defined for Type error

Posted by John Cabral <jo...@gmail.com>.
I've tried out that theory.  I had copied over the <typedescription>
element for that type into the type system descriptor file used by my
engine.  All 18 components are there and I can't see anything else in
the file that would need to be copied over.  Actually, I just realized
something.  The code I am using is running outside of an annotator.
So, I just wired something together so that I can get a JCas create a
feature structure and then add them to the JCas for the purposes of
testing.  Is there a background assumption that feature structures
should only be added only within an Annotator?

Thank you for your help.

On Wed, Mar 12, 2008 at 6:34 AM, Thilo Goetz <tw...@gmx.de> wrote:
> Sounds like a version mismatch between your
>  generated Java files and the xml descriptor.
>  The CAS is complaining that it doesn't know
>  about the feature "reason", although the setter
>  is defined in the Java class.  Make sure you
>  load the right descriptor.  In CVD, you can
>  look at the type system as it is defined in
>  the CAS.
>
>  HTH,
>  Thilo
>
>
>
>  John Cabral wrote:
>  > I've run into a very odd error that is being thrown by my code.  I
>  > have used the Eclipse plugin to define a type system and then used the
>  > JCasGen tool to generate the .java files for the types.  I added 18
>  > features to one of the types.  When I try to use the set*() methods
>  > for them, it works in 7 cases but in the other 11 cases I will get an
>  > error similar to this:
>  >
>  >      [java] Exception in thread "main"
>  > org.apache.uima.cas.CASRuntimeException: Feature "reason" is not
>  > defined for type "amps.featurestructures.ddms.Security".
>  >      [java]     at
>  > org.apache.uima.jcas.impl.JCasImpl.throwFeatMissing(JCasImpl.java:996)
>  >      [java]     at
>  > amps.featurestructures.ddms.Security.setReason(Unknown Source)
>  >      [java]     at amps.test.Test.main(Unknown Source)
>  >
>  > Any ideas?  I've been reviewing the code and so far cannot tell any
>  > difference between the methods that are working and those that are
>  > failing.
>  >
>  > Thank you.
>

Re: JCasGen - Feature not Defined for Type error

Posted by Thilo Goetz <tw...@gmx.de>.
Sounds like a version mismatch between your
generated Java files and the xml descriptor.
The CAS is complaining that it doesn't know
about the feature "reason", although the setter
is defined in the Java class.  Make sure you
load the right descriptor.  In CVD, you can
look at the type system as it is defined in
the CAS.

HTH,
Thilo

John Cabral wrote:
> I've run into a very odd error that is being thrown by my code.  I
> have used the Eclipse plugin to define a type system and then used the
> JCasGen tool to generate the .java files for the types.  I added 18
> features to one of the types.  When I try to use the set*() methods
> for them, it works in 7 cases but in the other 11 cases I will get an
> error similar to this:
> 
>      [java] Exception in thread "main"
> org.apache.uima.cas.CASRuntimeException: Feature "reason" is not
> defined for type "amps.featurestructures.ddms.Security".
>      [java]     at
> org.apache.uima.jcas.impl.JCasImpl.throwFeatMissing(JCasImpl.java:996)
>      [java]     at
> amps.featurestructures.ddms.Security.setReason(Unknown Source)
>      [java]     at amps.test.Test.main(Unknown Source)
> 
> Any ideas?  I've been reviewing the code and so far cannot tell any
> difference between the methods that are working and those that are
> failing.
> 
> Thank you.