Page MenuHomePhabricator

SMW + 4store: SMWSparqlDatabaseError / Malformed query
Closed, ResolvedPublic

Description

Author: dclark

Description:
See also these mailing list threads:

Having a problem getting SMW to work with 4store based on
documentation at
http://semantic-mediawiki.org/wiki/Help:Using_SPARQL_and_RDF_stores

The error message I'm getting in full is below. I've searched for a
solution, and found several other people with the problem, but no one
so far with an answer.

I'm new to all of this so unable to parse manually, but based on the
error message it looks like SMW is sending a malformed query "DELETE {
wiki:Main_Page ?p ?o } WHERE { wiki:Main_Page ?p ?o }" to 4store,
which is rejecting it.

If that isn't actually malformed, then perhaps 4store isn't allowing
DELETE statements, but I (scarily) can't find anything on 4store's web
site that talks about any kind of access / privilege control
whatsoever.

I'm guessing it must be standard practice to just firewall the
external (e.g. eth0) 4store port, and not allow any non-admin users on
the MediaWiki / 4store server?

My LocalSettings.php for 4store (I've also tried with
smwgSparqlDataEndpoint set to '')
$smwgDefaultStore = 'SMWSparqlStore';
$smwgSparqlDatabase = 'SMWSparqlDatabase4Store'; #
using 4Store as connector
$smwgSparqlQueryEndpoint = 'http://localhost:9000/sparql/'; #
location of query service
$smwgSparqlUpdateEndpoint = 'http://localhost:9000/update/'; #
location of update service
$smwgSparqlDataEndpoint = 'http://localhost:9000/data/'; #
location of SPARQL over HTTP service

optional value; leave as is in case of problems
#$smwgSparqlDefaultGraph = 'http://example.org/mydefaultgraphname';

optional name of default graph

Ubuntu 12.10 (i686)
MediaWiki 1.19.2-2
4store 1.1.4-2
Semantic Bundle (Version 1.8alpha)
... lots of other extensions enabled ...
Semantic MediaWiki (Version 1.8.0.1)

root@mritter:/var/lib/mediawiki/extensions/SemanticMediaWiki/maintenance#
php SMW_refreshData.php -v

Refreshing all semantic data in the database!

Some versions of PHP suffer from memory leaks in long-running scripts.
If your machine gets very slow after many pages (typically more than

  1. were refreshed, please abort with CTRL-C and resume this script at the last processed page id using the parameter -s (use -v to display page ids during refresh). Continue this until all pages were refreshed. ---

Processing all IDs from 1 to last ID ...
(0) Processing ID 1 ...
Unexpected non-MediaWiki exception encountered, of type "SMWSparqlDatabaseError"
exception 'SMWSparqlDatabaseError' with message 'A SPARQL query error
has occurred
Query: PREFIX wiki:
http://mritter.dclark.us/wiki/index.php/Special:URIResolver/
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX swivt: http://semantic-mediawiki.org/swivt/1.0#
PREFIX property:
http://mritter.dclark.us/wiki/index.php/Special:URIResolver/Property-3A
PREFIX xsd: http://www.w3.org/2001/XMLSchema#
DELETE { wiki:Main_Page ?p ?o } WHERE { wiki:Main_Page ?p ?o }
Error: Malformed query
Endpoint: http://localhost:9000/update/
HTTP response code: 400
' in /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase.php:590
Stack trace:
#0 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase.php(500):
SMWSparqlDatabase->throwSparqlErrors('http://localhos...', 'PREFIX
wiki: <h...')
#1 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase.php(351):
SMWSparqlDatabase->doUpdate('PREFIX wiki: <h...')
#2 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php(357):
SMWSparqlDatabase->delete('wiki:Main_Page ...', 'wiki:Main_Page ...',
Array)
#3 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php(151):
SMWSparqlStore->deleteSparqlData(Object(SMWExpNsResource))
#4 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php(234):
SMWSparqlStore->doDataUpdate(Object(SMWSemanticData))
#5 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/SMW_ParseData.php(374):
SMWStore->updateData(Object(SMWSemanticData))
#6 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/jobs/SMW_UpdateJob.php(64):
SMWParseData::storeData(Object(ParserOutput), Object(Title), false)
#7 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/storage/SQLStore/SMW_SQLStore3_SetupHandlers.php(445):
SMWUpdateJob->run()
#8 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/storage/SQLStore/SMW_SQLStore3.php(404):
SMWSQLStore3SetupHandlers->refreshData(1, 1, false, false)
#9 /var/lib/mediawiki/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php(446):
SMWSQLStore3->refreshData(1, 1, false, false)
#10 /var/lib/mediawiki/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php(147):
SMWSparqlStore->refreshData(1, 1, false, false)
#11 {main}

~~~~

Another user writes:

4Store and SMW 1.8 (Error: Malformed query)

Hi, I am trying to configure 4Store's triple-store and SPARQL endpoint (
http://4store.org/) with SMW 1.8

I have followed the configuration from
http://semantic-mediawiki.org/wiki/Help:Using_SPARQL_and_RDF_stores#4Store

$smwgDefaultStore = 'SMWSparqlStore';
$smwgSparqlDatabase = 'SMWSparqlDatabase4Store';
$smwgSparqlQueryEndpoint = 'http://localhost:8080/sparql/';
$smwgSparqlUpdateEndpoint = 'http://localhost:8080/update/';
$smwgSparqlDataEndpoint = '';
$smwgSparqlDefaultGraph = '';
enableSemantics('mywiki');

I have tried a few tweaks but I keep getting the "Error: Malformed query"

with the following error-trail:

Unexpected non-MediaWiki exception encountered, of type
"SMWSparqlDatabaseError"
exception 'SMWSparqlDatabaseError' with message 'A SPARQL query error has
occurred
Query: PREFIX wiki: http://mywiki/wiki/index.php/Special:URIResolver/
PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX owl: http://www.w3.org/2002/07/owl#
PREFIX swivt: http://semantic-mediawiki.org/swivt/1.0#
PREFIX property: <
http://mywiki/wiki/index.php/Special:URIResolver/Property-3A>
PREFIX xsd: http://www.w3.org/2001/XMLSchema#
DELETE { property:Last_editor_is ?p ?o } WHERE { property:Last_editor_is ?p
?o }
Error: Malformed query
Endpoint: http://localhost:8080/update/
HTTP response code: 400
' in
/Users/peterk/Projects/MAMP/wiki/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase.php:590
Stack trace:
#0
/Users/peterk/Projects/MAMP/wiki/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase.php(500):
SMWSparqlDatabase->throwSparqlErrors('http://localhos...', 'PREFIX wiki:
<h...')
#1
/Users/peterk/Projects/MAMP/wiki/extensions/SemanticMediaWiki/includes/sparql/SMW_SparqlDatabase.php(351):
SMWSparqlDatabase->doUpdate('PREFIX wiki: <h...')
#2
/Users/peterk/Projects/MAMP/wiki/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php(357):
SMWSparqlDatabase->delete('property:Last_e...', 'property:Last_e...', Array)
#3
/Users/peterk/Projects/MAMP/wiki/extensions/SemanticMediaWiki/includes/storage/SMW_SparqlStore.php(105):
SMWSparqlStore->deleteSparqlData(Object(SMWExpNsResource))
#4
/Users/peterk/Projects/MAMP/wiki/extensions/SemanticMediaWiki/includes/jobs/SMW_UpdateJob.php(45):
SMWSparqlStore->deleteSubject(Object(Title))
#5 /Users/peterk/Projects/MAMP/wiki/includes/Wiki.php(435):
SMWUpdateJob->run()

...

I managed to configure 4Store with SMW 1.7.1 in the past.

Is there a known bug or change with configuring this triple-store in V1.8?


Version: REL1_18-branch
Severity: normal

Details

Reference
bz43708

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:25 AM
bzimport set Reference to bz43708.
bzimport added a subscriber: Unknown Object (MLST).

dclark wrote:

Note: This is a regression; it worked with SMW 1.7.1 but not 1.8.

(Making this note per Jeroen De Dauw's 2013-01-10 email "[Semediawiki-user] Fixes for SMW 1.8.1")

katkov.juriy wrote:

I have the same bug with SMW 1.8 and 4store 1.1.4-1

renaud.richardet wrote:

Same here on SMW 1.8 and SMW 1.9 trunk

Change 70047 had a related patch set uploaded by Nemo bis:
Fixes RDF export of subobjects

https://gerrit.wikimedia.org/r/70047