I'm having trouble loading my RDF4J custom SPARQL function in GraphDB.
I'm running GraphDB 10.2.0 using the Docker image at https://hub.docker.com/r/ontotext/graphdb.
I've followed https://rdf4j.org/documentation/tutorials/custom-sparql-functions/ and created a custom SPARQL function in RDF4J. I've added the SPI configuration as described in the documentation and packaged it up into a JAR file.
I'm running the GraphDB container with the following docker-compose.yml
file.
version: "3.8"
services:
graphdb:
image: ontotext/graphdb:10.2.0
volumes:
- graphdb-data:/opt/graphdb/home
- ./build/libs/palindrome-1.0-SNAPSHOT.jar:/opt/graphdb/dist/lib/plugins/example-plugin/palindrome-1.0-SNAPSHOT.jar
ports:
- 7200:7200
environment:
# Note: running GraphDB in DEBUG mode
GDB_JAVA_OPTS: >-
-Xmx4g
-Xms2g
-Dgraphdb.home=/opt/graphdb/home
-Dgraphdb.workbench.importDirectory=/opt/graphdb/home/graphdb-import
-Dgraphdb.workbench.cors.enable=true
-Denable-context-index=true
-Dentity-pool-implementation=transactional
-Dhealth.max.query.time.seconds=600
-Dgraphdb.append.request.id.headers=true
-Dreuse.vars.in.subselects=true
-Dgraphdb.logger.root.level=DEBUG
networks:
- graphdb
profiles:
- graphdb
volumes:
graphdb-data:
networks:
graphdb:
Once GraphDB has started up. I load some data.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix ex: <http://example.org/> .
ex:a rdfs:label "step on no pets" .
ex:b rdfs:label "go on, try it" .
And I run the SPARQL query.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX cfn: <http://example.org/custom-function/>
SELECT ?x ?label
WHERE {
?x rdfs:label ?label .
FILTER(cfn:palindrome(str(?label)))
}
However, running the query responds with the following error.
Error 500: error
Query evaluation error: Unknown function 'http://example.org/custom-function/palindrome' (HTTP status 500)
I've looked at existing Stackoverflow questions which seem to suggest RDF4J custom functions can work in GraphDB.
Please can someone guide me on how to load a custom SPARQL function written with RDF4J. Thanks in advance.