Hi Preethi, It looks like one of the required jar files (probably arq.jar) is not on the classpath, or it's an incompatible version of the jar file. D2RQ only works with the version of ARQ that's shipped with D2RQ (in the lib directory).
Please don't email support requests to me personally. Use the mailing list (in cc). Hope that helps, Richard On 23 Aug 2011, at 15:06, Preethi Priyadharsini wrote: > Hi, > I want to load the RDF triple file and query it using Jena's Graph API and > SPARQL but I get run time when I try to execute the the example program which > is given in the the following link > http://www4.wiwiss.fu-berlin.de/bizer/d2rq/spec/. Using Eclipse platform > adding d2rq-7.0 jar file and all the jar files in ARQ1.4 package and > mysql-connector-java-5.1.7-bin jar file that I used for database connectivity > to the classpath I executed the following program but i get some run time > error please help me to execute the SPARQL query. > > jena.java > > import com.hp.hpl.jena.rdf.model.*; > import com.hp.hpl.jena.graph.*; > import com.hp.hpl.jena.vocabulary.*; > import de.fuberlin.wiwiss.d2rq.*; > import com.hp.hpl.jena.util.FileManager; > import com.hp.hpl.jena.datatypes.xsd.*; > import java.util.Iterator; > public class jena { > // Load mapping file > public static void main(String s[]) > { > Model mapping = > FileManager.get().loadModel("C:/Users/user/Downloads/d2r-server-0.7/d2r-server-0.7/mapping-iswc.n3"); > > // Set up the GraphD2RQ > GraphD2RQ g = new GraphD2RQ(mapping, "http://localhost:2020/"); > > // Create a find(spo) pattern > Node subject = Node.ANY; > Node predicate = DC.date.asNode(); > Node object = Node.createLiteral("2003", null, XSDDatatype.XSDgYear); > Triple pattern = new Triple(subject, predicate, object); > > // Query the graph > Iterator it = g.find(pattern); > > // Output query results > while (it.hasNext()) { > Triple t = (Triple) it.next(); > System.out.println("Published in 2003: " + t.getSubject()); > > } > } > } > > Run time error > > Exception in thread "main" java.lang.NoClassDefFoundError: > com/hp/hpl/jena/sparql/engine/main/QueryEngineMain > at java.lang.ClassLoader.defineClass1(Native Method) > at java.lang.ClassLoader.defineClass(ClassLoader.java:620) > at > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) > at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) > at java.net.URLClassLoader.access$000(URLClassLoader.java:56) > at java.net.URLClassLoader$1.run(URLClassLoader.java:195) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:188) > at java.lang.ClassLoader.loadClass(ClassLoader.java:306) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) > at de.fuberlin.wiwiss.d2rq.GraphD2RQ.<clinit>(GraphD2RQ.java:57) > at jena.main(jena.java:19) > > > jena1.java > > import com.hp.hpl.jena.query.Query; > import com.hp.hpl.jena.query.QueryExecutionFactory; > import com.hp.hpl.jena.query.QueryFactory; > import com.hp.hpl.jena.query.ResultSet; > import de.fuberlin.wiwiss.d2rq.*; > import com.hp.hpl.jena.query.QueryFactory.*; > import com.hp.hpl.jena.query.*; > > public class jena1 { > public static void main(String s[]) > { > ModelD2RQ m = new > ModelD2RQ("file:C:/Users/user/Downloads/d2r-server-0.7/d2r-server-0.7/mapping-iswc.n3"); > String sparql = > "PREFIX dc: <http://purl.org/dc/elements/1.1/>" + > "PREFIX foaf: <http://xmlns.com/foaf/0.1/>" + > "SELECT ?paperTitle ?authorName WHERE {" + > " ?paper dc:title ?paperTitle . " + > " ?paper dc:creator ?author ." + > " ?author foaf:name ?authorName ." + > "}"; > Query q = QueryFactory.create(sparql); > ResultSet rs = QueryExecutionFactory.create(q, m).execSelect(); > while (rs.hasNext()) { > QuerySolution row = rs.nextSolution(); > System.out.println("Title: " + > row.getLiteral("paperTitle").getString()); > System.out.println("Author: " + > row.getLiteral("authorName").getString()); > } > } > } > > Run time error > > Exception in thread "main" java.lang.NoClassDefFoundError: > com/hp/hpl/jena/sparql/engine/main/QueryEngineMain > at java.lang.ClassLoader.defineClass1(Native Method) > at java.lang.ClassLoader.defineClass(ClassLoader.java:620) > at > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) > at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) > at java.net.URLClassLoader.access$000(URLClassLoader.java:56) > at java.net.URLClassLoader$1.run(URLClassLoader.java:195) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:188) > at java.lang.ClassLoader.loadClass(ClassLoader.java:306) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) > at java.lang.ClassLoader.loadClass(ClassLoader.java:251) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) > at de.fuberlin.wiwiss.d2rq.GraphD2RQ.<clinit>(GraphD2RQ.java:57) > at jena.main(jena.java:19) > > With Regards, > Preethi . > > ------------------------------------------------------------------------------ Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 _______________________________________________ d2rq-map-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/d2rq-map-devel
