ontodev / robot

ROBOT is an OBO Tool
http://robot.obolibrary.org
BSD 3-Clause "New" or "Revised" License
259 stars 73 forks source link

Integration of Robot in other tools (through maven jars) breaks with 1.7.1 #759

Open bjonnh opened 3 years ago

bjonnh commented 3 years ago

Looks like something changed in 1.7.1 (worked well in 1.7.0):

Exception in thread "main" java.lang.NoClassDefFoundError: org/openrdf/rio/RDFHandler

looks like one of the dependencies is not included anymore in 1.7.1?

bjonnh commented 3 years ago

Looks like the integration of Whelk broke ELK… (org.openrdf.sesame:sesame-rio-api:2.8.11 was present in 1.7.0 and providing that)

bjonnh commented 3 years ago

Interestingly your fat-jar doesn't have that issue, so it really is just the maven artifacts that are missing sesame.

bjonnh commented 3 years ago

Adding manually some sesame dependencies I can reach a:

Exception in thread "main" java.lang.NoSuchMethodError: 'void org.semanticweb.owlapi.rio.RioRenderer.<init>(org.semanticweb.owlapi.model.OWLOntology, org.openrdf.rio.RDFHandler, org.semanticweb.owlapi.model.OWLDocumentFormat, org.openrdf.model.Resource[])'
    at org.obolibrary.robot.QueryOperation.loadOntologyAsModel(QueryOperation.java:134)

Tried to add: net.sourceforge.owlapi:owlapi-distribution:4.5.17 as well but it still cannot find it either

balhoff commented 3 years ago

@bjonnh instead of specifying sesame dependencies, please try specifying the version of OWL API used by ROBOT (4.5.6).

I think this is a result of a change in OWL API that happened with 4.5.17. They switched from sesame to rdf4j, and there are some incompatibilities. Whelk depends on OWL API 4.5.18 (simply because it is the latest 4.x), but because ROBOT directly depends on a specific version of OWL API, it overrides it in its own build.

How this is resolved also depends on your build tool. In another project that I build with SBT, I had to take an extra step to ensure that OWL API didn't go past 4.5.16: https://github.com/balhoff/blazegraph-runner/blob/10d9ef41f6f2c3d8aedf16a0811ea0b1c8728db3/build.sbt#L37-L38

ROBOT usually tries to match the OWL API version used by Protégé, although this issue complicates things; I think interoperability issues will be a problem until most projects switch over to the rdf4j version. There is also a bug fix we would like to get from 4.5.16 or 4.5.17 related to loading OBO files directly off the web.

bjonnh commented 3 years ago

Thanks!

It seems that the maven pom of 1.7.1 is different from the 1.7.0 one…

I'm using Gradle (KTS). If I exclude owlapi from robot 1.7.1 then I can specify my own version. Looks like one dependency of 1.7.1 is trying to load 4.5.17…

implementation("org.obolibrary.robot:robot-core:1.7.1") {
        exclude("org.slf4j")
        exclude("net.sourceforge.owlapi")
    }
implementation("net.sourceforge.owlapi:owlapi-distribution:4.5.16")

This solves it for me…

Do we have an idea of what dependencies of ROBOT are holding us back?

balhoff commented 3 years ago

One file in ROBOT uses Sesame classes, but migrating to rdf4j is easy (I just tried it):

https://github.com/ontodev/robot/blob/8a9313440fb18819dd4db29b9bae6da435e9dc74/robot-core/src/main/java/org/obolibrary/robot/QueryOperation.java#L20-L25

However there are 2 failing ROBOT tests caused by OWL API 4.5.10, and 2 more caused by 4.5.13, unrelated to the Sesame issue. I don't think anyone has looked at these closely yet.

bjonnh commented 3 years ago

Similarly, I have a :

[ERROR] org.semanticweb.owlapi.utilities.Injector: No instantiation found for org.semanticweb.owlapi.model.OWLOntologyBuilder arg0
[ERROR] org.semanticweb.owlapi.utilities.Injector: Instantiation failed

when trying to convert to obo.

And it looks like an issue Protégé also has: Protege #974

balhoff commented 3 years ago

I filed an OWL API issue related to at least two of the test failures I mentioned: https://github.com/owlcs/owlapi/issues/984