You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Shaw, Ryan" <ry...@unc.edu> on 2023/05/21 23:48:24 UTC
Dynamically loading SPARQL functions from class path
Is it still possible to dynamically load SPARQL functions from the classpath? I have it working with tarql, which uses Jena 3.11, but I can’t seem to get it working with the latest version of Jena:
$ JVM_ARGS="-cp /Users/ryanshaw/Code/ncg-dataset/lib/sparql-functions/build/libs/sparql-functions.jar" ./tools/apache-jena-4.8.0/bin/arq --data=dataset.nt --query=queries/new-ids.rq
19:36:15 WARN ClsLoader :: Class not found: org.ncgazetteer.mint
19:36:15 WARN exec :: URI <java:org.ncgazetteer.mint> has no registered function factory
$ cat queries/new-ids.rq:
PREFIX ncp: <http://n2t.net/ark:/39333/ncg/place/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX f: <java:org.ncgazetteer.>
CONSTRUCT {
?oldid owl:sameAs ?newid .
}
WHERE {
SELECT DISTINCT ?oldid (f:mint("ncp") AS ?newid)
WHERE {
?oldid ?p ?o .
FILTER(REGEX(STR(?oldid), "^http://n2t.net/ark:/39333/ncg/place/NCG"))
}
}
$ unzip -l /Users/ryanshaw/Code/ncg-dataset/lib/sparql-functions/build/libs/sparql-functions.jar | grep mint
4174 05-21-2023 16:34 org/ncgazetteer/mint.class
Re: Dynamically loading SPARQL functions from class path
Posted by Andy Seaborne <an...@apache.org>.
On 22/05/2023 00:48, Shaw, Ryan wrote:
> Is it still possible to dynamically load SPARQL functions from the classpath?
Yes - but the scripts don't seem to have the ability to add to the class
path.
JVM_ARGS isn't going to get the -cp correct. See end of script.
It'll need a script fix (or call the program directly, or put the
extension in <jena>/lib/)
Be good to get a PR to fix this - the template for commands is
https://github.com/apache/jena/blob/main/apache-jena/template.bin
Andy
> I have it working with tarql, which uses Jena 3.11, but I can’t seem to get it working with the latest version of Jena:
>
> $ JVM_ARGS="-cp /Users/ryanshaw/Code/ncg-dataset/lib/sparql-functions/build/libs/sparql-functions.jar" ./tools/apache-jena-4.8.0/bin/arq --data=dataset.nt --query=queries/new-ids.rq
>
> 19:36:15 WARN ClsLoader :: Class not found: org.ncgazetteer.mint
> 19:36:15 WARN exec :: URI <java:org.ncgazetteer.mint> has no registered function factory
>
> $ cat queries/new-ids.rq:
>
> PREFIX ncp: <http://n2t.net/ark:/39333/ncg/place/>
> PREFIX owl: <http://www.w3.org/2002/07/owl#>
> PREFIX f: <java:org.ncgazetteer.>
>
> CONSTRUCT {
> ?oldid owl:sameAs ?newid .
> }
> WHERE {
> SELECT DISTINCT ?oldid (f:mint("ncp") AS ?newid)
> WHERE {
> ?oldid ?p ?o .
> FILTER(REGEX(STR(?oldid), "^http://n2t.net/ark:/39333/ncg/place/NCG"))
> }
> }
>
> $ unzip -l /Users/ryanshaw/Code/ncg-dataset/lib/sparql-functions/build/libs/sparql-functions.jar | grep mint
>
> 4174 05-21-2023 16:34 org/ncgazetteer/mint.class
>
>
>