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 Perez-Lopez <da...@gmail.com> on 2012/11/19 15:12:16 UTC

Unable to connect with fuseki SPARQL endpoint through Sesame connector

Hello,

I've set-up a SPARQL endpoint with fuseki with the following options:

    $ java -Xmx1200M -jar fuseki-server.jar --update --mem /ds
    14:02:23 INFO  Server               :: Dataset: in-memory
    14:02:23 INFO  Server               :: Dataset path = /ds
    14:02:23 INFO  Server               :: Fuseki 0.2.5
2012-10-20T17:03:29+0100
    14:02:23 INFO  Server               :: Started 2012/11/19 14:02:23 CET
on port 3030


then I've added some data to it `/s-put http://localhost:3030/ds/datadefault
/Users/david/desarrollo/proyectos/trunk-pom/pom-sparql/src/test/resources/ontologies/democomiccon2011.owl`

after that I could query easily the dataset through the web interface, and
get some results for example:


http://localhost:3030/ds/query?query=select+*+where+{%3Fx+%3Fd+%3Fx}&output=xml&stylesheet=%2Fxml-to-html.xsl<http://localhost:3030/ds/query?query=select+*+where+%7B%3Fx+%3Fd+%3Fx%7D&output=xml&stylesheet=%2Fxml-to-html.xsl>

My next step was to try to connect with the endpoint through a Sesame
connector (2.6.0) using the URL
`http://localhost:3030/ds/sparql`<http://localhost:3030/ds/sparql>but
I got a 404 error.

Previously, I had been able to connect successfully to a Virtuoso server
through the same connector, namely to
`http://aemet.linkeddata.es/sparql`<http://aemet.linkeddata.es/sparql>

I debugged both connections the one with virtuoso [virtuoso connection
debug][1] and the one with fuseki [fuseki connection debug][2] trying to
find differences, but without success. Feel free to check both text files
attached

I also tried to simulate the call with Poster extension for firefox and as
you can see in the image the GET request works but the POST doesn't
![Poster extension get/post requests to fuseki server][3]

Any clues of how could I connect to fuseki through a sesame connector? Does
it only supports GET requests? Thanks in advance

----------


  [1]:
https://dl.dropbox.com/u/9437566/fuseki_bug/virtuoso_sesame_connector_aemet.txt
  [2]:
https://dl.dropbox.com/u/9437566/fuseki_bug/fuseki_sesame_connector_localhost.txt
  [3]:
https://dl.dropbox.com/u/9437566/fuseki_bug/fuseki_poster_get_post_firefox.PNG

Re: Unable to connect with fuseki SPARQL endpoint through Sesame connector

Posted by David Perez-Lopez <da...@gmail.com>.
Thanks for the tips Andy. I finally solved the problem with them.

I launched fuseki with the dataset: /repositories/ds

$ java -Xmx1200M -jar fuseki-server.jar --update --mem /repositories/ds
> 18:35:45 INFO  Server               :: Dataset: in-memory
> 18:35:45 INFO  Server               :: Dataset path = /repositories/ds
> 18:35:45 INFO  Server               :: Fuseki 0.2.5
> 2012-10-20T17:03:29+0100
> 18:35:45 INFO  Server               :: Started 2012/11/20 18:35:45 CET on
> port 3030
>

and in my piece of code I created the repository with the repositoryID as
ds/sparql

        String endpointFuseki = "http://localhost:3030/";
>         String repositoryID="ds/sparql"
>
>         HTTPRepository endPoint = new HTTPRepository(endpointFuseki,
> repositoryID);
>


2012/11/20 Andy Seaborne <an...@apache.org>

> If the log isn't showing anything, then requests aren't arriving at Fuseki
> within Jetty.  That means a URL is sent that isn't routed to a n endpoint.
>  Usually, the URL is wrong.
>
> You have named a Sesame repository http://localhost:3030/ds/**sparql<http://localhost:3030/ds/sparql>-- but that in Fuseki is a SPARQL endpoint, not a Sesame repository
>
> http://www.openrdf.org/doc/**sesame2/system/ch08.html<http://www.openrdf.org/doc/sesame2/system/ch08.html>says:
>
> """
> Queries on a specific repository with ID <ID> can be evaluated by sending
> requests to: <SESAME_URL>/repositories/<ID>**.
> """
> e.g.
>  GET /openrdf-sesame/repositories/**mem-rdf?query
>
> so my guess is that it is attaching "/repositories" to the address you
> specified and hence the SPARQL endpoint it uses is not actually the one you
> pass in.
>
> You might try:
>
> HTTPRepository("http://**localhost:3030/ds <http://localhost:3030/ds>",
> "")
> HTTPRepository("http://**localhost:3030/ <http://localhost:3030/>", "ds")
>
> if then sesame constructs the right URL for the SPARQL endpoint by adding
> the /query and filling in ?query=  but it is inserts /repositories, it's
> not going to work.
>
> The reverse works for me: sesame server and SOH/Fuseki command line tools:
>
> s-query --service 'http://localhost:8080/**openrdf-workbench/**
> repositories/ds/query<http://localhost:8080/openrdf-workbench/repositories/ds/query>'
> 'ASK{}'
>
> Or try running Fuseki with a dataset at "/repositories/ds"
>
>         Andy
>
>
>
> On 19/11/12 22:24, David Perez-Lopez wrote:
>
>> Thanks for answering Andy,
>>
>> Just in case it helps these is the piece of code I'm using for testing the
>> connection. Again if I use the URL stored in the variable endpointAEMT, it
>> works but if I do it with the one in endpointFuseki it doesn't.
>>
>>      public static void main(String[] args) {
>>
>>          // Doesn't work with
>>          String endpointFuseki = "http://localhost:3030/ds/**sparql<http://localhost:3030/ds/sparql>
>> ";
>>
>>          // Works with Virtuoso endpoint
>>          String endpointAEMT = "http://aemet.linkeddata.es/**sparql<http://aemet.linkeddata.es/sparql>
>> ";
>>
>>          try {
>>              HTTPRepository endPoint = new HTTPRepository(endpointFuseki,
>> "");
>>              endPoint.initialize();
>>
>>              RepositoryConnection conn =  endPoint.getConnection();
>>              try {
>>                  String sparqlQuery = "SELECT * WHERE {?X ?P ?Y} LIMIT 10
>> ";
>>                  TupleQuery query =
>> conn.prepareTupleQuery(**QueryLanguage.SPARQL, sparqlQuery);
>>                  TupleQueryResult result = query.evaluate();
>>
>>                  while (result.hasNext()) {
>>                      // do something linked and open
>>                  }
>>                }
>>              } finally {
>>                  conn.close();
>>              }
>>              catch (Exception e) {
>>                    e.printStackTrace();
>>                }
>>      }
>>
>>
>>
>>
>> And the log shows something like:
>>
>>> 15:41:22 INFO  [1] 404 Service Description: /ds/sparql
>>> ?
>>>
>>>
>> In fact in my method call there is no trace in the server terminal
>>
>> If a request is sent without a query, it's a service description request
>>
>>> (which you can't set yet).
>>>
>>> Try in a browser you get:
>>> [[
>>> Error 404: Service Description: /ds/sparql
>>> ]]
>>>
>>> You need a query.
>>>
>>> In a browser try:
>>>
>>> http://localhost:3030/ds/**sparql?query=ASK{}&output=text<http://localhost:3030/ds/sparql?query=ASK%7B%7D&output=text>
>>>
>>> (a simple query - force output to text)
>>>
>>> This is the SPARQL protocol which sesame supports (it's not chnaged for
>>> SPARQL 1.1).  There needs to be ?query or the POSTed form equivalent.
>>>
>>>
>> The browser replies with yes
>>
>>
>> I've tried with the Firefox addons firebug & tamperData to change the form
>> method to GET and modify the accepts and the parameters sent in the POST
>> variables to try to reproduce the same environment that are sent with the
>> Sesame connector, it keeps working with the browser but no lack with the
>> connector.
>>
>>
>

Re: Unable to connect with fuseki SPARQL endpoint through Sesame connector

Posted by Andy Seaborne <an...@apache.org>.
If the log isn't showing anything, then requests aren't arriving at 
Fuseki within Jetty.  That means a URL is sent that isn't routed to a n 
endpoint.  Usually, the URL is wrong.

You have named a Sesame repository http://localhost:3030/ds/sparql -- 
but that in Fuseki is a SPARQL endpoint, not a Sesame repository

http://www.openrdf.org/doc/sesame2/system/ch08.html says:

"""
Queries on a specific repository with ID <ID> can be evaluated by 
sending requests to: <SESAME_URL>/repositories/<ID>.
"""
e.g.
  GET /openrdf-sesame/repositories/mem-rdf?query

so my guess is that it is attaching "/repositories" to the address you 
specified and hence the SPARQL endpoint it uses is not actually the one 
you pass in.

You might try:

HTTPRepository("http://localhost:3030/ds", "")
HTTPRepository("http://localhost:3030/", "ds")

if then sesame constructs the right URL for the SPARQL endpoint by 
adding the /query and filling in ?query=  but it is inserts 
/repositories, it's not going to work.

The reverse works for me: sesame server and SOH/Fuseki command line tools:

s-query --service 
'http://localhost:8080/openrdf-workbench/repositories/ds/query' 'ASK{}'

Or try running Fuseki with a dataset at "/repositories/ds"

	Andy


On 19/11/12 22:24, David Perez-Lopez wrote:
> Thanks for answering Andy,
>
> Just in case it helps these is the piece of code I'm using for testing the
> connection. Again if I use the URL stored in the variable endpointAEMT, it
> works but if I do it with the one in endpointFuseki it doesn't.
>
>      public static void main(String[] args) {
>
>          // Doesn't work with
>          String endpointFuseki = "http://localhost:3030/ds/sparql";
>
>          // Works with Virtuoso endpoint
>          String endpointAEMT = "http://aemet.linkeddata.es/sparql";
>
>          try {
>              HTTPRepository endPoint = new HTTPRepository(endpointFuseki,
> "");
>              endPoint.initialize();
>
>              RepositoryConnection conn =  endPoint.getConnection();
>              try {
>                  String sparqlQuery = "SELECT * WHERE {?X ?P ?Y} LIMIT 10 ";
>                  TupleQuery query =
> conn.prepareTupleQuery(QueryLanguage.SPARQL, sparqlQuery);
>                  TupleQueryResult result = query.evaluate();
>
>                  while (result.hasNext()) {
>                      // do something linked and open
>                  }
>                }
>              } finally {
>                  conn.close();
>              }
>              catch (Exception e) {
>                    e.printStackTrace();
>                }
>      }
>
>
>
>
> And the log shows something like:
>> 15:41:22 INFO  [1] 404 Service Description: /ds/sparql
>> ?
>>
>
> In fact in my method call there is no trace in the server terminal
>
> If a request is sent without a query, it's a service description request
>> (which you can't set yet).
>>
>> Try in a browser you get:
>> [[
>> Error 404: Service Description: /ds/sparql
>> ]]
>>
>> You need a query.
>>
>> In a browser try:
>>
>> http://localhost:3030/ds/sparql?query=ASK{}&output=text
>>
>> (a simple query - force output to text)
>>
>> This is the SPARQL protocol which sesame supports (it's not chnaged for
>> SPARQL 1.1).  There needs to be ?query or the POSTed form equivalent.
>>
>
> The browser replies with yes
>
>
> I've tried with the Firefox addons firebug & tamperData to change the form
> method to GET and modify the accepts and the parameters sent in the POST
> variables to try to reproduce the same environment that are sent with the
> Sesame connector, it keeps working with the browser but no lack with the
> connector.
>


Re: Unable to connect with fuseki SPARQL endpoint through Sesame connector

Posted by David Perez-Lopez <da...@gmail.com>.
Thanks for answering Andy,

Just in case it helps these is the piece of code I'm using for testing the
connection. Again if I use the URL stored in the variable endpointAEMT, it
works but if I do it with the one in endpointFuseki it doesn't.

    public static void main(String[] args) {

        // Doesn't work with
        String endpointFuseki = "http://localhost:3030/ds/sparql";

        // Works with Virtuoso endpoint
        String endpointAEMT = "http://aemet.linkeddata.es/sparql";

        try {
            HTTPRepository endPoint = new HTTPRepository(endpointFuseki,
"");
            endPoint.initialize();

            RepositoryConnection conn =  endPoint.getConnection();
            try {
                String sparqlQuery = "SELECT * WHERE {?X ?P ?Y} LIMIT 10 ";
                TupleQuery query =
conn.prepareTupleQuery(QueryLanguage.SPARQL, sparqlQuery);
                TupleQueryResult result = query.evaluate();

                while (result.hasNext()) {
                    // do something linked and open
                }
              }
            } finally {
                conn.close();
            }
            catch (Exception e) {
                  e.printStackTrace();
              }
    }




And the log shows something like:
> 15:41:22 INFO  [1] 404 Service Description: /ds/sparql
> ?
>

In fact in my method call there is no trace in the server terminal

If a request is sent without a query, it's a service description request
> (which you can't set yet).
>
> Try in a browser you get:
> [[
> Error 404: Service Description: /ds/sparql
> ]]
>
> You need a query.
>
> In a browser try:
>
> http://localhost:3030/ds/sparql?query=ASK{}&output=text
>
> (a simple query - force output to text)
>
> This is the SPARQL protocol which sesame supports (it's not chnaged for
> SPARQL 1.1).  There needs to be ?query or the POSTed form equivalent.
>

The browser replies with yes


I've tried with the Firefox addons firebug & tamperData to change the form
method to GET and modify the accepts and the parameters sent in the POST
variables to try to reproduce the same environment that are sent with the
Sesame connector, it keeps working with the browser but no lack with the
connector.

Re: Unable to connect with fuseki SPARQL endpoint through Sesame connector

Posted by Andy Seaborne <an...@apache.org>.
On 19/11/12 15:46, Andy Seaborne wrote:
> This is the SPARQL protocol which sesame supports (it's not chnaged for
> SPARQL 1.1).  There needs to be ?query or the POSTed form equivalent.

That's not quite right - the service description at the plain URL 
endpoint is added by SPARQL 1.1 (it's in the service description spec, 
not the protocol which is unchanged but only applies to ?query and ?request.

	Andy


Re: Unable to connect with fuseki SPARQL endpoint through Sesame connector

Posted by Andy Seaborne <an...@apache.org>.
On 19/11/12 14:12, David Perez-Lopez wrote:
> Hello,
>
> I've set-up a SPARQL endpoint with fuseki with the following options:
>
>      $ java -Xmx1200M -jar fuseki-server.jar --update --mem /ds
>      14:02:23 INFO  Server               :: Dataset: in-memory
>      14:02:23 INFO  Server               :: Dataset path = /ds
>      14:02:23 INFO  Server               :: Fuseki 0.2.5
> 2012-10-20T17:03:29+0100
>      14:02:23 INFO  Server               :: Started 2012/11/19 14:02:23 CET
> on port 3030
>
>
> then I've added some data to it `/s-put http://localhost:3030/ds/datadefault
> /Users/david/desarrollo/proyectos/trunk-pom/pom-sparql/src/test/resources/ontologies/democomiccon2011.owl`
>
> after that I could query easily the dataset through the web interface, and
> get some results for example:
>
>
> http://localhost:3030/ds/query?query=select+*+where+{%3Fx+%3Fd+%3Fx}&output=xml&stylesheet=%2Fxml-to-html.xsl<http://localhost:3030/ds/query?query=select+*+where+%7B%3Fx+%3Fd+%3Fx%7D&output=xml&stylesheet=%2Fxml-to-html.xsl>
>
> My next step was to try to connect with the endpoint through a Sesame
> connector (2.6.0) using the URL
> `http://localhost:3030/ds/sparql`<http://localhost:3030/ds/sparql>but
> I got a 404 error.

And the log shows something like:
15:41:22 INFO  [1] 404 Service Description: /ds/sparql
?

If a request is sent without a query, it's a service description request 
(which you can't set yet).

Try in a browser you get:
[[
Error 404: Service Description: /ds/sparql
]]

You need a query.

In a browser try:

http://localhost:3030/ds/sparql?query=ASK{}&output=text

(a simple query - force output to text)

This is the SPARQL protocol which sesame supports (it's not chnaged for 
SPARQL 1.1).  There needs to be ?query or the POSTed form equivalent.
>
> Previously, I had been able to connect successfully to a Virtuoso server
> through the same connector, namely to
> `http://aemet.linkeddata.es/sparql`<http://aemet.linkeddata.es/sparql>
>
> I debugged both connections the one with virtuoso [virtuoso connection
> debug][1] and the one with fuseki [fuseki connection debug][2] trying to
> find differences, but without success. Feel free to check both text files
> attached
>
> I also tried to simulate the call with Poster extension for firefox and as
> you can see in the image the GET request works but the POST doesn't
> ![Poster extension get/post requests to fuseki server][3]
>
> Any clues of how could I connect to fuseki through a sesame connector? Does
> it only supports GET requests? Thanks in advance

GET and POST

	Andy

>
> ----------
>
>
>    [1]:
> https://dl.dropbox.com/u/9437566/fuseki_bug/virtuoso_sesame_connector_aemet.txt
>    [2]:
> https://dl.dropbox.com/u/9437566/fuseki_bug/fuseki_sesame_connector_localhost.txt
>    [3]:
> https://dl.dropbox.com/u/9437566/fuseki_bug/fuseki_poster_get_post_firefox.PNG
>