NoSuchMethod while trying to create SPARQL query with jena

I am trying to do some SPARQL queries using vc-db-1.rdf and q1.rq from ARQ examples. Here is my java code:

import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.util.FileManager;
import com.hp.hpl.jena.query.* ;
import com.hp.hpl.jena.query.ARQ;
import com.hp.hpl.jena.iri.*;
public class querier extends Object 
static final String inputFileName = "vc-db-1.rdf";
public static void main (String args[]) 
    // Create an empty in-memory model 
    Model model = ModelFactory.createDefaultModel();
    // use the FileManager to open the bloggers RDF graph from the filesystem
    InputStream in = FileManager.get().open(inputFileName);
    if (in == null) 
        throw new IllegalArgumentException( "File: " + inputFileName + " not found");
    // read the RDF/XML file in, ""); 
    // Create a new query
    String queryString = "PREFIX vcard: <> SELECT ?y ?givenName WHERE { ?y vcard:Family \"Smith\" . ?y vcard:Given  ?givenName . }";


The compilation is fine. The problem is that the request is not even executed, but I am getting an error when I create it in the line



with the following explanation:

C:\Wallet\projects\java\ARQ_queries>java querier
Exception in thread "main" java.lang.NoSuchMethodError: com.hp.hpl.jena.iri.IRI.
    at com.hp.hpl.jena.n3.IRIResolver.resolveGlobal(
    at com.hp.hpl.jena.sparql.mgt.SystemInfo.createIRI(
    at com.hp.hpl.jena.sparql.mgt.SystemInfo.<init>(
    at com.hp.hpl.jena.query.ARQ.init(
    at com.hp.hpl.jena.query.ARQ.<clinit>(
    at com.hp.hpl.jena.query.Query.<clinit>(
    at com.hp.hpl.jena.query.QueryFactory.create(
    at com.hp.hpl.jena.query.QueryFactory.create(
    at com.hp.hpl.jena.query.QueryFactory.create(
    at querier.main(


How can I solve this? Thank.


source to share

1 answer

It looks like you are missing the IRI library in the classpath (the IRI library is separate from the main Jena JAR). Jena has runtime dependencies on several other libraries that are included in lib

the Jena distribution directory . All of this should be in your classpath at runtime (but not necessarily at compile time).



All Articles