Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError: javax/xml/bind/annotation/adapters/HexBinaryAdapter #620

Open
davidboweninrupt opened this issue Aug 25, 2023 · 4 comments
Assignees
Labels
Milestone

Comments

@davidboweninrupt
Copy link

davidboweninrupt commented Aug 25, 2023

Describe the bug

When using anonymous resources with generated labels an error is raised because the HexBinaryAdapter is not available.

To Reproduce

Steps to reproduce the behavior:

  1. git clone --branch v1.4.19 https://github.com/dgarijo/Widoco.git
  2. docker build -t widoco-issue-620 Widoco/
  3. Create ontology.ttl using the examples below
  4. docker run --rm -v "$(pwd)":/usr/local/widoco/in widoco-issue-620 -ontFile in/ontology.ttl
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/adapters/HexBinaryAdapter
        at org.eclipse.rdf4j.rio.helpers.AbstractRDFParser.createNode(AbstractRDFParser.java:464)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseNodeID(TurtleParser.java:1120)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseValue(TurtleParser.java:586)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseObject(TurtleParser.java:462)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseObjectList(TurtleParser.java:390)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parsePredicateObjectList(TurtleParser.java:385)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseTriples(TurtleParser.java:350)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parseStatement(TurtleParser.java:217)
        at org.eclipse.rdf4j.rio.turtle.TurtleParser.parse(TurtleParser.java:179)
        at org.semanticweb.owlapi.rio.RioParserImpl.parseDocumentSource(RioParserImpl.java:186)
        at org.semanticweb.owlapi.rio.RioParserImpl.parse(RioParserImpl.java:134)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:195)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1105)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1055)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1011)
        at widoco.WidocoUtils.loadModelToDocument(WidocoUtils.java:70)
        at widoco.gui.GuiController.<init>(GuiController.java:275)
        at widoco.gui.GuiController.main(GuiController.java:528)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.adapters.HexBinaryAdapter
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base

Expected behavior

Documentation should have been generated

Additional context

Note that it fails if the name starts with an n and then some hex, or even if it's just plain hex.

A simple working ontology

prefix dcterms: <http://purl.org/dc/terms/>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix schema: <https://schema.org/>

<example> a owl:Ontology ;
    rdfs:label "Example"@en ;
    dcterms:creator _:org ;
    dcterms:contributor _:org .

_:org a schema:Organization ;
    schema:name "Example Org" ;
    schema:url <https://example.org> .

A simple failing ontology

prefix dcterms: <http://purl.org/dc/terms/>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix schema: <https://schema.org/>

<example> a owl:Ontology ;
    rdfs:label "Example"@en ;
    dcterms:contributor _:n8ee89f13b89c45248946be6e748b80b4b1 ;
    dcterms:creator _:n8ee89f13b89c45248946be6e748b80b4b1 .

_:n8ee89f13b89c45248946be6e748b80b4b1 a schema:Organization ;
    schema:name "Example Org" ;
    schema:url <https://example.org> .
@dgarijo
Copy link
Owner

dgarijo commented Aug 25, 2023 via email

@davidboweninrupt
Copy link
Author

Hi @dgarijo

Have you tried declaring the bnodes with []?

Yes, that works fine. It's only in this strange edge case that it goes wrong which is why I thought you might be interested.

Rather fortunately the error is completely reproducible using the test case which at least means you won't be trying to guess how to make it happen. As it's so small I thought it might make a nice test case to ensure it behaves nicely in the future.

I wasn't sure if you would want to change the API you were using or chase the classpath fun. As you say, sometimes it's surprising what the code pulls in.

ofc I've been able to work around this by stabilising my input so I don't trip over this, so feel free to take a bit of time investigating this.

Thanks for getting back to me so quickly.

@davidboweninrupt
Copy link
Author

BTW it looks as though the parsers that are constructed and used in owlapi, such as TurtleParser are in the rdf4j package when it's running, but I suspect you are anticipating it loading the owlapi TurtleParser.

The jar certainly appears to contain them both:

$ docker run -it --entrypoint=jar widoco-issue-620 tf /usr/local/widoco/widoco.jar | grep TurtleParser.class
org/semanticweb/owlapi/rdf/turtle/parser/TurtleParser.class
org/eclipse/rdf4j/rio/turtle/TurtleParser.class

I can confirm the problematic behaviour goes as far back as v1.4.17 when I build the jar today. I can't get v1.4.16 to build and v1.4.15 didn't container the Dockerfile.

I believe you are getting rdf4j from a transitive dependency in owlapi:

$ mvn dependency:tree
[INFO] es.oeg:widoco:jar:1.4.19
[INFO] +- org.apache.maven:maven-model:jar:3.9.0:compile
[INFO] |  \- org.codehaus.plexus:plexus-utils:jar:3.4.2:compile
[INFO] +- com.github.VisualDataWeb:OWL2VOWL:jar:0.3.5:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-web:jar:1.5.6.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter:jar:1.5.6.RELEASE:compile
[INFO] |  |  |  +- org.springframework.boot:spring-boot:jar:1.5.6.RELEASE:compile
[INFO] |  |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.6.RELEASE:compile
[INFO] |  |  |  +- org.springframework:spring-core:jar:4.3.10.RELEASE:compile
[INFO] |  |  |  \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.6.RELEASE:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.16:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.16:compile
[INFO] |  |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.16:compile
[INFO] |  |  +- org.hibernate:hibernate-validator:jar:5.3.5.Final:compile
[INFO] |  |  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  |  |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  |  |  \- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] |  |  +- org.springframework:spring-web:jar:4.3.10.RELEASE:compile
[INFO] |  |  |  +- org.springframework:spring-aop:jar:4.3.10.RELEASE:compile
[INFO] |  |  |  +- org.springframework:spring-beans:jar:4.3.10.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-context:jar:4.3.10.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-webmvc:jar:4.3.10.RELEASE:compile
[INFO] |  |     \- org.springframework:spring-expression:jar:4.3.10.RELEASE:compile
[INFO] |  +- org.apache.servicemix.bundles:org.apache.servicemix.bundles.collections-generic:jar:4.01_1:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.6:compile
[INFO] |  +- commons-io:commons-io:jar:2.5:compile
[INFO] |  +- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO] |  +- commons-cli:commons-cli:jar:1.3.1:compile
[INFO] |  \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] |     \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.30:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.7.30:compile
[INFO] +- net.sf.saxon:Saxon-HE:jar:9.4:compile
[INFO] |  +- org.jdom:jdom:jar:1.1:compile
[INFO] |  +- xom:xom:jar:1.2.5:compile
[INFO] |  |  +- xml-apis:xml-apis:jar:1.3.03:compile
[INFO] |  |  +- xerces:xercesImpl:jar:2.8.0:compile
[INFO] |  |  \- xalan:xalan:jar:2.7.0:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  \- xml-resolver:xml-resolver:jar:1.2:compile
[INFO] +- net.sourceforge.owlapi:owlapi-distribution:jar:5.1.18:compile
[INFO] |  +- net.sourceforge.owlapi:owlapi-compatibility:jar:5.1.18:compile
[INFO] |  |  \- net.sourceforge.owlapi:owlapi-apibinding:jar:5.1.18:compile
[INFO] |  |     +- net.sourceforge.owlapi:owlapi-api:jar:5.1.18:compile
[INFO] |  |     |  \- javax.inject:javax.inject:jar:1:compile
[INFO] |  |     +- net.sourceforge.owlapi:owlapi-impl:jar:5.1.18:compile
[INFO] |  |     +- net.sourceforge.owlapi:owlapi-parsers:jar:5.1.18:compile
[INFO] |  |     +- net.sourceforge.owlapi:owlapi-oboformat:jar:5.1.18:compile
[INFO] |  |     +- net.sourceforge.owlapi:owlapi-tools:jar:5.1.18:compile
[INFO] |  |     \- net.sourceforge.owlapi:owlapi-rio:jar:5.1.18:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.9.10:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.10.7:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.10:compile
[INFO] |  +- org.apache.commons:commons-rdf-api:jar:0.5.0:compile
[INFO] |  +- org.tukaani:xz:jar:1.6:compile
[INFO] |  +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-model:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-api:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-languages:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-datatypes:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-binary:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-n3:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-nquads:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-ntriples:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-rdfjson:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-jsonld:jar:3.4.3:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.10:compile
[INFO] |  |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.12:compile
[INFO] |  |  \- org.apache.httpcomponents:httpclient-cache:jar:4.5.10:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-rdfxml:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-trix:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-turtle:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-trig:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-rio-hdt:jar:3.4.3:compile
[INFO] |  +- org.eclipse.rdf4j:rdf4j-util:jar:3.4.3:compile
[INFO] |  +- com.github.jsonld-java:jsonld-java:jar:0.13.0:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient-osgi:jar:4.5.10:compile
[INFO] |  |  |  +- commons-codec:commons-codec:jar:1.11:compile
[INFO] |  |  |  +- org.apache.httpcomponents:httpmime:jar:4.5.10:compile
[INFO] |  |  |  \- org.apache.httpcomponents:fluent-hc:jar:4.5.10:compile
[INFO] |  |  \- org.apache.httpcomponents:httpcore-osgi:jar:4.4.12:compile
[INFO] |  |     \- org.apache.httpcomponents:httpcore-nio:jar:4.4.12:compile
[INFO] |  +- com.github.vsonnier:hppcrt:jar:0.7.5:compile
[INFO] |  +- com.github.ben-manes.caffeine:caffeine:jar:2.8.1:compile
[INFO] |  |  +- org.checkerframework:checker-qual:jar:3.1.0:compile
[INFO] |  |  \- com.google.errorprone:error_prone_annotations:jar:2.3.4:compile
[INFO] |  +- com.google.guava:guava:jar:30.0-jre:compile
[INFO] |  |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] |  |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  |  \- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] |  \- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] +- com.googlecode.json-simple:json-simple:jar:1.1:compile
[INFO] +- junit:junit:jar:4.13.1:test
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] ------------------------------------------------------------------------

It looks as though owlapi 5.1.18 brings it in via it's rio/pom.xml.

So to me (who doesn't know Maven) that appears to suggest it's been brought in purposefully some years ago and isn't a new transitive dependency that recently started behaving differently.

It also appears there's some OSGi config for rdf4j-rio-turtle but I'm not sure which parts of owlapi are wrapped in OSGi and which bits aren't.

Sorry I can't be more help.

@dgarijo
Copy link
Owner

dgarijo commented Aug 26, 2023

Thanks! Possible cause in https://stackoverflow.com/questions/61177573/javax-xml-bind-cannot-be-resolved. I have to test out the solution

@dgarijo dgarijo self-assigned this Sep 6, 2023
@dgarijo dgarijo added the bug label Sep 6, 2023
@dgarijo dgarijo added this to the v1.4.xx milestone Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants