I found that the root cause of the NPE seems to be that in the first
"initialize(aContext)" call, the implementation makes no call to
super.initialize(aContext), which, in turn would have saved the context in a
place where other parts of the framework (e.g., the default reconfigure method),
expect to find it.

I don't think this is an issue just for older API use.

It seems to me that the framework should arrange to save the context (without
depending on user annotator code to call super.initialize(aContext)), or
alternatively, not depend on it being saved.

-Marshall

On 9/1/2010 12:20 PM, Tommaso Teofili wrote:
> Hi Marshall,
> I figured out that the issue regards the reconfigure() method within the old
> API.
> In fact in my use case I instantiate an aggregate AE which includes also a
> SnowballAnnotator, after the first processing (no problem here) I don't
> recreate the AE each time but only reconfigure it and that's where Snowball
> fails.
> I made the following test with the not-patched code:
>
> try {
>
>       AnalysisEngine ae = null;
>
>       XMLInputSource in = new XMLInputSource("desc/SnowballAnnotator.xml");
>
>       ResourceSpecifier specifier =
>> UIMAFramework.getXMLParser().parseResourceSpecifier(in);
>
>>       ae = UIMAFramework.produceAnalysisEngine(specifier);
>
>
>       CAS cas =
>> AnnotatorTester.getCASfromXCAS(JUnitExtension.getFile("typesystem.xml"),
>> JUnitExtension.getFile("englishXCAS.xml"));
>
>
>       ae.process(cas);
>
>
>
>       ae.reconfigure();
>
>     } catch (Exception e) {
>
>       fail();
>
>     }
>
>
> and it fails; instead the bar is green with the patched version.
> Hope this helps.
> Cheers,
> Tommaso
>
>
> 2010/8/31 Marshall Schor <[email protected]>
>
>>  Hi Tommaso,
>>
>> Can you say more about the initialize() occasional failure?
>>
>> I'm curious as to what the failure is, and if you have any thoughts as to
>> why is
>> it "occasional"?  I took a quick look at the patch, but may have missed the
>> part
>> that addressed the occasional failure...
>>
>> Thanks!  -Marshall
>>
>> On 8/28/2010 6:48 AM, Tommaso Teofili wrote:
>>> H all,
>>> I noticed the SnowballAnnotator is extending the deprecated
>>> JTextAnnotator_ImplBase, have some unused imports and generics should be
>>> enabled.
>>> Moreover the initialize() method occasionally fails due to the
>>> AnnotatorContext object being null when run in a 2.3.1-SNAPSHOT
>>> distribution.
>>> I made a patch to make it extend JCasAnnotatorImpl_Base (and some little
>>> refactorings [1]) that fixed this situation, but I would like to know if
>>> anyone has experienced it and if have any objections on applying such a
>>> patch.
>>> Regards,
>>> Tommaso
>>>
>>> [1] : https://issues.apache.org/jira/browse/UIMA-1861
>>>

Reply via email to