You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Zen 98052 <z9...@outlook.com> on 2016/06/21 15:00:37 UTC

got exception on specific query

Hi,

I got exception when calling QueryFactory.create(query); where query is following:


PREFIX v: <http://b/dir/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (COUNT(?idObj) AS ?idCount) WHERE
{
  {
    SELECT ?person ?idObj WHERE
    {
      ?person v:hasUniqueID ?idObj .
    }
  }
  ?person v:hasDataContext ?dc .
  ?dc v:metadataID "foobar" .
}


The exception I got is:

com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
    at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
    at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
    at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
    at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
...


However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.

Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11

Though it is working now, but I wonder if this is safe option? If not, what is the workaround?



Thanks,

Z

Re: got exception on specific query

Posted by Andy Seaborne <an...@apache.org>.
On 22/06/16 00:11, Zen 98052 wrote:
> Thanks Andy!
>
> Aside from this bizarre issue, i'd think passing syntaxARQ is fine, because it's an extension of syntaxSPARQL_11, right?

Yes.

(Ssh! - don't tell anyone but Fuseki uses Syntax.syntaxARQ)

     Andy

>
> ________________________________
> From: Andy Seaborne <an...@apache.org>
> Sent: Tuesday, June 21, 2016 6:00:29 PM
> To: users@jena.apache.org
> Subject: Re: got exception on specific query
>
> On 21/06/16 22:09, Zen 98052 wrote:
>> Yes, that's really weird. It works fine on previous deployment (using same version of Jena, and same call to QueryFactory.create)
>>
>> Do you see any problem if I pass Syntax.syntaxARQ?
>
> Yes - the underlying fault is still there!  The exception message is as
> far as I can tell, due to catching a java.lang.Error which does not come
> from the parser.  Such java.lang.Error are a sign of a low-level problem
> - the fact you see in some places and not others is also a bad sign (tm).
>
> FWIW My best guess, with little evidence, is a corrupt class file or
> something of that kind.
>
>          Andy
>
>>
>>
>>
>> Thanks,
>>
>> Z
>>
>> ________________________________
>> From: Andy Seaborne <an...@apache.org>
>> Sent: Tuesday, June 21, 2016 4:55:28 PM
>> To: users@jena.apache.org
>> Subject: Re: got exception on specific query
>>
>> On 21/06/16 21:02, Zen 98052 wrote:
>>> Yes, still using Jena 2, to be precise, v2.13.0
>>
>> I tried the query in various versions (3.x, 2.13.0, 2.11) and they all
>> work.  My test was to run "qparse" on the query which calls
>> QueryFactory.parse
>>
>>           Andy
>>
>>>
>>> ________________________________
>>> From: Andy Seaborne <an...@apache.org>
>>> Sent: Tuesday, June 21, 2016 3:19:17 PM
>>> To: users@jena.apache.org
>>> Subject: Re: got exception on specific query
>>>
>>> Which version are you using?
>>>
>>>     > com.hp.hpl.jena.
>>>
>>> Jena2, not Jena3.
>>>
>>>            Andy
>>>
>>> On 21/06/16 16:11, Zen 98052 wrote:
>>>>
>>>> What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.
>>>>
>>>> The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..
>>>>
>>>>
>>>> ________________________________
>>>> From: Zen 98052 <z9...@outlook.com>
>>>> Sent: Tuesday, June 21, 2016 11:00:37 AM
>>>> To: users@jena.apache.org
>>>> Subject: got exception on specific query
>>>>
>>>> Hi,
>>>>
>>>> I got exception when calling QueryFactory.create(query); where query is following:
>>>>
>>>>
>>>> PREFIX v: <http://b/dir/>
>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>>
>>>> SELECT (COUNT(?idObj) AS ?idCount) WHERE
>>>> {
>>>>       {
>>>>         SELECT ?person ?idObj WHERE
>>>>         {
>>>>           ?person v:hasUniqueID ?idObj .
>>>>         }
>>>>       }
>>>>       ?person v:hasDataContext ?dc .
>>>>       ?dc v:metadataID "foobar" .
>>>> }
>>>>
>>>>
>>>> The exception I got is:
>>>>
>>>> com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
>>>>         at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
>>>>         at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
>>>>         at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
>>>>         at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
>>>>         at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
>>>>         at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
>>>>         at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
>>>> ...
>>>>
>>>>
>>>> However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.
>>>>
>>>> Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11
>>>>
>>>> Though it is working now, but I wonder if this is safe option? If not, what is the workaround?
>>>>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Z
>>>>
>>>
>>>
>>
>>
>
>


Re: got exception on specific query

Posted by Zen 98052 <z9...@outlook.com>.
Thanks Andy!

Aside from this bizarre issue, i'd think passing syntaxARQ is fine, because it's an extension of syntaxSPARQL_11, right?

________________________________
From: Andy Seaborne <an...@apache.org>
Sent: Tuesday, June 21, 2016 6:00:29 PM
To: users@jena.apache.org
Subject: Re: got exception on specific query

On 21/06/16 22:09, Zen 98052 wrote:
> Yes, that's really weird. It works fine on previous deployment (using same version of Jena, and same call to QueryFactory.create)
>
> Do you see any problem if I pass Syntax.syntaxARQ?

Yes - the underlying fault is still there!  The exception message is as
far as I can tell, due to catching a java.lang.Error which does not come
from the parser.  Such java.lang.Error are a sign of a low-level problem
- the fact you see in some places and not others is also a bad sign (tm).

FWIW My best guess, with little evidence, is a corrupt class file or
something of that kind.

        Andy

>
>
>
> Thanks,
>
> Z
>
> ________________________________
> From: Andy Seaborne <an...@apache.org>
> Sent: Tuesday, June 21, 2016 4:55:28 PM
> To: users@jena.apache.org
> Subject: Re: got exception on specific query
>
> On 21/06/16 21:02, Zen 98052 wrote:
>> Yes, still using Jena 2, to be precise, v2.13.0
>
> I tried the query in various versions (3.x, 2.13.0, 2.11) and they all
> work.  My test was to run "qparse" on the query which calls
> QueryFactory.parse
>
>          Andy
>
>>
>> ________________________________
>> From: Andy Seaborne <an...@apache.org>
>> Sent: Tuesday, June 21, 2016 3:19:17 PM
>> To: users@jena.apache.org
>> Subject: Re: got exception on specific query
>>
>> Which version are you using?
>>
>>    > com.hp.hpl.jena.
>>
>> Jena2, not Jena3.
>>
>>           Andy
>>
>> On 21/06/16 16:11, Zen 98052 wrote:
>>>
>>> What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.
>>>
>>> The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..
>>>
>>>
>>> ________________________________
>>> From: Zen 98052 <z9...@outlook.com>
>>> Sent: Tuesday, June 21, 2016 11:00:37 AM
>>> To: users@jena.apache.org
>>> Subject: got exception on specific query
>>>
>>> Hi,
>>>
>>> I got exception when calling QueryFactory.create(query); where query is following:
>>>
>>>
>>> PREFIX v: <http://b/dir/>
>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>
>>> SELECT (COUNT(?idObj) AS ?idCount) WHERE
>>> {
>>>      {
>>>        SELECT ?person ?idObj WHERE
>>>        {
>>>          ?person v:hasUniqueID ?idObj .
>>>        }
>>>      }
>>>      ?person v:hasDataContext ?dc .
>>>      ?dc v:metadataID "foobar" .
>>> }
>>>
>>>
>>> The exception I got is:
>>>
>>> com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
>>>        at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
>>>        at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
>>>        at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
>>>        at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
>>>        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
>>>        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
>>>        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
>>> ...
>>>
>>>
>>> However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.
>>>
>>> Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11
>>>
>>> Though it is working now, but I wonder if this is safe option? If not, what is the workaround?
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Z
>>>
>>
>>
>
>


Re: got exception on specific query

Posted by Andy Seaborne <an...@apache.org>.
On 21/06/16 22:09, Zen 98052 wrote:
> Yes, that's really weird. It works fine on previous deployment (using same version of Jena, and same call to QueryFactory.create)
>
> Do you see any problem if I pass Syntax.syntaxARQ?

Yes - the underlying fault is still there!  The exception message is as 
far as I can tell, due to catching a java.lang.Error which does not come 
from the parser.  Such java.lang.Error are a sign of a low-level problem 
- the fact you see in some places and not others is also a bad sign (tm).

FWIW My best guess, with little evidence, is a corrupt class file or 
something of that kind.

	Andy

>
>
>
> Thanks,
>
> Z
>
> ________________________________
> From: Andy Seaborne <an...@apache.org>
> Sent: Tuesday, June 21, 2016 4:55:28 PM
> To: users@jena.apache.org
> Subject: Re: got exception on specific query
>
> On 21/06/16 21:02, Zen 98052 wrote:
>> Yes, still using Jena 2, to be precise, v2.13.0
>
> I tried the query in various versions (3.x, 2.13.0, 2.11) and they all
> work.  My test was to run "qparse" on the query which calls
> QueryFactory.parse
>
>          Andy
>
>>
>> ________________________________
>> From: Andy Seaborne <an...@apache.org>
>> Sent: Tuesday, June 21, 2016 3:19:17 PM
>> To: users@jena.apache.org
>> Subject: Re: got exception on specific query
>>
>> Which version are you using?
>>
>>    > com.hp.hpl.jena.
>>
>> Jena2, not Jena3.
>>
>>           Andy
>>
>> On 21/06/16 16:11, Zen 98052 wrote:
>>>
>>> What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.
>>>
>>> The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..
>>>
>>>
>>> ________________________________
>>> From: Zen 98052 <z9...@outlook.com>
>>> Sent: Tuesday, June 21, 2016 11:00:37 AM
>>> To: users@jena.apache.org
>>> Subject: got exception on specific query
>>>
>>> Hi,
>>>
>>> I got exception when calling QueryFactory.create(query); where query is following:
>>>
>>>
>>> PREFIX v: <http://b/dir/>
>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>
>>> SELECT (COUNT(?idObj) AS ?idCount) WHERE
>>> {
>>>      {
>>>        SELECT ?person ?idObj WHERE
>>>        {
>>>          ?person v:hasUniqueID ?idObj .
>>>        }
>>>      }
>>>      ?person v:hasDataContext ?dc .
>>>      ?dc v:metadataID "foobar" .
>>> }
>>>
>>>
>>> The exception I got is:
>>>
>>> com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
>>>        at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
>>>        at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
>>>        at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
>>>        at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
>>>        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
>>>        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
>>>        at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
>>> ...
>>>
>>>
>>> However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.
>>>
>>> Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11
>>>
>>> Though it is working now, but I wonder if this is safe option? If not, what is the workaround?
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Z
>>>
>>
>>
>
>


Re: got exception on specific query

Posted by Zen 98052 <z9...@outlook.com>.
Yes, that's really weird. It works fine on previous deployment (using same version of Jena, and same call to QueryFactory.create)

Do you see any problem if I pass Syntax.syntaxARQ?



Thanks,

Z

________________________________
From: Andy Seaborne <an...@apache.org>
Sent: Tuesday, June 21, 2016 4:55:28 PM
To: users@jena.apache.org
Subject: Re: got exception on specific query

On 21/06/16 21:02, Zen 98052 wrote:
> Yes, still using Jena 2, to be precise, v2.13.0

I tried the query in various versions (3.x, 2.13.0, 2.11) and they all
work.  My test was to run "qparse" on the query which calls
QueryFactory.parse

        Andy

>
> ________________________________
> From: Andy Seaborne <an...@apache.org>
> Sent: Tuesday, June 21, 2016 3:19:17 PM
> To: users@jena.apache.org
> Subject: Re: got exception on specific query
>
> Which version are you using?
>
>   > com.hp.hpl.jena.
>
> Jena2, not Jena3.
>
>          Andy
>
> On 21/06/16 16:11, Zen 98052 wrote:
>>
>> What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.
>>
>> The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..
>>
>>
>> ________________________________
>> From: Zen 98052 <z9...@outlook.com>
>> Sent: Tuesday, June 21, 2016 11:00:37 AM
>> To: users@jena.apache.org
>> Subject: got exception on specific query
>>
>> Hi,
>>
>> I got exception when calling QueryFactory.create(query); where query is following:
>>
>>
>> PREFIX v: <http://b/dir/>
>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>
>> SELECT (COUNT(?idObj) AS ?idCount) WHERE
>> {
>>     {
>>       SELECT ?person ?idObj WHERE
>>       {
>>         ?person v:hasUniqueID ?idObj .
>>       }
>>     }
>>     ?person v:hasDataContext ?dc .
>>     ?dc v:metadataID "foobar" .
>> }
>>
>>
>> The exception I got is:
>>
>> com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
>>       at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
>>       at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
>>       at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
>>       at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
>>       at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
>>       at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
>>       at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
>> ...
>>
>>
>> However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.
>>
>> Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11
>>
>> Though it is working now, but I wonder if this is safe option? If not, what is the workaround?
>>
>>
>>
>> Thanks,
>>
>> Z
>>
>
>


Re: got exception on specific query

Posted by Andy Seaborne <an...@apache.org>.
On 21/06/16 21:02, Zen 98052 wrote:
> Yes, still using Jena 2, to be precise, v2.13.0

I tried the query in various versions (3.x, 2.13.0, 2.11) and they all 
work.  My test was to run "qparse" on the query which calls 
QueryFactory.parse

	Andy

>
> ________________________________
> From: Andy Seaborne <an...@apache.org>
> Sent: Tuesday, June 21, 2016 3:19:17 PM
> To: users@jena.apache.org
> Subject: Re: got exception on specific query
>
> Which version are you using?
>
>   > com.hp.hpl.jena.
>
> Jena2, not Jena3.
>
>          Andy
>
> On 21/06/16 16:11, Zen 98052 wrote:
>>
>> What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.
>>
>> The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..
>>
>>
>> ________________________________
>> From: Zen 98052 <z9...@outlook.com>
>> Sent: Tuesday, June 21, 2016 11:00:37 AM
>> To: users@jena.apache.org
>> Subject: got exception on specific query
>>
>> Hi,
>>
>> I got exception when calling QueryFactory.create(query); where query is following:
>>
>>
>> PREFIX v: <http://b/dir/>
>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>
>> SELECT (COUNT(?idObj) AS ?idCount) WHERE
>> {
>>     {
>>       SELECT ?person ?idObj WHERE
>>       {
>>         ?person v:hasUniqueID ?idObj .
>>       }
>>     }
>>     ?person v:hasDataContext ?dc .
>>     ?dc v:metadataID "foobar" .
>> }
>>
>>
>> The exception I got is:
>>
>> com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
>>       at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
>>       at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
>>       at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
>>       at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
>>       at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
>>       at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
>>       at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
>> ...
>>
>>
>> However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.
>>
>> Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11
>>
>> Though it is working now, but I wonder if this is safe option? If not, what is the workaround?
>>
>>
>>
>> Thanks,
>>
>> Z
>>
>
>


Re: got exception on specific query

Posted by Zen 98052 <z9...@outlook.com>.
Yes, still using Jena 2, to be precise, v2.13.0

________________________________
From: Andy Seaborne <an...@apache.org>
Sent: Tuesday, June 21, 2016 3:19:17 PM
To: users@jena.apache.org
Subject: Re: got exception on specific query

Which version are you using?

 > com.hp.hpl.jena.

Jena2, not Jena3.

        Andy

On 21/06/16 16:11, Zen 98052 wrote:
>
> What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.
>
> The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..
>
>
> ________________________________
> From: Zen 98052 <z9...@outlook.com>
> Sent: Tuesday, June 21, 2016 11:00:37 AM
> To: users@jena.apache.org
> Subject: got exception on specific query
>
> Hi,
>
> I got exception when calling QueryFactory.create(query); where query is following:
>
>
> PREFIX v: <http://b/dir/>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>
> SELECT (COUNT(?idObj) AS ?idCount) WHERE
> {
>    {
>      SELECT ?person ?idObj WHERE
>      {
>        ?person v:hasUniqueID ?idObj .
>      }
>    }
>    ?person v:hasDataContext ?dc .
>    ?dc v:metadataID "foobar" .
> }
>
>
> The exception I got is:
>
> com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
>      at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
>      at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
>      at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
>      at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
>      at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
>      at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
>      at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
> ...
>
>
> However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.
>
> Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11
>
> Though it is working now, but I wonder if this is safe option? If not, what is the workaround?
>
>
>
> Thanks,
>
> Z
>


Re: got exception on specific query

Posted by Andy Seaborne <an...@apache.org>.
Which version are you using?

 > com.hp.hpl.jena.

Jena2, not Jena3.

	Andy

On 21/06/16 16:11, Zen 98052 wrote:
>
> What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.
>
> The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..
>
>
> ________________________________
> From: Zen 98052 <z9...@outlook.com>
> Sent: Tuesday, June 21, 2016 11:00:37 AM
> To: users@jena.apache.org
> Subject: got exception on specific query
>
> Hi,
>
> I got exception when calling QueryFactory.create(query); where query is following:
>
>
> PREFIX v: <http://b/dir/>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>
> SELECT (COUNT(?idObj) AS ?idCount) WHERE
> {
>    {
>      SELECT ?person ?idObj WHERE
>      {
>        ?person v:hasUniqueID ?idObj .
>      }
>    }
>    ?person v:hasDataContext ?dc .
>    ?dc v:metadataID "foobar" .
> }
>
>
> The exception I got is:
>
> com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
>      at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
>      at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
>      at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
>      at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
>      at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
>      at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
>      at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
> ...
>
>
> However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.
>
> Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11
>
> Though it is working now, but I wonder if this is safe option? If not, what is the workaround?
>
>
>
> Thanks,
>
> Z
>


Re: got exception on specific query

Posted by Zen 98052 <z9...@outlook.com>.
What puzzling me more, the code currently being deployed actually never passed that second arg, but it doesn't throw exception.

The Jena API version is same, I made some changes at other places, but not on that particular code. This is so weird..


________________________________
From: Zen 98052 <z9...@outlook.com>
Sent: Tuesday, June 21, 2016 11:00:37 AM
To: users@jena.apache.org
Subject: got exception on specific query

Hi,

I got exception when calling QueryFactory.create(query); where query is following:


PREFIX v: <http://b/dir/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT (COUNT(?idObj) AS ?idCount) WHERE
{
  {
    SELECT ?person ?idObj WHERE
    {
      ?person v:hasUniqueID ?idObj .
    }
  }
  ?person v:hasDataContext ?dc .
  ?dc v:metadataID "foobar" .
}


The exception I got is:

com.hp.hpl.jena.query.QueryParseException: com/hp/hpl/jena/sparql/util/PrefixMapping2
    at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:118)
    at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
    at com.hp.hpl.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
    at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:148)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:80)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:53)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:41)
...


However, when I pass the syntax arg, i.e. QueryFactory.create(query, Syntax.syntaxARQ); then it works fine.

Without passing syntax, it'd use Syntax.defaultQuerySyntax, which resolves to Syntax.syntaxSPARQL_11

Though it is working now, but I wonder if this is safe option? If not, what is the workaround?



Thanks,

Z