1 Reply Latest reply on Apr 1, 2009 3:03 PM by alwu-Oracle

    Jena Adaptor: possible bug in Graph.contains()

    691732
      I'm getting some weird failures in some test cases after porting some existing Jena client code to use the Oracle back-end, and I think I've isolated it to an apparent bug in the GraphOracleSem.contains(Node, Node, Node) method. The method does not appear to find existing triples when one of the nodes is a URI ending in a slash ("/"). I have the following test code:

      +=== Begin Java code trace ===+
      FileInputStream fis = new FileInputStream("C:/test.owl");
      GraphOracleSem graph = new GraphOracleSem(oracle, "TEST_MODEL");
      ModelOracleSem model = new ModelOracleSem(graph);

      try {
      model.enterCriticalSection(Lock.WRITE);
      model.read(fis, baseUri, "RDF/XML-ABBREV");
      model.commit();
      } catch (Exception e) {
      model.abort();
      } finally {
      model.leaveCriticalSection();
      }
                     
      Node n = Node.createURI( "http://www.example.com/test1/" );
      if (graph.contains(n, Node.ANY, Node.ANY)) {
      System.out.println("Found node: " + n);
      } else {
      System.out.println("Did NOT find node: " + n);
      }
           
      n = Node.createURI( "http://www.example.com/test2" );
      if (graph.contains(n, Node.ANY, Node.ANY)) {
      System.out.println("Found node: " + n);
      } else {
      System.out.println("Did NOT find node: " + n);
      }
      +=== End Java code trace ===+

      And the following contents for test.owl:
      +=== Begin OWL file ===+
      <?xml version="1.0" encoding="UTF-8"?>
      <rdf:RDF
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
      xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
      xmlns:owl="http://www.w3.org/2002/07/owl#">

      <owl:Ontology rdf:about="http://www.example.com/test1/">
           <rdfs:label>Test Ontology</rdfs:label>
           <rdfs:comment>An example of an OWL ontology.</rdfs:comment>
      </owl:Ontology>

      <owl:Ontology rdf:about="http://www.example.com/test2">
           <rdfs:label>Test Ontology 2</rdfs:label>
           <rdfs:comment>Another example of an OWL ontology.</rdfs:comment>
      </owl:Ontology>

      </rdf:RDF>
      +=== End OWL file ===+

      Running the test code generates the following output:

      Did NOT find node: http://www.example.com/test1/
      Found node: http://www.example.com/test2

      As you can see, the only difference between the way the two resources are defined is that the URI of one ends in a slash and the other doesn't. Is this indeed a bug in the Oracle Jena adaptor? Are there any workarounds to get this working with my existing data? Thanks.