Menu

"Hello World" example

Help
2013-03-07
2014-02-19
  • Luba Powell

    Luba Powell - 2013-03-07

    So,  I downloaded .WAR file  from https://sourceforge.net/projects/bigdata/files/latest/download,  uploaded it to Tomcat 7 and validated it via.http://localhost:8080/bigdata/sparql.

    Now I need to run SPARQL queries from a simple Java program.  Does anyone have "Hello World" example or Quick Start how-to?

    Many thanks,
    Clova

     
  • Mike Personick

    Mike Personick - 2013-03-07

    Check out com.bigdata.rdf.sail.webapp.TestNanoSparqlClient and see if that helps.

     
  • Luba Powell

    Luba Powell - 2013-03-07

    Did that.  Where is the property file there,  containing Connection String to the NSS?  A couple of lines with Connect,  execute simple query and pick up the result set will get us started.  Thanks.

     
  • Luba Powell

    Luba Powell - 2013-03-07

    Thank you,  mrpersonick.  Will do as you suggest and report. 
    Clove

     
  • Luba Powell

    Luba Powell - 2013-03-07

    com.bigdata.rdf.sail.webapp.client.RemoteRepository  is not in the NSS .war file.  Where can I download client package from?

     
  • Mike Personick

    Mike Personick - 2013-03-07

    WEB-INF/lib/bigdata-1.2.2.jar

     
  • Bryan Thompson

    Bryan Thompson - 2013-03-07

    This might only be in the dev branch.  We are currently prepping that for a release.  You can check out the code from SVN  and then do "ant war" to generate the WAR artifact.

    Bryan
    https://bigdata.svn.sourceforge.net/svnroot/bigdata/branches/BIGDATA_RELEASE_1_2_0 (this is the current dev branch)

     
  • Luba Powell

    Luba Powell - 2013-03-07

    OK.   Will do just that and report.

     
  • Luba Powell

    Luba Powell - 2013-03-07

    Question.  Can I mix the client from the DEV release 1.2.0 with the WAR that I installed and validated yesterday on Tomcat 7? 

     
  • Bryan Thompson

    Bryan Thompson - 2013-03-07

    The database file on the disk is compatible.  The WAR contains the server side of the REST interface.  You need to update it.  You should have only had to apply edits to web.xml and RWStore.properties, so the rest can be safely overwritten.
    Bryan

     
  • Luba Powell

    Luba Powell - 2013-03-07

    Almost there….   Ran com.bigdata.gom.Example1 (renamed to Example11).  Connected to the server OK,  but received "404" as a response:

    Exception in thread "main" java.lang.RuntimeException: query=PREFIX foaf: <http://xmlns.com/foaf/0.1/>
    CONSTRUCT {
    ?u a foaf:Person .
    ?u foaf:knows ?v .
    ?u rdfs:label ?name .
    }
    WHERE {
    ?u a foaf:Person .
    ?u foaf:knows ?v .
    OPTIONAL { ?u rdfs:label ?name } .
    } LIMIT 100
    at com.bigdata.gom.om.NanoSparqlObjectManager.evaluateGraph(NanoSparqlObjectManager.java:127)
    at test.Example11.call(Example11.java:51)
    at test.Example11.main(Example11.java:111)
    Caused by: com.bigdata.rdf.sail.webapp.client.HttpException: Status Code=404, Status Line=HTTP/1.1 404 Not Found, Response=<html><head><title>Apache Tomcat/7.0.37 - Error report</title><style><!-H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-></style> </head><body><h1>HTTP Status 404 - /sparql/</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/sparql/</u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.37</h3></body></html>
    at com.bigdata.rdf.sail.webapp.client.RemoteRepository.checkResponseCode(RemoteRepository.java:1361)
    at com.bigdata.rdf.sail.webapp.client.RemoteRepository$GraphQuery.evaluate(RemoteRepository.java:957)
    at com.bigdata.gom.om.NanoSparqlObjectManager.evaluateGraph(NanoSparqlObjectManager.java:119)
    … 2 more

    Verified namespace = "kb"

     
  • Bryan Thompson

    Bryan Thompson - 2013-03-08

    I am not sure what problem you are encountering.  I just ran Example1 from SVN against a NSS instance:

    Here is the output of Example1:

    Found 4 instances.
    ID: http://www.bigdata.com/Mike
    http://www.w3.org/1999/02/22-rdf-syntax-ns#type: http://xmlns.com/foaf/0.1/Person
    http://xmlns.com/foaf/0.1/knows: http://www.bigdata.com/Bryan
    http://www.w3.org/2000/01/rdf-schema#label: "Mike"
    ID: http://www.bigdata.com/Martyn
    http://www.w3.org/1999/02/22-rdf-syntax-ns#type: http://xmlns.com/foaf/0.1/Person
    http://xmlns.com/foaf/0.1/knows: http://www.bigdata.com/Bryan
    http://www.w3.org/2000/01/rdf-schema#label: "Martyn"
    ID: http://xmlns.com/foaf/0.1/Person
    ID: http://www.bigdata.com/Bryan
    http://www.w3.org/1999/02/22-rdf-syntax-ns#type: http://xmlns.com/foaf/0.1/Person
    http://xmlns.com/foaf/0.1/knows: http://www.bigdata.com/Mike
    http://xmlns.com/foaf/0.1/knows: http://www.bigdata.com/Martyn
    http://www.w3.org/2000/01/rdf-schema#label: "Bryan"
    

    Here is the RWStore.properties file:

    #
    # Note: These options are applied when the journal and the triple store are
    # first created.
    ##
    ## Journal options.
    ##
    # The backing file. This contains all your data.  You want to put this someplace
    # safe.  The default locator will wind up in the directory from which you start
    # your servlet container.
    com.bigdata.journal.AbstractJournal.file=bigdata.jnl
    # The persistence engine.  Use 'Disk' for the WORM or 'DiskRW' for the RWStore.
    com.bigdata.journal.AbstractJournal.bufferMode=DiskRW
    com.bigdata.btree.writeRetentionQueue.capacity=4000
    com.bigdata.btree.BTree.branchingFactor=128
    # 200M initial extent.
    com.bigdata.journal.AbstractJournal.initialExtent=209715200
    com.bigdata.journal.AbstractJournal.maximumExtent=209715200
    ##
    ## Setup for QUADS mode without the full text index.
    ##
    com.bigdata.rdf.sail.truthMaintenance=false
    com.bigdata.rdf.store.AbstractTripleStore.quads=true
    com.bigdata.rdf.store.AbstractTripleStore.statementIdentifiers=false
    com.bigdata.rdf.store.AbstractTripleStore.textIndex=false
    com.bigdata.rdf.store.AbstractTripleStore.axiomsClass=com.bigdata.rdf.axioms.NoAxioms
    #com.bigdata.rdf.store.AbstractTripleStore.inlineDateTimes=true
    

    In this case, I ran the NanoSparqlServer main() routine with the following command line arguments rather than running against a tomcat instance:

    8080 kb RWStore.properties
    

    Since you are running inside of tomcat, please verify that there are no errors in the relevant log files for your installation.

    Thanks,
    Bryan

     
  • Luba Powell

    Luba Powell - 2013-03-08

    I ran NSS on Tomcat 7 over Windows.   I am going to recompile the DEV branch and re-deploy it on a less restrictive network,  but also onto Window 7. 

    ETD is Sunday.  Will report when done.

    Many thanks,
    Clove

     

Log in to post a comment.