is there a way where I can write my RDF data DIRECTLY and query it via SPARQL - sparql

I'm practicing some SPARQL queries and features, my problem is that whenever I get new RDF data, I go to protoge, build classes and relationships and instances that accompany to these RDF, then explore these data, then import it to a dataset in Fuseki, then I query it.
and if I make any mistake in my data, I'd need to repeat the whole process.
It's becoming tedious and time consuming, that's why I badly need to ask you if there's a place (tool or a fuseki support plugin ... or anything ..) where I can write my simple rdf data directly and then query it from my fuseki.
that data I want to write for example is really simple, it's like this:
#prefix dei: <http://www.warsaw.pl/ > .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . 
#prefix foaf: <http://xmlns.com/foaf/0.1/> .
dei:~rcardish/
      rdf:type foaf:Person ;
      foaf:name “Rafa Cardish" ;
foaf:member <http://www.warsaw.pl> ;
      rdfs:SeeAlso <http://www.linkedin.com/in/rafacardish>
but even that simple and small rdf takes me time in my current way.
Your help is appreciated.
Update 1
Now I can do this to load my data into fuseki
./fuseki-server --file=/Users/bla bla bla/rdfData.rdf /testdataset
and this is the data
#prefix dc: <http://purl.org/dc/elements/1.1/> .
#prefix : <http://example.org/book/> .
#prefix ns: <http://example.org/ns#> .
:book1 dc:title "SPARQL Tutorial" .
:book1 ns:price 42 .
:book1 ns:discount 0.2 .
:book2 dc:title "The Semantic Web" .
:book2 ns:price 23 .
:book2 ns:discount 0.25 .
but I don't know how to query it because when i run Fuseki, i go to query and I have to select a dataset but here there is no dataset shown in the drop down
Update 2
Now it's working, my mistake is that the file extension was .ttl.rdf, when I make it .ttl alone it works

You can use command line tools (e.g. Redland tools) or write a simple script to load RDF and run SPARQL queries over it (e.g. using RDFlib):
1) Using Redland: roqet query.rq -D data.ttl -r json
Runnit it with a query for ?s dc:title ?title using your example data returns:
"bindings" : [
{
"s" : { "type": "uri", "value": "http://example.org/book/book1" },
"title" : { "type": "literal", "value": "SPARQL Tutorial" }
},
{
"s" : { "type": "uri", "value": "http://example.org/book/book2" },
"title" : { "type": "literal", "value": "The Semantic Web" }
}
]
JSON is one of result formats but you can also get CSV, etc.
See also: Command line Semantic Web with Redland
2) Using RDFlib to run SPARQL queries is also quite a compact way to do this (in Python):
import rdflib
g = rdflib.Graph()
g.parse("data.ttl", format="n3")
qres = g.query(
"""SELECT DISTINCT *
WHERE {
?s dc:title ?title .
}""")
for row in qres:
print("%s : %s" % row)
Results:
http://example.org/book/book1 : SPARQL Tutorial
http://example.org/book/book2 : The Semantic Web

You can use Jena's command line tools to run SPARQL queries easily. In the Jena distribution, there's a sparql executable with --query and --data flags. Once you have your RDF file (if you're writing by hand, I'd suggest using the Turtle/N3 serialization and giving your file the .ttl or .n3 suffix), and then it's easy to run a query. For instance, when I have a data.n3 file like this:
#prefix : <http://stackoverflow.com/a/35854800/1281433/>
<http://stackoverflow.com/users/1281433/> :hasUserName "Joshua Taylor" .
and a query.rq like this:
prefix : <http://stackoverflow.com/a/35854800/1281433/>
select ?user where {
?user :hasUserName "Joshua Taylor"
}
Then I can get output like this:
$ sparql --query query.rq --data data.n3
---------------------------------------------
| user |
=============================================
| <http://stackoverflow.com/users/1281433/> |
---------------------------------------------

Related

SHACL SPARQLTarget not validating the SPARQL query output nodes

I have a NodeShape with a sh:SPARQLTarget . I tried to run the Target SPARQL query in an ontology editor and it delivered results, but when I'm executing the same query in my custom target node shape in sh:select, it won't validate the target nodes returned by the SPARQL query. I am using pySHACL. Did I do something wrong? I'm out of ideas. Here is my Nodeshape and data graph:
I have used “” for sh:select instead of “”” “””, since I am defining the shapes_graph as a variable in my python code and it is already encoded in """ """. I have also enabled meta_shacl=True in pyShacl to ensure that my shapes_graph is valid. Also the nodeShape (snomed:dob363698007Shape) works well when provided with a normal TargetClass or TargetNode. What am I missing?
I have already referred SPARQLRule not constructing
**NodeShape**
snomed:
sh:declare [
sh:prefix "snomed" ;
sh:namespace <http://localhost:8890/snomed/> ;
] .
snomed:dob363698007Shape
a sh:NodeShape ;
sh:target [
a sh:SPARQLTarget ;
sh:prefixes snomed: ;
sh:select "SELECT ?this WHERE { ?node a snomed:24078009.?node a snomed:dob .?node snomed:609096000 ?this.?this a snomed:dob363698007 .bind(?node as ?conceptName).bind(?this as ?RGName) .FILTER(REGEX(strafter(xsd:string(?RGName),'snomed/'),strafter(xsd:string(?conceptName),'snomed/')) ).}";
] ;
sh:property [
sh:path snomed:363698007;
sh:minCount 1;
].```
**Data Graph**
```snomed:dob a rdfs:Class,snomed:dob ;
rdfs:label "Semantic Pattern dob"^^xsd:string ;
snomed:609096000 snomed:dob363698007 .
snomed:dob363698007 a rdfs:Class,snomed:dob363698007;
snomed:363698007 snomed:123037004 .
snomed:24078009 a rdfs:Class, snomed:24078009, snomed:dob;
rdfs:label "Gangosa of yaws (disorder)"^^xsd:string ;
snomed:609096000 snomed:24078009_3,snomed:24078009_5,snomed:24078009_6;
rdfs:subClassOf snomed:128349005,
snomed:140004,
snomed:177010002,
snomed:312118003,
snomed:312129004,
snomed:312422001,
snomed:363166002,
snomed:47841006,
snomed:88037009 .
snomed:24078009_3 a rdfs:Class, snomed:24078009_3, snomed:dob363698007 ;
snomed:263502005 snomed:90734009 .
snomed:24078009_5 a rdfs:Class, snomed:24078009_5,snomed:dob363698007;
snomed:116676008 snomed:110435003 ;
snomed:246075003 snomed:6246005 ;
snomed:363698007 snomed:71836000 ;
snomed:370135005 snomed:441862004 .
snomed:24078009_6 a rdfs:Class, snomed:24078009_6,snomed:dob363698007 ;
snomed:116676008 snomed:110435003 ;
snomed:246075003 snomed:6246005 ;
snomed:363698007 snomed:72914001 ;
snomed:370135005 snomed:441862004 .
I've put your shacl shapes file and data graph into PySHACL to isolate the issue you are seeing.
There are two problems with your given setup that I have found.
Firstly, SPARQL-Based Targets is a feature from the SHACL Advanced Specification. PySHACL does not enable the Advanced-Spec features by default. You can enable "advanced mode" by passing advanced=True to the validation module, or -a or --advanced on the commandline tool.
That is the main reason your SPARQL target was not selecting the nodes you expected.
Next, after enabling advanced mode, you will see that PySHACL fails when loading your SHACL Shape Graph. That is because your prefix namespace is not declared correctly.
See the examples in the SPARQL-Prefixes section of the Spec document. The specification states
"The values of sh:namespace are literals of datatype xsd:anyURI."
Your sh:namespace is a URIRef, not a Literal. Changing the namespace declaration to the following, fixes the error.
sh:namespace "http://localhost:8890/snomed/"^^xsd:anyURI ;
I've run PySHACL with the corrected Shapes Graph, and it works as expected.
See this code for a complete working example: https://gist.github.com/ashleysommer/a319beeef33973906b76711675b2635c

Is there a way to store SPARQL queries as instances in an RDF file?

I am creating a database which encodes directed acyclic graphs (DAGs), where nodes are RDF instances and edges are object properties. Ultimately, I would like to create SPARQL queries which match graph patterns in my set of DAGs. There are many (~200) subtree patterns that I am interested in and would like to somehow store these queries to execute later.
The SPARQL below is a toy example of selecting instances of DAGs having a set of nodes and connections:
SELECT ?dag
WHERE {
?dag :has_node ?n1 ;
:has_node ?n2 ;
:has_node ?n3 .
?n1 rdfs:type :Type1 ;
:parent_of ?n2 .
?n2 rdfs:type :Type2 ;
:parent_of ?n3 .
?n3 rdfs:type :Type3 .
}
Is it possible to store SPARQL queries like the one above as instances in RDF? If so, can I refer to the instance in a SPARQL query and have it translated into SPARQL? (See below)
SELECT ?dag
WHERE {
?dag :has_graph_pattern ?graphPattern .
}
The ?graphPattern variable would be an instance that would encode the same thing as the first SPARQL query.
Thanks for any feedback!
Another way to go would be using the SHACL Advanced Features vocabulary. You could store your ?dag variable as the ?this variable in a shape graph (see the section about SPARQL-Based Targets). You can then store the pattern after a sh:select predicate and use the select query as your pattern for finding your dag.
As suggested in #Roos' answer, I was able to encode my subgraphs in SHACL rules and use them to create triples relating DAGs and subgraphs.
In the example below, there are two DAGs—DAG1 and DAG2—whose nodes can have three possible node labels: A, B, or C. For this example, I want to find DAGs with the C<--B-->C pattern, and then create a new triple linking that DAG with an instance representing this subgraph:
ex:DAG ex:has_subgraph ex:subGraph1
This pattern I'm matching is highlighted in yellow in the image below:
The subgraph pattern can be encoded into a SHACL rule shown below in TTL. Be sure to have sh:declare statements preceding rules, as this may cause issues with the SHACL rule inferencer you use. This is stored in a file called dagShapes.ttl:
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix sh: <http://www.w3.org/ns/shacl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix ex: <http://example.com/ns#> .
ex:
sh:declare [
sh:prefix "ex" ;
sh:namespace "http://example.com/ns#"^^xsd:anyURI ;
] .
ex:DAGSubGraphRule1
a sh:NodeShape ;
sh:targetClass ex:DAG ;
sh:rule [
a sh:SPARQLRule ;
sh:prefixes ex: ;
sh:construct """
CONSTRUCT {
$this ex:has_subgraph ex:subGraph1 .
}
WHERE {
$this ex:has_node ?n1 ;
ex:has_node ?n2 ;
ex:has_node ?n3 .
?n1 a ex:nodeType_B ;
ex:parent_of ?n2 ;
ex:parent_of ?n3 .
?n2 a ex:nodeType_C .
?n3 a ex:nodeType_C .
}
""" ;
] ;
.
The DAGs in this example are encoded in their own file called dagData.ttl like this:
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix sh: <http://www.w3.org/ns/shacl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix ex: <http://example.com/ns#> .
ex:DAG1
a ex:DAG ;
ex:has_node ex:d1_n1 ;
ex:has_node ex:d1_n2 ;
ex:has_node ex:d1_n3 ;
ex:has_node ex:d1_n4 ;
ex:has_node ex:d1_n5 .
ex:d1_n1 a ex:nodeType_A ;
ex:parent_of ex:d1_n2 .
ex:d1_n2 a ex:nodeType_A ;
ex:parent_of ex:d1_n3 .
ex:d1_n3 a ex:nodeType_B ;
ex:parent_of ex:d1_n4 ;
ex:parent_of ex:d1_n5 .
ex:d1_n4 a ex:nodeType_C .
ex:d1_n5 a ex:nodeType_C .
ex:DAG2
a ex:DAG ;
ex:has_node ex:d2_n1 ;
ex:has_node ex:d2_n2 ;
ex:has_node ex:d2_n2 ;
ex:has_node ex:d2_n2 ;
ex:has_node ex:d2_n2 .
ex:d1_n1 a ex:nodeType_A ;
ex:parent_of ex:d1_n2 .
ex:d1_n2 a ex:nodeType_A ;
ex:parent_of ex:d1_n3 .
ex:d1_n3 a ex:nodeType_B ;
ex:parent_of ex:d1_n4 .
ex:d1_n4 a ex:nodeType_C ;
ex:parent_of ex:d1_n5 .
ex:d1_n5 a ex:nodeType_C .
The DAG file and the subgraph shapes file are then passed to a SHACL rule inference tool. The inferencer is run like this in the command line:
shaclinfer -datafile dagData.ttl -shapesfile dagShapes.ttl
The output from the inferencer shows that DAG1 was correctly associated with my subgraph pattern!
#prefix dash: <http://datashapes.org/dash#> .
#prefix ex: <http://example.com/ns#> .
#prefix graphql: <http://datashapes.org/graphql#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix sh: <http://www.w3.org/ns/shacl#> .
#prefix swa: <http://topbraid.org/swa#> .
#prefix tosh: <http://topbraid.org/tosh#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:DAG1 ex:has_subgraph ex:subGraph1 .
It's certainly possible to encode a SPARQL query as OWL-but I'm not sure of anyone that's done it (it would be an involved process). As for pulling it out, definitely. It will be retrieved as a SPARQL Query Result, which you'd have to manually parse to get the full sparql query out.
In short, it's possible to embed a sparql query in an OWL document by first transforming the query to RDF. You can certainly pull the query out, _but processing to reconstruct the original query has to be done in another system (Java, Python, etc). Sounds like a cool topic for a paper, but lots of work around serializing and retrieving the query. Do I recommend it? Not if you're trying to do anything immediate.

OWL Inference problems using max cardinality in restriction class

I have created an ontology in protege. I am using the Pellet reasoner (it is enabled) and the snap sparql plugin.
I am trying to declare a small enterprise as an enterprise that has at most 20 employees.
Here are my triples. I am not able to see the inference that cs:SmithBrothers is a cs:SmallEnterprise (by the way of SPARQL query). Can someone please help me? I have been at this literally all day.
# employs
cs:employs a owl:ObjectProperty ;
rdfs:range cs:employee ;
rdfs:domain cs:enterprise .
# is-employed-by (the inverse of employs)
cs:isEmployedBy a owl:ObjectProperty ;
owl:inverseOf cs:employs .
# j. A small enterprise is an enterprise which employs at most 20 employees.
cs:smallEnterprise a owl:class ;
owl:equivalentClass [
owl:intersectionOf (
[ a owl:Restriction ;
owl:onProperty cs:employs ;
owl:maxCardinality 20 ]
cs:enterprise
)] .
# x. SmithBrothers is a family-based enterprise.
cs:SmithBrothers a cs:enterprise .
# y. Frank, Lea, Dave, Kate, Dino are employed by SmithBrothers.
cs:Frank cs:isEmployedBy cs:SmithBrothers .
cs:Lea cs:isEmployedBy cs:SmithBrothers .
cs:Dave cs:isEmployedBy cs:SmithBrothers .
cs:Kate cs:isEmployedBy cs:SmithBrothers .
cs:Dino cs:isEmployedBy cs:SmithBrothers .
#########################################
Thanks in advance.

Is it possible to query inferred Einstein Riddle knowledge from OWLIM?

I have OWLIM repository populated with Einstein Riddle owl.
Link1 - Link2. Is it possible to query inferred knowledge from OWLIM using sparql ? To get same results as on individual tab in Protege ?
SPARQL:
PREFIX riddle: <http://www.iis.nsk.su/persons/ponom/ontologies/einsteins_riddle_en.owl#>
SELECT DISTINCT ?kto ?co
WHERE {
?kto riddle:drinks ?co .
?kto a owl:Thing .
?co a owl:Thing .
Protege and OWLIM have same result, only explicit knowledge.
co kto
---------------------------------------------
http://www.iis.nsk.su/persons/ponom/ontologies/einsteins_riddle_en.owl#tea http://www.iis.nsk.su/persons/ponom/ontologies/einsteins_riddle_en.owl#Ukrainian
But (according to my information) in Protege, SPARQL query works only on existing knowledge and OWLIM build up repository with existing and inferred triples. So I expected inferred triples too.
P.S.:
Query to get count of inferred triples (OWLIM):
SELECT (COUNT(*) as ?count)
FROM <http://www.ontotext.com/implicit>
WHERE {
?s ?p ?o .
}
returns 0.
** ** ** EDIT: ** ** **
My configuration:
#
# Sesame configuration template for a owlim repository
#
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
#prefix rep: <http://www.openrdf.org/config/repository#>.
#prefix sr: <http://www.openrdf.org/config/repository/sail#>.
#prefix sail: <http://www.openrdf.org/config/sail#>.
#prefix owlim: <http://www.ontotext.com/trree/owlim#>.
[] a rep:Repository ;
rep:repositoryID "Riddle" ;
rdfs:label "Einstein Riddle Getting Started" ;
rep:repositoryImpl [
rep:repositoryType "openrdf:SailRepository" ;
sr:sailImpl [
sail:sailType "owlim:Sail" ;
owlim:base-URL "http://www.iis.nsk.su/persons/ponom/ontologies/einsteins_riddle_en.owl#" ;
# There must be exactly the same number of semicolon separated entries in
# the defaulNS and imports fields
owlim:defaultNS "http://www.iis.nsk.su/persons/ponom/ontologies/einsteins_riddle_en.owl#" ;
owlim:imports "./ontology/zebra.owl" ;
owlim:entity-index-size "5000000" ;
owlim:repository-type "file-repository" ;
owlim:ruleset "owl-max" ;
owlim:storage-folder "storage" ;
# OWLIM-SE parameters
owlim:cache-memory "180m" ;
# OWLIM-Lite parameters
owlim:noPersist "false" ;
# Other OWLIM-SE parameters
# owlim:enable-context-index "false" ;
owlim:check-for-inconsistencies "true" ;
# owlim:disable-sameAs "false" ;
owlim:enable-optimization "true" ;
owlim:enablePredicateList "true" ;
# owlim:entity-id-size "32" ; # 32/40
# owlim:fts-memory "20m" ;
# owlim:ftsIndexPolicy "never" ; # never/onStartup/onShutdown/onCommit
# owlim:ftsLiteralsOnly "false" ;
# owlim:in-memory-literal-properties "false" ;
# owlim:enable-literal-index "true" ;
# owlim:index-compression-ratio "-1" ; # -1/10-50
# owlim:owlim-license "" ;
# owlim:predicate-memory "80m" ;
# owlim:query-timeout "-1" ;
# owlim:tokenization-regex "[\p{L}\d_]+" ;
# owlim:tuple-index-memory "80m" ;
# owlim:useShutdownHooks "true" ;
# owlim:transaction-mode "safe" ;
# owlim:read-only "false" ;
# Other OWLIM-Lite parameters
# owlim:jobsize "1000}" ;
# owlim:new-triples-file ""
]
].
And it doesn't matter if I use owl2-rl or owl2-ql or w/e else. Always same result. Only number of inferred triples changes to positive.
08:51:40 Executing query 'Who drinks What'
co kto
---------------------------------------------
einsteins_riddle_en:tea einsteins_riddle_en:Ukrainian
08:51:40 1 result(s) in 63ms.
08:51:40 Executing query 'Number of inferred triples'
count
---------------------------------------------
"770"^^<http://www.w3.org/2001/XMLSchema#integer>
Inferred triples are useless for me, sample of them:
p s o
---------------------------------------------
rdf:type rdf:type rdf:Property
rdf:type rdfs:subPropertyOf rdf:Property
rdf:type rdfs:subClassOf rdf:Property
rdf:type rdfs:domain rdf:Property
rdf:type rdfs:range rdf:Property
rdf:type owl:equivalentClass rdf:Property
rdf:type psys:transitiveOver rdf:Property
...
Yes, this is possible, but it depends on how your OWLIM repository is configured.
The inference ruleset that OWLIM uses is set as a configuration parameter when you first create your repository - see the configuration documentation for details. Obviously, if you have set it to use an empty ruleset, it will do no inference at all. Depending on which ruleset you pick (there are several levels of expressivity), it will be able to infer more or less entailed triples (the more expressive the ruleset, the more entailed information).
If your OWLIM repository is configured correctly, queries will automatically retrieved inferred information along with the explicit statements.
Of course, it also depends on whether there actually is anything that can be inferred. The fact that your query gives the same result in Protege and OWLIM might simply mean that OWLIM does do inferencing, but didn't find any inferred information that matches your query.

Currently in a locked region: Fuseki + full text search + inference

I've recently started playing with the full text search in the Fuseki 0.2.8 snapshot.
I have an InfModel backed by a TDB dataset, which I've added a Lucene text index to. I have tested it out with some search queries like this:
prefix text: <http://jena.apache.org/text#>
select distinct ?s where { ?s text:query ('stu' 16) }
This works great, until I have two or more simultaneous queries to Fuseki, then occasionally I get:
Error 500: Currently in a locked region Fuseki - version 0.2.8-SNAPSHOT (Build date: 20130820-0755).
I've tried testing out the endpoint with 10 concurrent users sending queries at random intervals, over a two minute period around 30% of the queries return the 500 error above.
I have also tried disabling inference by replacing this section (full assembler file below):
<#dataset_fulltext> rdf:type text:TextDataset ;
text:dataset <#dataset_inf> ;
##text:dataset <#tdbDataset> ;
text:index <#indexLucene> .
with this:
<#dataset_fulltext> rdf:type text:TextDataset ;
##text:dataset <#dataset_inf> ;
text:dataset <#tdbDataset> ;
text:index <#indexLucene> .
and there are no exceptions generated when the TextDataset is using #tdbDataset rather than #dataset_inf.
Are there any problems with my set up, or is this a bug in Fuseki?
Here is my current assembler file:
#prefix : <#> .
#prefix fuseki: <http://jena.apache.org/fuseki#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
#prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
#prefix text: <http://jena.apache.org/text#> .
#prefix dc: <http://purl.org/dc/terms/> .
[] rdf:type fuseki:Server ;
# Timeout - server-wide default: milliseconds.
# Format 1: "1000" -- 1 second timeout
# Format 2: "10000,60000" -- 10s timeout to first result, then 60s timeout to for rest of query.
# See java doc for ARQ.queryTimeout
ja:context [ ja:cxtName "arq:queryTimeout" ; ja:cxtValue "12000,50000" ] ;
fuseki:services (
<#service1>
) .
# Custom code.
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
# TDB
tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .
## Initialize text query
[] ja:loadClass "org.apache.jena.query.text.TextQuery" .
# A TextDataset is a regular dataset with a text index.
text:TextDataset rdfs:subClassOf ja:RDFDataset .
# Lucene index
text:TextIndexLucene rdfs:subClassOf text:TextIndex .
## ---------------------------------------------------------------
## Service with only SPARQL query on an inference model.
## Inference model bbase data in TDB.
<#service1> rdf:type fuseki:Service ;
rdfs:label "TDB/text service" ;
fuseki:name "dataset" ; # http://host/dataset
fuseki:serviceQuery "query" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceUpload "upload" ;
fuseki:serviceReadWriteGraphStore "data" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:dataset <#dataset_fulltext> ;
.
<#dataset_inf> rdf:type ja:RDFDataset ;
ja:defaultGraph <#model_inf> .
<#model_inf> rdf:type ja:Model ;
ja:baseModel <#tdbGraph> ;
ja:reasoner [ ja:reasonerURL <http://jena.hpl.hp.com/2003/OWLMicroFBRuleReasoner> ] .
<#tdbDataset> rdf:type tdb:DatasetTDB ;
tdb:location "Data" .
<#tdbGraph> rdf:type tdb:GraphTDB ;
tdb:dataset <#tdbDataset> .
# Dataset with full text index.
<#dataset_fulltext> rdf:type text:TextDataset ;
text:dataset <#dataset_inf> ;
##text:dataset <#tdbDataset> ;
text:index <#indexLucene> .
# Text index description
<#indexLucene> a text:TextIndexLucene ;
text:directory <file:Lucene> ;
##text:directory "mem" ;
text:entityMap <#entMap> ;
.
# Mapping in the index
# URI stored in field "uri"
# rdfs:label is mapped to field "text"
<#entMap> a text:EntityMap ;
text:entityField "uri" ;
text:defaultField "text" ;
text:map (
[ text:field "text" ; text:predicate dc:title ]
[ text:field "text" ; text:predicate dc:description ]
) .
And here is the full stack trace for one of the exceptions in Fuseki's log:
16:27:01 WARN Fuseki :: [2484] RC = 500 : Currently in a locked region
com.hp.hpl.jena.sparql.core.DatasetGraphWithLock$JenaLockException: Currently in a locked region
at com.hp.hpl.jena.sparql.core.DatasetGraphWithLock.checkNotActive(DatasetGraphWithLock.java:72)
at com.hp.hpl.jena.sparql.core.DatasetGraphTrackActive.begin(DatasetGraphTrackActive.java:44)
at org.apache.jena.query.text.DatasetGraphText.begin(DatasetGraphText.java:102)
at org.apache.jena.fuseki.servlets.HttpAction.beginRead(HttpAction.java:117)
at org.apache.jena.fuseki.servlets.SPARQL_Query.execute(SPARQL_Query.java:236)
at org.apache.jena.fuseki.servlets.SPARQL_Query.executeWithParameter(SPARQL_Query.java:195)
at org.apache.jena.fuseki.servlets.SPARQL_Query.perform(SPARQL_Query.java:80)
at org.apache.jena.fuseki.servlets.SPARQL_ServletBase.executeLifecycle(SPARQL_ServletBase.java:185)
at org.apache.jena.fuseki.servlets.SPARQL_ServletBase.executeAction(SPARQL_ServletBase.java:166)
at org.apache.jena.fuseki.servlets.SPARQL_ServletBase.execCommonWorker(SPARQL_ServletBase.java:154)
at org.apache.jena.fuseki.servlets.SPARQL_ServletBase.doCommon(SPARQL_ServletBase.java:73)
at org.apache.jena.fuseki.servlets.SPARQL_Query.doGet(SPARQL_Query.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
at org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:82)
at org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:294)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at org.eclipse.jetty.server.nio.BlockingChannelConnector$BlockingChannelEndPoint.run(BlockingChannelConnector.java:298)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
Any advice appreciated.
Thanks,
Stuart.
This looks like it is probably a bug which I have filed as JENA-522, if you have further details on the bug to add please add a comment there.
The issue is that the dataset with inference implicitly uses ARQ's standard in-memory Dataset implementation and this does not support transactions.
However text datasets which correspond to DatasetGraphText internally (and in your stack trace) requires the wrapped dataset to support transactions and where they do not wraps them with DatasetGraphWithLock. It is this that appears to be encountering the problem with the lock, the documentation states that this should support multiple readers but having followed the logic of the code I'm not sure that it actually allows this.