I was previously using native Sesame (2.8.3). As I needed OWL inferencing, I installed GraphDB-Lite (the Sesame .war version 2.7.8). While the inferencing is fine, I'm unable to use my previous code. The code is below:

$(document).ready(function() {
                url: 'http://my.ip.address.here:8080/openrdf-sesame/repositories/repositoryName',
                dataType: 'jsonp', 
                data: { 
                    queryLn: 'SPARQL',
                    query: adValQuery, 
                    infer: 'true',
                    Accept: 'application/json'
                success: adValDisplayData,
                error: adValDisplayError

    function adValDisplayError(xhr, textStatus, errorThrown) {

    function adValDisplayData(adValData) {
        var testHeader = $('#result thread').append('<tr/>');
        $.each(adValData.head.vars, function(key,value) {
            header.append("<th>" + value + "</th>");
        var rowCount = 0;

        $.each(adValData.results.bindings, function(index, adValQueryResult) {
        var row = $('<tr/>');
        $.each(adValData.head.vars, function(key, varname) {
            row.append("<td>" + adValQueryResult[varname].value + "</td>"); 
           //Capturing query results as variables 
        $("#result tbody").after(row);

        adValCount = adValDataObjects.length/6;

Both Chrome and Firefox report errors in the console:

  1. Chrome: Uncaught SyntaxError: Unexpected token :

  2. Firefox: SyntaxError: missing ; before statement.

On the main page, the "Error: jQuery19108598828004544555_1436556866856 was not called" pops up. How can I resolve this issue?

I read in the documentation of Sesame 2.7.12 that some issues with jsonp were fixed. I'm curious if my problem has got anything to do with the version of GraphDB-Lite preceding 2.7.12.

UPDATE 1: This is a follow-up to Jeen's suggestions.

Thank you for the detailed response, Jeen. A couple of points:

  1. I had tried to install GraphDB-Lite on Sesame 2.7.16 suspecting some issue of the sort you mentioned. However, replacing the Sesame .war files with those of GraphDB reverts the version of Sesame to 2.7.8 (that of GraphDB). That approach hence doesn't work.

  2. As I need to get a version out at the earliest, I'd want to go ahead with the hack for now and use CORS in the second spiral. When I use http://my.ip.address.here:8080/openrdf-workbench/repositories/repositoryName/query as the url in ajax, I get the following error:

    Uncaught SyntaxError: Unexpected token <

This is probably because the result from the server is an XML file with the first couple of lines of the code being:

<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/xsl' href='/openrdf-workbench/transformations/query.xsl'?>

Do I have to change the format of the response?

UPDATE-2: Adding headers to accept application/json I'm trying to edit the code to include headers. This presently doesn't work:


  //       beforeSend: function(xhr) {
  //   xhr.setRequestHeader("Content-Type", "application/json");
  //   xhr.setRequestHeader("Accept", "application/json");
  // },

  url: 'http://my.ip.address.here:8080/openrdf-workbench/repositories/TVP_1/query',

  headers: { 
    accept : "application/json",
    "Content-Type": "application/json"
dataType: 'jsonp',
data: { 
    queryLn: 'SPARQL',
    query: allScansQuery, 
    limit: 100,
    infer: 'true',

success: allScansDisplayData,
error: allScansDisplayError


If someone can help me figure out what needs to be changed, I'll be grateful.

asked 10 Jul '15, 23:37

kurious's gravatar image

accept rate: 0%

edited 13 Jul '15, 21:02

This is likely caused by a known issue in Sesame Server (SES-2164) with JSONP callbacks, which was fixed in Sesame release 2.7.15.

A possible solution is to upgrade the version of Sesame included in your GraphDB installation to 2.7.15 (or 2.7.16, which is the latest 2.7.x version). I must caution you that this is untested and may cause other things to fail. UPDATE the way to do this is to first install GraphDB, and then replace the sesame jar files included in the webapp with those of the newer version.

Alternatively, there is a workaround: instead of directly accessing the Sesame Server REST API, use the Sesame Workbench application as a 'proxy' for JSONP callbacks. This is very simple to try actually. In your jQuery script, instead of using the Sesame Server REST API URL:


use this URL for the Workbench app's query screen:


UPDATE to control the output format, make sure you set the correct Accept header. By default it will respond with the query result in application/sparql-results+xml format (this is what you are receiving). If you want JSON you need to ask for application/sparql-results+json or just application/json. If setting the Accept header doesn't work for some reason, you can also try to specify the format by adding Accept=application/json as a parameter, instead.

I should point out that this is a hack: it makes use of an undocumented feature of the Workbench application, so this may stop working when you upgrade your version of Sesame. However, if upgrading to a newer 2.7.x version is currently not an option, you can use this as a short-term solution.

The best solution, however, is this: don't use JSONP callbacks at all. Instead, if you must do cross-domain access from Javascript, use CORS headers. Although Sesame/GraphDB itself has no built-in support for this, you can easily configure your Tomcat servlet container to add CORS headers to responses via a filter. See the Tomcat 7 documentation for more info on how to do this. Added bonus is that it is a safer mechanism.


answered 11 Jul '15, 20:03

Jeen%20Broekstra's gravatar image

Jeen Broekstra
accept rate: 66%

edited 12 Jul '15, 16:13

Hi Jeen, I've tried your suggestions but still face issues.I've updated my question accordingly. Please have a look.

(11 Jul '15, 23:42) kurious

I've edited my answer to address your updates.

(12 Jul '15, 16:12) Jeen Broekstra

Thank you very much, Jeen. Can you please show an example of how to add "Accept=application/json as a parameter"? I've found several examples of using accept:application/json inside headers object as well as outside (as in the present code) within ajax. None of them solve the issue and generate the same error.

(13 Jul '15, 14:16) kurious

@kurious you are actually already doing this in your jQuery code above: the data block is the list of request parameters you are sending with the request, and it contains an Accept parameter. If instead you want to try sending a proper HTTP header (which is actually the recommended way to do this), you need to modify your jQuery Ajax call accordingly (I'm no jQuery expert but there's plenty of examples out there on how to do this - just google 'jquery set accept http header').

(13 Jul '15, 17:22) Jeen Broekstra

Sure, Jeen. I will try some more approaches and report what works.

(13 Jul '15, 18:45) kurious

Resolved! Here's what worked:

  1. As Jeen suggested, I replaced the jar files of GraphDB with those of Sesame 2.7.16. I copied the same set of files to the 'libs' folder of both Sesame-openrdf and Sesame-workbench. Though some jar files are duplicate, I did not remove one version for the other.

  2. In the ajax query, I retained the previous URL i.e., http://my.ip.address.here:8080/openrdf-sesame/repositories/repositoryName instead of querying the workbench. In fact, querying the workbench returns XML even when I specify application/json under the 'accept' parameter under headers or data or even while using the 'accepts' parameter in itself.

  3. For anyone reading this, please note this is a risky workaround at best (Jeen specifies that in his response). I will implement CORS soon and add a response about what works for me.


answered 14 Jul '15, 13:41

kurious's gravatar image

accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 10 Jul '15, 23:37

Seen: 2,668 times

Last updated: 03 Jun, 05:58

powered by BitNami OSQA