Re: Unable to load a remote context

Doh, I knew I was missing the obvious.  I disregarded the warning about CORS because at first I was not using any client-side Javascript but a custom Java client (using jsonld-java).  Only after fixing a few other problems (typos in the context, not returning the correct content-type etc.) did I start testing on the playground. However, all is well now.

@David Lehn: One thing that would make the problem clearer is to identify the exact cause rather than a list of things that might be the problem.  I only took a quick look at the Javascript code, but it looked like it should be possible to determine if A) the URL couldn't be dereferenced, B) the document was not valid JSON, C) CORS header was not present, or D) more than on link header was provided.  In my case I had several of the above problems, but even after fixing them the error message remained the same so it was never clear if I was fixing anything or making things worse.

@ Dave Longley:  I just did a "git pull" from master and didn't see any changes so maybe you haven't pushed the changes yet.  I just wanted to mention that there were five instances of the same typo.

Thanks for the help. Time to go link some data!

Cheers,
Keith

On Apr 17, 2014, at 6:50 PM, David I. Lehn <dil@lehn.org> wrote:

> On Thu, Apr 17, 2014 at 5:21 PM, Keith Suderman <suderman@anc.org> wrote:
>> I am experimenting with JSON-LD and I am having a problem loading a remote
>> context, I keep getting the error “Derefencing a URL did not result in a
>> valid JSON-LD object”.  (Full error message is included below).
>> ...
>> {
>> "@context": "http://vocab.lappsgrid.org/person.jsonld"
>> }
>> 
>> Can anyone spot the problem? I am stumped.
>> 
>> The full error message is:
>> 
>> { "name": "jsonld.InvalidUrl", "message": "Derefencing a URL did not result
>> in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps
>> due to a same-origin policy (ensure the server uses CORS if you are using
>> client-side JavaScript), too many redirects, a non-JSON response, or more
>> than one HTTP Link Header was provided for a remote context.", "details": {
>> "code": "loading remote context failed", "url":
>> "http://vocab.lappsgrid.org/person.jsonld", "cause": { "name":
>> "jsonld.LoadDocumentError", "message": "URL could not be dereferenced, an
>> error occurred.", "details": { "code": "loading document failed", "url":
>> "http://vocab.lappsgrid.org/person.jsonld", "cause": "" } } } }
>> 
> 
> It doesn't look like your server has CORS enabled for the vocab resource:
> http://vocab.lappsgrid.org/person.jsonld
> 
> This site has some CORS info and setup help:
> http://enable-cors.org/
> 
> The error message does suggest this as a potential problem.  And
> current chrome has console XHR error messages mentioning missing CORS
> headers.  Since you seem to have run into this issue, can you suggest
> a better way to make this sort of problem and solutions clearer?
> 
> 
>> P.S. I also noticed a small spelling mistake in the error message;
>> “Derefencing” instead of “Dereferencing”.  I can prepare a pull request if
>> anyone wants it.
>> 
> 
> Please do.
> 
> -dave
> 

------------------------------
Research Associate
Department of Computer Science
Vassar College
Poughkeepsie, NY

Received on Friday, 18 April 2014 02:25:17 UTC