Kai Schlamp wrote:
> Hy Thilo,
> 
> comment below.
> 
> Thilo Goetz wrote:
>> Kai Schlamp wrote:
>>> Hello.
>>>
>>> I use UIMA analysis engines as Eclipse plugins inside an Eclipse RCP
>>> application.
>>> Nearly everything works fine, but I can't get the resource definitions
>>> to work corretly.
>>> When trying to fetch the path of the resource in my annotators intialize
>>> method (by using getContext().getResourceFilePath("sd_model");), then I
>>> get the below exception.
>>> It must be some classpath problem (as so often with Eclipse plugins) as
>>> this analysis engine works correctly using the UIMA document analyzer.
>>
>> Resources are resolved via the classpath.  Try putting
>> the model file insided your jar and see if that helps.
>> If that works, you can maybe investigate better ways.
>> I don't know enough about Eclipse plugin programming
>> to make a definitive suggestions.
> 
> That's strange, cause the resource file is on the classpath. It's inside
> a "resources" folder of my plugin
> that has an entry in the MANIFEST.MF ("Bundle-ClassPath: resources/").
> I also registered UIMA as bundle buddy ("Eclipse-RegisterBuddy:
> org.apache.uima").
> Maybe someone else has an idea.
> I could provide a basic plugin (inclusive a test plugin) that easily
> demonstrates the problem.
> Are attachments allowed in this group?
> If not I can send it via mail if someone is interested.

Before you do that, try putting the following code
in your annotator:

    String filename = "EnglishSD.bin.gz";
    InputStream is = UIMAFramework.class.getResourceAsStream(filename);
    if (is == null) {
      System.out.println("Could not open file " + filename);
    } else {
      System.out.println("Successfully opened file " + filename);
    }

I don't know what code exactly UIMA uses to load that
resource, but if this works, loading the model as a
resource should work as well.  If on the other hand
this doesn't work, I'm not surprised that the model
can't be loaded as a resource.

--Thilo

> 
> Regards,
> Kai
> 
> 
>>
>> --Thilo
>>
>>> Here is how I define the resource in the AE descriptor:
>>>
>>> <resourceManagerConfiguration>
>>>     <externalResources>
>>>       <externalResource>
>>>         <name>english_sd_model</name>
>>>         <description/>
>>>         <fileResourceSpecifier>
>>>           <fileUrl>file:EnglishSD.bin.gz</fileUrl>
>>>         </fileResourceSpecifier>
>>>       </externalResource>
>>>     </externalResources>
>>>     <externalResourceBindings>
>>>       <externalResourceBinding>
>>>         <key>sd_model</key>
>>>         <resourceName>english_sd_model</resourceName>
>>>       </externalResourceBinding>
>>>     </externalResourceBindings>
>>>   </resourceManagerConfiguration>
>>>
>>> Should I define the fileUrl somehow different?
>>>
>>> Regards,
>>> Kai
>>>
>>>
>>> org.apache.uima.resource.ResourceAccessException
>>>     at
>>> org.apache.uima.impl.UimaContext_ImplBase.getResourceFilePath(UimaContext_ImplBase.java:226)
>>>
>>>
>>>     at
>>> org.pubcurator.analyzers.range.annotators.RangeAnnotator.initialize(RangeAnnotator.java:54)
>>>
>>>
>>>     at
>>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:251)
>>>
>>>
>>>     at
>>> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:157)
>>>
>>>
>>>     at
>>> org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
>>>
>>>
>>>     at
>>> org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
>>>
>>>
>>>     at
>>> org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:267)
>>>     at
>>> org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:335)
>>>
>>>     at
>>> org.pubcurator.analyzers.range.annotators.RangeAnnotatorTest.testProcessJCas(RangeAnnotatorTest.java:35)
>>>
>>>
>>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>     at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>
>>>
>>>     at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>>
>>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>>     at
>>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>>>
>>>
>>>     at
>>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>>>
>>>
>>>     at
>>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>>>
>>>
>>>     at
>>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>>>
>>>
>>>     at
>>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>>>
>>>
>>>     at
>>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>>>
>>>     at
>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
>>>
>>>
>>>     at
>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
>>>
>>>
>>>     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
>>>     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
>>>     at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
>>>     at
>>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>>>
>>>
>>>     at
>>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>>>
>>>     at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
>>>     at
>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
>>>
>>>
>>>     at
>>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>>
>>>
>>>     at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>>
>>>
>>>     at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>>
>>>
>>>     at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>>
>>>
>>>     at
>>> org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
>>>
>>>
>>>     at
>>> org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
>>>
>>>
>>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>     at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>
>>>
>>>     at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>>
>>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>>     at
>>> org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)
>>>
>>>
>>>     at
>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>>>
>>>
>>>     at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>>>
>>>
>>>     at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>>>
>>>
>>>     at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
>>>
>>>
>>>     at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
>>>
>>>
>>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>     at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>
>>>
>>>     at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>
>>>
>>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>>     at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
>>>     at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
>>>     at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
>>>     at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
>>

Reply via email to