2

Hi i've just started using Jena and wanted to run a few SPARQL queries. I got the following exception when I tried to run a basic select query:

Caused by: java.lang.NoSuchMethodError: com.hp.hpl.jena.rdf.model.impl.RDFWriterFImpl.setBaseWriterClassName(Ljava/lang/String;Ljava/>lang/String;)Ljava/lang/String;
    at org.openjena.riot.SysRIOT.wireIntoJena(SysRIOT.java:93)
    at org.openjena.riot.RIOT.init(RIOT.java:61)
    at com.hp.hpl.jena.query.ARQ.init(ARQ.java:451)
    at com.hp.hpl.jena.query.ARQ.<clinit>(ARQ.java:456)
    at com.hp.hpl.jena.query.Query.<clinit>(Query.java:62)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:52)
    at com.qmap.core.server.jena.GetExistingRelationships.appendValidProperties(GetExistingRelationships.java:153)

My java code is:

String queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>  PREFIX ns: <http://www.semanticweb.org/ontologies/2012/1/Ontology1328444427428.owl#>  SELECT ?r WHERE { ns:within rdfs:range ?r . }";
Query query = QueryFactory.create(queryString, Syntax.syntaxSPARQL);

QueryExecution qexec = QueryExecutionFactory.create(query, m) ;
try {

        Iterator<QuerySolution> rs = qexec.execSelect() ;
        for ( ; rs.hasNext() ; )
        {
            QuerySolution soln = rs.next() ;
            System.out.println(soln.toString());

        }
      } finally { qexec.close() ; }

Where 'm' is of type OntModel. From what I have been reading the problem possibly lies with my Jena libraries - however I updated to the most recent Jena build and still no luck. It may be that there is something missing, however the package referenced in the stack trace is there.

Here are my jena library files:

JENA Library Files

Any Help would be greatly appreciated.

roscminni
  • 65
  • 7

1 Answers1

4

Your code works for me. It looks like jena-core is not on the runtime classpath.

It may be because there is other stuff on your classpath - the line numbers don't quite line up with ARQ 2.9.4.

AndyS
  • 14,989
  • 15
  • 20