You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by David Patterson <dp...@i-a-i.com> on 2014/11/09 22:49:07 UTC

Fuseki and other web traffic

I've loaded the latest Fuseki (1.1.1) and it runs. I can use the control panel to select my dataset and issue queries.

However, when I load a web page into a browser (via File->Open page) that calls http://localhost:3030/... I see nothing in the browser. When I look at the javascript console for the page, I see an error message:

XMLHttpRequest cannot load http://localhost:3030/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Is there a recommended approach to this? I want to have a web page that issues a Fuseki query for a starting set of resources. I'll then format them with appropriate links so the user can delve into the data as they wish.

(a) Should I setup another server (such as Apache Tomcat) so the user asks it for the first page which issues the Fuseki request?

(b) Do I setup an Apache Tomcat (or other server) with servlets, so my first request is to a servlet that issues an http request to Fuseki and then returns the data to be formatted?

(c) Something else?

I'm willing to do whatever it takes to make this work, but I'd like to have some idea that it will work before trying it.

I'm currently running on a Windows 7 desktop machine with lots of resources, but it may eventually run on a Mac.

Thanks.

Dave Patterson



________________________________
This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.

RE: Fuseki and other web traffic

Posted by David Patterson <dp...@i-a-i.com>.
Osma,

Thanks for this suggestion. I'm now past my problem and fighting with reading the results of my query and formatting it the way I wanted.

<Aside>It might be worth adding a more complete example showing more parts of the problem and what is needed to really make it work.</Aside>

Dave Patterson

-----Original Message-----
From: Osma Suominen [mailto:osma.suominen@helsinki.fi]
Sent: Monday, November 10, 2014 1:13 PM
To: users@jena.apache.org
Subject: Re: Fuseki and other web traffic

Hi Dave!

I think you need to pass the SPARQL query as the POST parameter "query".
In your code you have this line:

var jqXHR = $.post( url, q1 );

Change it to this:

var jqXHR = $.post( url, { query: q1 } );

At least that's how it should work according to the jQuery documentation
here: http://api.jquery.com/jquery.post/

-Osma


10.11.2014, 19:21, David Patterson kirjoitti:
> Andy, et. al.
>
> Thank you for your suggestion. I still don't get output back to my web page.
> On the command screen where I started Fuseki, however, I see:
>
> 11:59:44 INFO  [5] POST http://localhost:3030/aronat/query
> 11:59:44 INFO  [5] 400 SPARQL Query: No 'query=' parameter (4 ms)
>
> Any suggestions?
>
> Dave Patterson
>
>
>
> ________________________________
> This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.
>


--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist National Library of Finland P.O. Box 26 (Teollisuuskatu 23)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suominen@helsinki.fi
http://www.nationallibrary.fi



________________________________
This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.

Re: Fuseki and other web traffic

Posted by Osma Suominen <os...@helsinki.fi>.
Hi Dave!

I think you need to pass the SPARQL query as the POST parameter "query". 
In your code you have this line:

var jqXHR = $.post( url, q1 );

Change it to this:

var jqXHR = $.post( url, { query: q1 } );

At least that's how it should work according to the jQuery documentation 
here: http://api.jquery.com/jquery.post/

-Osma


10.11.2014, 19:21, David Patterson kirjoitti:
> Andy, et. al.
>
> Thank you for your suggestion. I still don't get output back to my web page.
> On the command screen where I started Fuseki, however, I see:
>
> 11:59:44 INFO  [5] POST http://localhost:3030/aronat/query
> 11:59:44 INFO  [5] 400 SPARQL Query: No 'query=' parameter (4 ms)
>
> Any suggestions?
>
> Dave Patterson
>
>
>
> ________________________________
> This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.
>


-- 
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Teollisuuskatu 23)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suominen@helsinki.fi
http://www.nationallibrary.fi

RE: Fuseki and other web traffic

Posted by David Patterson <dp...@i-a-i.com>.
Andy, et. al.

Thank you for your suggestion. I still don't get output back to my web page.
On the command screen where I started Fuseki, however, I see:

11:59:44 INFO  [5] POST http://localhost:3030/aronat/query
11:59:44 INFO  [5] 400 SPARQL Query: No 'query=' parameter (4 ms)

Any suggestions?

Dave Patterson



________________________________
This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.

Re: Fuseki and other web traffic

Posted by Andy Seaborne <an...@apache.org>.
Dave,

The query endpoint is

   http://localhost:3030/aronat/query

Note the dataset name in the URL.

	Andy


On 10/11/14 15:45, David Patterson wrote:
> Andy and Osma,
>
> 1) I've updated to the jena-fuseki-1.1.2-SNAPSHOT version.
>
> 2) I'm starting Fuseki as:
> cd \jena\jena-fuseki-1.1.2-SNAPSHOT
> call fuseki-server --update --config=e:\abc\project1\fuseki1.ttl
>
> 3) assembler file: (minus the comments)
> @prefix fuseki:  <http://jena.apache.org/fuseki#> .
> @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
> @prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
> @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
> @prefix :        <#> .
>
> [] rdf:type fuseki:Server ;
>
> fuseki:services (
>       <#service2>
> ) .
>
> # Declaration additional assembler items.
> [] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
>
> # TDB
> tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
> tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>
> <#service2> rdf:type fuseki:Service ;
> fuseki:name                     "aronat" ;   # http://www.i-a-i.com/abc
> fuseki:serviceQuery             "query" ;    # SPARQL query service
> fuseki:serviceReadGraphStore    "data" ;     # SPARQL Graph store protocol (read only)
>   fuseki:dataset           <http://www.i-a-i.com/aronat> .
>
> <http://www.i-a-i.com/aronat>    rdf:type ja:RDFDataset ;
> rdfs:label "Aronat" ;
> ja:defaultGraph
>        [ rdfs:label "ABC for ABC" ;
>          a ja:MemoryModel ;
>          ja:content [ja:externalContent <file:structure.0001.ttl> ] ;
>          ja:content [ja:externalContent <file:abc.0001.ttl> ] ;
> ] .
>
> 4) The HTML file:
> <!DOCTYPE html>
> <html>
> <head>
> <meta charset="UTF-8">
> <title>View ABC Ontology</title>
> <link href="../_css/site.css" rel="stylesheet">
> <script src="../_js/jquery-1.7.2.min.js"></script>
> <script>
> var q1 = "PREFIX abc: <http://www.i-a-i.com/odcs#>\n"
> +    "PREFIX owl:  <http://www.w3.org/2002/07/owl#>\n"
>      +    "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
>      +    "PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\n"
> +    "SELECT  ?t ?l\n"
>      +    "WHERE   { ?t a owl:Thing .\n"
>      +    "      OPTIONAL\n"
>      +    "          { ?s rdfs:label ?l }\n"
>      +    "        }\n\n"
>      +    " ORDER BY ?t ";
>
> var url = "http://localhost:3030/query";
> // also tried with "http://localhost:3030" with same result
>
> $(document).ready(function() {
> var jqXHR = $.post( url, q1 );
>      jqXHR.done( function( data ) {
>          var reply =  $( data ).find( "#content" );
>          $( "#result" ).empty().append( reply );
> });     // end done
>
> }); // end ready
> </script>
> </head>
> <body>
> <div class="main">
> <h1>List of classes descendant from owl:Thing</h1>
> <div id="result" >
> <!-- to be filled in-->
> </div>
> </body>
> </html>
>
> I see the <h1> in the output, but nothing else.
>
> Dave Patterson
>
>
>
> ________________________________
> This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.
>


Re: Fuseki and other web traffic

Posted by Rob Vesse <rv...@dotnetrdf.org>.
Your URLs are incorrect since they omit the service name (set by the
fuseki:name property in your configuration)

So for your example it should be http://localhost:3030/aronat/query

Rob

On 10/11/2014 15:45, "David Patterson" <dp...@i-a-i.com> wrote:

>Andy and Osma,
>
>1) I've updated to the jena-fuseki-1.1.2-SNAPSHOT version.
>
>2) I'm starting Fuseki as:
>cd \jena\jena-fuseki-1.1.2-SNAPSHOT
>call fuseki-server --update --config=e:\abc\project1\fuseki1.ttl
>
>3) assembler file: (minus the comments)
>@prefix fuseki:  <http://jena.apache.org/fuseki#> .
>@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
>@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
>@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
>@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
>@prefix :        <#> .
>
>[] rdf:type fuseki:Server ;
>
>fuseki:services (
>     <#service2>
>) .
>
># Declaration additional assembler items.
>[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .
>
># TDB
>tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
>tdb:GraphTDB    rdfs:subClassOf  ja:Model .
>
><#service2> rdf:type fuseki:Service ;
>fuseki:name                     "aronat" ;   # http://www.i-a-i.com/abc
>fuseki:serviceQuery             "query" ;    # SPARQL query service
>fuseki:serviceReadGraphStore    "data" ;     # SPARQL Graph store
>protocol (read only)
> fuseki:dataset           <http://www.i-a-i.com/aronat> .
>
><http://www.i-a-i.com/aronat>    rdf:type ja:RDFDataset ;
>rdfs:label "Aronat" ;
>ja:defaultGraph
>      [ rdfs:label "ABC for ABC" ;
>        a ja:MemoryModel ;
>        ja:content [ja:externalContent <file:structure.0001.ttl> ] ;
>        ja:content [ja:externalContent <file:abc.0001.ttl> ] ;
>] .
>
>4) The HTML file:
><!DOCTYPE html>
><html>
><head>
><meta charset="UTF-8">
><title>View ABC Ontology</title>
><link href="../_css/site.css" rel="stylesheet">
><script src="../_js/jquery-1.7.2.min.js"></script>
><script>
>var q1 = "PREFIX abc: <http://www.i-a-i.com/odcs#>\n"
>+    "PREFIX owl:  <http://www.w3.org/2002/07/owl#>\n"
>    +    "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
>    +    "PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\n"
>+    "SELECT  ?t ?l\n"
>    +    "WHERE   { ?t a owl:Thing .\n"
>    +    "      OPTIONAL\n"
>    +    "          { ?s rdfs:label ?l }\n"
>    +    "        }\n\n"
>    +    " ORDER BY ?t ";
>
>var url = "http://localhost:3030/query";
>// also tried with "http://localhost:3030" with same result
>
>$(document).ready(function() {
>var jqXHR = $.post( url, q1 );
>    jqXHR.done( function( data ) {
>        var reply =  $( data ).find( "#content" );
>        $( "#result" ).empty().append( reply );
>});     // end done
>
>}); // end ready
></script>
></head>
><body>
><div class="main">
><h1>List of classes descendant from owl:Thing</h1>
><div id="result" >
><!-- to be filled in-->
></div>
></body>
></html>
>
>I see the <h1> in the output, but nothing else.
>
>Dave Patterson
>
>
>
>________________________________
>This message and all attachments are PRIVATE, and contain information
>that is PROPRIETARY to Intelligent Automation, Inc. You are not
>authorized to transmit or otherwise disclose this message or any
>attachments to any third party whatsoever without the express written
>consent of Intelligent Automation, Inc. If you received this message in
>error or you are not willing to view this message or any attachments on a
>confidential basis, please immediately delete this email and any
>attachments and notify Intelligent Automation, Inc.





RE: Fuseki and other web traffic

Posted by David Patterson <dp...@i-a-i.com>.
Andy and Osma,

1) I've updated to the jena-fuseki-1.1.2-SNAPSHOT version.

2) I'm starting Fuseki as:
cd \jena\jena-fuseki-1.1.2-SNAPSHOT
call fuseki-server --update --config=e:\abc\project1\fuseki1.ttl

3) assembler file: (minus the comments)
@prefix fuseki:  <http://jena.apache.org/fuseki#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix :        <#> .

[] rdf:type fuseki:Server ;

fuseki:services (
     <#service2>
) .

# Declaration additional assembler items.
[] ja:loadClass "com.hp.hpl.jena.tdb.TDB" .

# TDB
tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .
tdb:GraphTDB    rdfs:subClassOf  ja:Model .

<#service2> rdf:type fuseki:Service ;
fuseki:name                     "aronat" ;   # http://www.i-a-i.com/abc
fuseki:serviceQuery             "query" ;    # SPARQL query service
fuseki:serviceReadGraphStore    "data" ;     # SPARQL Graph store protocol (read only)
 fuseki:dataset           <http://www.i-a-i.com/aronat> .

<http://www.i-a-i.com/aronat>    rdf:type ja:RDFDataset ;
rdfs:label "Aronat" ;
ja:defaultGraph
      [ rdfs:label "ABC for ABC" ;
        a ja:MemoryModel ;
        ja:content [ja:externalContent <file:structure.0001.ttl> ] ;
        ja:content [ja:externalContent <file:abc.0001.ttl> ] ;
] .

4) The HTML file:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>View ABC Ontology</title>
<link href="../_css/site.css" rel="stylesheet">
<script src="../_js/jquery-1.7.2.min.js"></script>
<script>
var q1 = "PREFIX abc: <http://www.i-a-i.com/odcs#>\n"
+    "PREFIX owl:  <http://www.w3.org/2002/07/owl#>\n"
    +    "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
    +    "PREFIX rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\n"
+    "SELECT  ?t ?l\n"
    +    "WHERE   { ?t a owl:Thing .\n"
    +    "      OPTIONAL\n"
    +    "          { ?s rdfs:label ?l }\n"
    +    "        }\n\n"
    +    " ORDER BY ?t ";

var url = "http://localhost:3030/query";
// also tried with "http://localhost:3030" with same result

$(document).ready(function() {
var jqXHR = $.post( url, q1 );
    jqXHR.done( function( data ) {
        var reply =  $( data ).find( "#content" );
        $( "#result" ).empty().append( reply );
});     // end done

}); // end ready
</script>
</head>
<body>
<div class="main">
<h1>List of classes descendant from owl:Thing</h1>
<div id="result" >
<!-- to be filled in-->
</div>
</body>
</html>

I see the <h1> in the output, but nothing else.

Dave Patterson



________________________________
This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.

Re: Fuseki and other web traffic

Posted by Andy Seaborne <an...@apache.org>.
Hi there,

In Fuseki1, the supplied web pages are just a HTML page. Everything is 
plain-old HTML forms so I'm not sure why you see nothing.

If it's query/update it is as Osma says.  The development snapshot build 
should have completed CORS support.

	Andy

On 10/11/14 06:46, Osma Suominen wrote:
> Hi Dave!
>
> CORS headers for read-only queries (i.e. to the query URL, not the
> update URL) should be set already in Fuseki 1.1.1. For the update
> endpoint CORS headers were added recently, see
> https://issues.apache.org/jira/browse/JENA-652 .
>
> Does it help to use the most recent Fuseki snapshot release?
>
> What is the Fuseki URL you are accessing? I.e. the part after
> localhost:3030.
>
> If you still can't get it to work with the current snapshot, can you
> provide a minimal example (a HTML/JS page) demonstrating the problem?
>
> I've used Fuseki successfully with the SKOSjs editor, which performs
> AJAX (XMLHttpRequest) SPARQL queries against both the query and update
> endpoints. The update queries only started to work after JENA-652.
>
> -Osma
>
>
> On 09/11/14 23:49, David Patterson wrote:
>> I've loaded the latest Fuseki (1.1.1) and it runs. I can use the
>> control panel to select my dataset and issue queries.
>>
>> However, when I load a web page into a browser (via File->Open page)
>> that calls http://localhost:3030/... I see nothing in the browser.
>> When I look at the javascript console for the page, I see an error
>> message:
>>
>> XMLHttpRequest cannot load http://localhost:3030/. No
>> 'Access-Control-Allow-Origin' header is present on the requested
>> resource. Origin 'null' is therefore not allowed access.
>>
>> Is there a recommended approach to this? I want to have a web page
>> that issues a Fuseki query for a starting set of resources. I'll then
>> format them with appropriate links so the user can delve into the data
>> as they wish.
>>
>> (a) Should I setup another server (such as Apache Tomcat) so the user
>> asks it for the first page which issues the Fuseki request?
>>
>> (b) Do I setup an Apache Tomcat (or other server) with servlets, so my
>> first request is to a servlet that issues an http request to Fuseki
>> and then returns the data to be formatted?
>>
>> (c) Something else?
>>
>> I'm willing to do whatever it takes to make this work, but I'd like to
>> have some idea that it will work before trying it.
>>
>> I'm currently running on a Windows 7 desktop machine with lots of
>> resources, but it may eventually run on a Mac.
>>
>> Thanks.
>>
>> Dave Patterson
>>
>>
>>
>> ________________________________
>> This message and all attachments are PRIVATE, and contain information
>> that is PROPRIETARY to Intelligent Automation, Inc. You are not
>> authorized to transmit or otherwise disclose this message or any
>> attachments to any third party whatsoever without the express written
>> consent of Intelligent Automation, Inc. If you received this message
>> in error or you are not willing to view this message or any
>> attachments on a confidential basis, please immediately delete this
>> email and any attachments and notify Intelligent Automation, Inc.
>>
>
>


Re: Fuseki and other web traffic

Posted by Osma Suominen <os...@helsinki.fi>.
Hi Dave!

CORS headers for read-only queries (i.e. to the query URL, not the 
update URL) should be set already in Fuseki 1.1.1. For the update 
endpoint CORS headers were added recently, see 
https://issues.apache.org/jira/browse/JENA-652 .

Does it help to use the most recent Fuseki snapshot release?

What is the Fuseki URL you are accessing? I.e. the part after 
localhost:3030.

If you still can't get it to work with the current snapshot, can you 
provide a minimal example (a HTML/JS page) demonstrating the problem?

I've used Fuseki successfully with the SKOSjs editor, which performs 
AJAX (XMLHttpRequest) SPARQL queries against both the query and update 
endpoints. The update queries only started to work after JENA-652.

-Osma


On 09/11/14 23:49, David Patterson wrote:
> I've loaded the latest Fuseki (1.1.1) and it runs. I can use the control panel to select my dataset and issue queries.
>
> However, when I load a web page into a browser (via File->Open page) that calls http://localhost:3030/... I see nothing in the browser. When I look at the javascript console for the page, I see an error message:
>
> XMLHttpRequest cannot load http://localhost:3030/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
>
> Is there a recommended approach to this? I want to have a web page that issues a Fuseki query for a starting set of resources. I'll then format them with appropriate links so the user can delve into the data as they wish.
>
> (a) Should I setup another server (such as Apache Tomcat) so the user asks it for the first page which issues the Fuseki request?
>
> (b) Do I setup an Apache Tomcat (or other server) with servlets, so my first request is to a servlet that issues an http request to Fuseki and then returns the data to be formatted?
>
> (c) Something else?
>
> I'm willing to do whatever it takes to make this work, but I'd like to have some idea that it will work before trying it.
>
> I'm currently running on a Windows 7 desktop machine with lots of resources, but it may eventually run on a Mac.
>
> Thanks.
>
> Dave Patterson
>
>
>
> ________________________________
> This message and all attachments are PRIVATE, and contain information that is PROPRIETARY to Intelligent Automation, Inc. You are not authorized to transmit or otherwise disclose this message or any attachments to any third party whatsoever without the express written consent of Intelligent Automation, Inc. If you received this message in error or you are not willing to view this message or any attachments on a confidential basis, please immediately delete this email and any attachments and notify Intelligent Automation, Inc.
>


-- 
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Teollisuuskatu 23)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suominen@helsinki.fi
http://www.nationallibrary.fi