This started as a clone of
http://www.openrdf.org/issues/browse/SES-366, which just might have recurred. I am using Sesame 2.6.6, connected via HTTP to a remote repository. I can use the Sesame workbench to look in my repository for statements and there I find many with non-null context. One particular wrinkle is that I am using BNodes, both in the repository and to limit the search. I don't see why that would affect the result tho. I checked in a debugger and the implementation of the Statement interface is org.openrdf.model.impl.StatementImpl, not ContextStatementImpl.
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryResult;
import org.openrdf.repository.http.HTTPRepository;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.rdbms.mysql.MySqlStore;
/**
* Tests context implementation by searching for statements that have context.
*
* @author clott
*/
public class TestGetStatementsWithContext {
/**
* Arguments control which repository implementation is used. Invoke with:
* <UL>
* <LI>1 argument: the URI of a remote repository
* <LI>4 arguments: the host name, database name, user name and password for
* a MySQL repository
* </UL>
*
* @param args
*/
public static void main(String[] args) {
try {
// Get started
Repository repo = null;
if (args.length == 4) {
System.out.println("Using mysql repository on host " + args[0]);
MySqlStore sqlStore = new MySqlStore(args[1]);
sqlStore.setServerName(args[0]);
sqlStore.setPortNumber(3306);
sqlStore.setUser(args[2]);
sqlStore.setPassword(args[3]);
repo = new SailRepository(sqlStore);
} else if (args.length == 1) {
System.out.println("Using remote repository at " + args[0]);
repo = new HTTPRepository(args[0]);
} else {
System.err.println("Too few arguments");
return;
}
// Init the repo
System.out.println("Initializating and connecting");
repo.initialize();
RepositoryConnection con = repo.getConnection();
// Get statements in context
System.out.println("Retrieving statements in known context");
URI context = new URIImpl(
"
http://www.mydomain.org/foo/bar#baz");
RepositoryResult<Statement> stmts = con.getStatements(null, null,
null, false, context);
// Show the statements. Context is always null.
// Same result if the context arg is omitted above.
while (stmts.hasNext()) {
Statement stmt = stmts.next();
System.out.println("Object type is "
+ stmt.getClass().getName());
System.out.println(stmt.toString());
}
stmts.close();
System.out.println("Closing connection and repository");
con.close();
// Release the lock on the repository
repo.shutDown();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
I cannot figure out how to edit the applies-to version in this bug, it's definitely not 2.0beta, sorry for confusion.
Anyhow I tried one more experiment, namely adjusting the preferred RDF format used by the HTTP client to TRIG, but that did not work either, still no context in the result. I also tried TRIX.
if (repo instanceof HTTPRepository) {
HTTPRepository httpRepo = (HTTPRepository) repo;
httpRepo.setPreferredRDFFormat(RDFFormat.TRIG);
}
not a problem chris, I think only admins can fix those fields, done now.
I can not reproduce this issue at all. Please note that core functionality like this is covered by the conformance tests which are run on every SVN commit. These tests all greenline, which makes me suspicious that something else is going on in your surroundings.
You should not need to set a preferred RDF format at all for this, by the way: the HTTPClient automatically selects only those formats that support contexts for the accept header.
Can you set your server logs to record debug-level info and then see what the incoming request parameters on the server look like? server logging is configured by going to the Sesame application datadir (see
http://www.openrdf.org/doc/sesame2/users/ch05.html) and editing /conf/logback.xml. You may need to restart Sesame for the changes to take effect.
Thanks for trying. Today I cannot reproduce the problem either :( Must be some error between the chair and the keyboard. Sorry to waste your time. Please close this issue. If I find a reliable reproduce-by example I will reopen or post.