I'm trying to use Empire with Grails. I got the Book class from the
Empire example working as a domain object, but I'm having trouble
using my own objects.
I have an entityManager created and initialized. But when I attempt to
create a query, I get an exception (line feeds inserted to aid
clarity):
Invalid query:
PREFIX rdfs: <
http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <
http://www.w3.org/2002/07/owl#>
PREFIX rdf: <
http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select ?result where { ?result rdf:type foo:mything . }
Here's a complete stack trace:
org.openrdf.query.parser.sparql.ast.VisitorException: QName
'foo:mything' uses an undefined prefix
at org.openrdf.query.parser.sparql.PrefixDeclProcessor
$QNameProcessor.visit(PrefixDeclProcessor.java:92)
at
org.openrdf.query.parser.sparql.ast.ASTQName.jjtAccept(ASTQName.java:
21)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
230)
at
org.openrdf.query.parser.sparql.ast.ASTObjectList.jjtAccept(ASTObjectList.java:
19)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
224)
at
org.openrdf.query.parser.sparql.ast.ASTPropertyList.jjtAccept(ASTPropertyList.java:
19)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
218)
at
org.openrdf.query.parser.sparql.ast.ASTTriplesSameSubject.jjtAccept(ASTTriplesSameSubject.java:
19)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
182)
at
org.openrdf.query.parser.sparql.ast.ASTBasicGraphPattern.jjtAccept(ASTBasicGraphPattern.java:
19)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
176)
at
org.openrdf.query.parser.sparql.ast.ASTGraphPatternGroup.jjtAccept(ASTGraphPatternGroup.java:
19)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
146)
at
org.openrdf.query.parser.sparql.ast.ASTWhereClause.jjtAccept(ASTWhereClause.java:
19)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
98)
at
org.openrdf.query.parser.sparql.ast.ASTSelectQuery.jjtAccept(ASTSelectQuery.java:
19)
at
org.openrdf.query.parser.sparql.ast.SimpleNode.childrenAccept(SimpleNode.java:
146)
at
org.openrdf.query.parser.sparql.ASTVisitorBase.visit(ASTVisitorBase.java:
80)
at
org.openrdf.query.parser.sparql.ast.ASTQueryContainer.jjtAccept(ASTQueryContainer.java:
21)
at
org.openrdf.query.parser.sparql.PrefixDeclProcessor.process(PrefixDeclProcessor.java:
61)
at
org.openrdf.query.parser.sparql.SPARQLParser.parseQuery(SPARQLParser.java:
41)
at
com.clarkparsia.empire.impl.sparql.SPARQLDialect.validateQueryFormat(Unknown
Source)
at com.clarkparsia.empire.impl.RdfQuery.<init>(Unknown Source)
at com.clarkparsia.empire.impl.RdfQueryFactory.newQuery(Unknown
Source)
at com.clarkparsia.empire.impl.RdfQueryFactory.createQuery(Unknown
Source)
at com.clarkparsia.empire.impl.EntityManagerImpl.createQuery(Unknown
Source)
at BootStrap$_closure1_closure3_closure5.doCall(BootStrap.groovy:51)
I don't know how prefixes are defined or set up. With the Book
example, things "just worked", I didn't do anything with the prefixes;
so I'm guessing they got picked up from the class annotation somehow.
Is there a way to manually add namespaces to the entityManager, or
QueryFactory, or whatever would be appropriate? Or maybe this
indicates a problem in my .owl file? Is the namespace possibly not
declared there? (I'm sure it is, but am casting about for reasons.)
- Jasen.