Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-1979

SHACL validation: NullPointerException when shapes with sh:alternativePath importing <http://datashapes.org/dash>

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Jena 3.16.0
    • Jena 3.17.0
    • SHACL
    • None

    Description

      How to replicate

      Run

      {{Graph shapesGraph = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM).read("shapes.ttl", "TTL").getGraph();}}
      Graph dataGraph = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM).read("data.ttl", "TTL").getGraph();}}
      validator = ShaclValidator.get();
      return validator.validate(shapesGraph, dataGraph);

      Files attached.

      What is happening

      The exception happens when a property shape with sh:alternativePath is evaluated inside ConstraintComponentSPARQL. I'm not sure why however it only happens when dash/tosh shapes are imported by a shape.

      The exception seems to happen on line 239 of SparqlValidation.java:

      RDFNode z = ModelUtils.convertGraphNodeToRDFNode(ShaclPaths.pathNode(path), model);

      where pathNode() returns null - only supporting P_Link, not P_Alt and convertGraphNodeToRDFNode() then runs unchecked node.isVariable().

      Stack trace:

      parameterMapToPreBinding:239, SparqlValidation (org.apache.jena.shacl.engine.constraint)
      validateMap:122, SparqlValidation (org.apache.jena.shacl.engine.constraint)
      validate:87, SparqlValidation (org.apache.jena.shacl.engine.constraint)
      lambda$validatePropertyShape$0:69, ConstraintComponentSPARQL (org.apache.jena.shacl.engine.constraint)
      accept:-1, 1035363280 (org.apache.jena.shacl.engine.constraint.ConstraintComponentSPARQL$$Lambda$125)
      forEach:75, Iterable (java.lang)
      validatePropertyShape:68, ConstraintComponentSPARQL (org.apache.jena.shacl.engine.constraint)
      evalConstraint:264, ValidationProc (org.apache.jena.shacl.validation)
      validationPropertyShape:248, ValidationProc (org.apache.jena.shacl.validation)
      validationPropertyShapes:228, ValidationProc (org.apache.jena.shacl.validation)
      validateShape:219, ValidationProc (org.apache.jena.shacl.validation)
      simpleValidationInternal:178, ValidationProc (org.apache.jena.shacl.validation)
      simpleValidation:122, ValidationProc (org.apache.jena.shacl.validation)
      simpleValidation:109, ValidationProc (org.apache.jena.shacl.validation)
      simpleValidation:101, ValidationProc (org.apache.jena.shacl.validation)
      validate:79, ShaclSimpleValidator (org.apache.jena.shacl.validation)
      validate:91, ShaclSimpleValidator (org.apache.jena.shacl.validation)
      validate:23, mytest (com.msd.gin.mrlitdi.test)
      run:17, mytest (com.msd.gin.mrlitdi.test)
      invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
      invoke:62, NativeMethodAccessorImpl (sun.reflect)
      invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
      invoke:498, Method (java.lang.reflect)
      runReflectiveCall:50, FrameworkMethod$1 (org.junit.runners.model)
      run:12, ReflectiveCallable (org.junit.internal.runners.model)
      invokeExplosively:47, FrameworkMethod (org.junit.runners.model)
      evaluate:17, InvokeMethod (org.junit.internal.runners.statements)
      runLeaf:325, ParentRunner (org.junit.runners)
      runChild:78, BlockJUnit4ClassRunner (org.junit.runners)
      runChild:57, BlockJUnit4ClassRunner (org.junit.runners)
      run:290, ParentRunner$3 (org.junit.runners)
      schedule:71, ParentRunner$1 (org.junit.runners)
      runChildren:288, ParentRunner (org.junit.runners)
      access$000:58, ParentRunner (org.junit.runners)
      evaluate:268, ParentRunner$2 (org.junit.runners)
      run:363, ParentRunner (org.junit.runners)
      run:137, JUnitCore (org.junit.runner)
      startRunnerWithArgs:69, JUnit4IdeaTestRunner (com.intellij.junit4)
      startRunnerWithArgs:33, IdeaTestRunner$Repeater (com.intellij.rt.junit)
      prepareStreamsAndStart:220, JUnitStarter (com.intellij.rt.junit)
      main:53, JUnitStarter (com.intellij.rt.junit)

      Attachments

        1. data.ttl
          0.1 kB
          Jan Rosecky
        2. shapes.ttl
          0.8 kB
          Jan Rosecky

        Activity

          People

            andy Andy Seaborne
            jan.rosecky Jan Rosecky
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m