UIMA Ruta: JCas cannot be initialized/Script cannot be found

235 views Asked by At

I try to integrate a UIMA Ruta script (Main.ruta) in an uimaFIT-pipeline (inMain.java) but the script cannot be found. This is my project structure:

uima-ruta-maven-test-project/src/main/Main.java
uima-ruta-maven-test-project/script/ruta/Main.ruta
uima-ruta-maven-test-project/descriptor/ruta/MainEngine.xml

Here is my code to create the AnalysisEngineDescription:

File file = new File("descriptor/ruta/MainEngine.xml");

AnalysisEngineDescription rutaScript = AnalysisEngineFactory.createEngineDescriptionFromPath(
                    file.getPath(),
                    RutaEngine.PARAM_SCRIPT_PATHS, "script",
                    RutaEngine.PARAM_MAIN_SCRIPT, "Main.ruta");

And this is my console output:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
org.apache.uima.resource.ResourceInitializationException: Initialization of annotator class "org.apache.uima.ruta.engine.RutaEngine" failed.  (Descriptor: file:/D:/Programming/MA/uima-ruta-maven-test-project/descriptor/ruta/MainEngine.xml)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:260)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:173)
    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:289)
    at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:417)
    at org.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:435)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
    at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:192)
    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:289)
    at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:341)
    at org.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:458)
    at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:178)
    at Main.main(Main.java:52)
Caused by: org.apache.uima.resource.ResourceInitializationException
    at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:579)
    at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.lambda$callInitializeMethod$2(AnalysisEngineImplBase.java:612)
    at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.withContexts(AnalysisEngineImplBase.java:653)
    at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.callInitializeMethod(AnalysisEngineImplBase.java:612)
    at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:252)
    ... 16 more
Caused by: org.apache.uima.analysis_engine.AnalysisEngineProcessException
    at org.apache.uima.ruta.engine.RutaEngine.initializeScript(RutaEngine.java:857)
    at org.apache.uima.ruta.engine.RutaEngine.initialize(RutaEngine.java:576)
    ... 20 more
Caused by: java.io.FileNotFoundException: Script [Main.ruta] cannot be found at [script;D:\Programming\MA\uima-ruta-maven-test-project] or classpath with extension .ruta
    ... 22 more

The last line of my console output seems to show the error. Main.ruta is searched in the path [script;D:\Programming\MA\uima-ruta-maven-test-project] which obviously doesn't exist because it is an invalid path. What I'm thinking is that the method createEngineDescriptionFromPath should append the "script" folder to the project path. But instead it prepends it.

Can someone help me with this, please?

EDIT

I have found this link to the documentation where the usage of the parameters mainScript and scriptPaths is explained. The paths have to be written with "." instead of "/".

I changed my code as follows:

AnalysisEngineDescription rutaScript = AnalysisEngineFactory.createEngineDescriptionFromPath(
                    file.getPath(),
                    RutaEngine.PARAM_SCRIPT_PATHS, "script.ruta",
                    RutaEngine.PARAM_MAIN_SCRIPT, "script.ruta.Main");

But now I am getting this console output:

Exception in thread "main" org.apache.uima.cas.CASRuntimeException: The JCas cannot be initialized.  The following errors occurred: 
JCas Class "org.apache.uima.ruta.type.AnyLine", loaded from "jar:file:/C:/Users/user/.m2/repository/org/apache/uima/ruta-typesystem/2.7.0/ruta-typesystem-2.7.0.jar!/org/apache/uima/ruta/type/AnyLine.class", is missing required constructor; likely cause is wrong version (UIMA version 3 or later JCas required).
JCas Class "org.apache.uima.ruta.type.EmptyLine", loaded from "jar:file:/C:/Users/user/.m2/repository/org/apache/uima/ruta-typesystem/2.7.0/ruta-typesystem-2.7.0.jar!/org/apache/uima/ruta/type/EmptyLine.class", is missing required constructor; likely cause is wrong version (UIMA version 3 or later JCas required).
JCas Class "org.apache.uima.ruta.type.WSLine", loaded from "jar:file:/C:/Users/user/.m2/repository/org/apache/uima/ruta-typesystem/2.7.0/ruta-typesystem-2.7.0.jar!/org/apache/uima/ruta/type/WSLine.class", is missing required constructor; likely cause is wrong version (UIMA version 3 or later JCas required).
...
at org.apache.uima.cas.impl.FSClassRegistry.reportErrors(FSClassRegistry.java:1284)
at org.apache.uima.cas.impl.FSClassRegistry.loadJCasForTSandClassLoader(FSClassRegistry.java:400)
at org.apache.uima.cas.impl.FSClassRegistry.getGeneratorsForClassLoader(FSClassRegistry.java:1320)
at org.apache.uima.cas.impl.TypeSystemImpl.getGeneratorsForClassLoader(TypeSystemImpl.java:2924)
at org.apache.uima.cas.impl.TypeSystemImpl.commit(TypeSystemImpl.java:1442)
at org.apache.uima.cas.impl.CASImpl.commitTypeSystem(CASImpl.java:1822)
at org.apache.uima.util.CasCreationUtils.doCreateCas(CasCreationUtils.java:620)
at org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:292)
at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:181)
at Main.main(Main.java:52)

It seems like the Ruta types cannot be initialized. I have UIMA Ruta version 2.7.0 and DKPro 2.0.0 in my pom.xml.

1

There are 1 answers

0
TheFrisbee On BEST ANSWER

It seems like UIMA Ruta 2 doesn't fit together well with UIMA v3 and other libraries that rely on it (uimaFit, DKPro in this case).

I got it to work in my case with the following versions: DKPro 1.11.0, UIMA 2.10.4, UIMA Ruta 2.7.0 and uimaFit 2.4.0 (see also this question).

UIMA Ruta 3 was recently released. I guess this version will work together better with UIMA v3.