google-code-export / uimafit

Automatically exported from code.google.com/p/uimafit
2 stars 1 forks source link

Specifying other classes, such as FileResourceSpecifier_impl, as resource specifiers causes IllegalClassException when binding #133

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm working with ConceptMapper, which means I need to attach a 
FileResourceSpecifier to the external dictionary resource (it only took me most 
of the day to work this out).

The relevant bits of code are something like this:

AnalysisEngineDescription aed = 
AnalysisEngineFactory.createAnalysisEngineDescription(
    "analysis_engine.descriptor_name");
ExternalResourceDescription dictRes = 
    ExternalResourceFactory.createExternalResourceDescription(
    "DictionaryFileName", DictionaryResource_impl.class, "someURL");
FileResourceSpecifier frSpec = new FileResourceSpecifier_impl();
frSpec.setFileUrl("file:testDict.xml");
dictRes.setResourceSpecifier(frSpec);
ExternalResourceFactory.bindExternalResource(aed, 
    ConceptMapper.PARAM_DICT_FILE, dictRes)

This gets an IllegalClassException:

org.apache.commons.lang.IllegalClassException: Unsupported resource specifier 
class [class org.apache.uima.resource.impl.FileResourceSpecifier_impl]
    at org.uimafit.factory.ConfigurationParameterFactory.canParameterBeSet(ConfigurationParameterFactory.java:584)
    at org.uimafit.factory.ExternalResourceFactory.bindNestedResources(ExternalResourceFactory.java:839)

I think this is a spurious error; I've wrapper the call to .canParameterBeSet() 
in a try/catch, and it seems to work fine (I've now got another unrelated 
downstream problem, so I can't promise yet, but will update when I do know more)

I've attached the patch against 1.4.0 which seems to fix it

Original issue reported on code.google.com by admac...@gmail.com on 31 May 2013 at 6:30

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks! I'll look into it.

Btw. there is a createExternalResourceDescription(String name, String url) 
method which creates an ExternalResourceDescription with a 
FileResourceSpecifier. Would that work for your scenario as well? It'll still 
require your fix though, just save you lots of lines.

Original comment by richard.eckart on 31 May 2013 at 9:25

GoogleCodeExporter commented 9 years ago
Cool, I've confirmed that a) your recommended method saves me a few LOC
and b) this works fine with my p[athc, now that I've fixed the downstream 
problem.
Just wondering why the milestone is 2.0.0. Seems like a minor uncontroversial 
fix - surely it could make it into 1.5.0 (if there is no 1.4.1 planned, as I 
assume)?

Original comment by admac...@gmail.com on 20 Jun 2013 at 5:12

GoogleCodeExporter commented 9 years ago
Currently there is no plan to do a 1.5.0 or 1.4.1 release. uimaFIT has been 
contributed to the UIMA project and a lot of work has already gone in preparing 
2.0.0. We're pretty close to a release, what lack is mostly time.

So unless there's strong reasons to do a 1.x release, e.g. because some users 
cannot wait for 2.x or are unable to upgrade...  

Original comment by richard.eckart on 20 Jun 2013 at 7:02

GoogleCodeExporter commented 9 years ago
Ah, I was just confused because there's a lot of issues marked for 1.5.0 in the 
list.

(that said, if the 2.0 release is taking a while, as major revisions often do, 
and you have a bunch of uncontroversial bug fixes lying around, maybe a 1.4.1 
release is worth considering?)

Original comment by admac...@gmail.com on 20 Jun 2013 at 7:08

GoogleCodeExporter commented 9 years ago
Hi,

I am new to uimafit and have ran into the same problem. Please help me to fix 
this. I dont seem to get what to do with the patch.

Thanks in advance

Original comment by ravigar...@gmail.com on 1 Jul 2013 at 12:28

GoogleCodeExporter commented 9 years ago
Sounds like doing a 1.4.1 wouldn't be a bad idea after all....

May I ask in which context you need to work with these FileResourceSpecifiers? 
I haven't seen them used so much.

Original comment by richard.eckart on 1 Jul 2013 at 12:59

GoogleCodeExporter commented 9 years ago
Hi Richard, 

I tried to define an external resource using the following lines of code

ExternalResourceDescription erd = 
ExternalResourceFactory.createExternalResourceDescription("MaxentModelFile", 
org.apache.ctakes.core.resource.SuffixMaxentModelResourceImpl.class, 
"file:sdmed.mod");     
        Map<String,ExternalResourceDescription> sentenceExternalMap = new HashMap<String, ExternalResourceDescription>();
        sentenceExternalMap.put("MaxentModel", erd);
        AnalysisEngineDescription sentenceDetectorDesc = AnalysisEngineFactory.createPrimitiveDescription(SentenceDetector.class, null, null, null, sentenceDetectorCapabilities, null, null, sentenceExternalMap);

But while running it, gives an runtime error URI is not hierarchical. So I 
tried the above mentioned code by admac. It too gave me the same error as 
mentioned above. So I dont seem to get whats the correct method to declare 
external resource in analysis engine description. Also I cannot make changes 
the AnalysisComponent class file.

Thanks 

Original comment by ravigar...@gmail.com on 1 Jul 2013 at 5:56

GoogleCodeExporter commented 9 years ago
Moved to Apache: https://issues.apache.org/jira/browse/UIMA-3093

Applied different fix: canParameterBeSet returns false for unknown specifiers 
instead of throwing an exception.

Original comment by richard.eckart on 20 Jul 2013 at 3:11

GoogleCodeExporter commented 9 years ago

Original comment by richard.eckart on 20 Jul 2013 at 3:12