Describe request with stardog API


For my project i need to use a describe request called from my server (spring with stardog api).
My request is :

  ?x rdf:type myOntology:human .

If i use these request in Stardog web interface (Stardog 5.3.1) i have a result
But the same request from my server doesn't work and i have an error :

ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is Unsupported Accept for query type] with root cause Unsupported Accept for query type
	at com.complexible.stardog.protocols.http.client.BaseHttpClient.checkResponseCode(
	at com.complexible.stardog.protocols.http.client.BaseHttpClient.execute(

How can i allow these kind of request ?
thanks for your answers

Hello and welcome!

Can you show us how you're making the request from the server (Java API, HTTP, etc) and if you're adding an Accept header in any way? The server is expecting to be asked for an RDF format and it doesn't appear to be getting that, whether it's something explicitly set or something being set by whichever client is generating the call.

String request = "DESCRIBE ?x WHERE {\n" + 
				"  ?x rdf:type myOntology:human .\n" + 
String[] resultat = executeRequest(request);

private synchronized String[] executeRequest(String request) throws TupleQueryResultHandlerException, QueryEvaluationException, 
	UnsupportedQueryResultFormatException, IOException, StardogException {
		logger.debug("Request "+request);
		SelectQuery aQuery =;
		TupleQueryResult aResult=null; ByteArrayOutputStream out=null;
		aResult = aQuery.execute();
		out = new ByteArrayOutputStream();
		QueryResultIO.writeTuple(aResult, TupleQueryResultFormat.CSV, out);
		String[] resultats = out.toString().split("\n");
		if (aResult!=null) {aResult.close();}
		return resultats;

	public void createAdminConnection(database db, boolean paramreasoner) {									// Main method to open a connection to a Stardog database
		if (pacsUrl==null) {pacsUrl = Application.pacsUrl ;}
		if (starDogUrl==null) {starDogUrl = Application.starDogUrl ;}		
		logger.debug("Creation of the StarDog connection (Database : "+db.toString()+") at "+starDogUrl);
		ConnectionConfiguration connectionConfig = ConnectionConfiguration									// Configuration of the connection
				.to(db.toString())																			// Select Database (from the enumeration)
				.server(starDogUrl)																			// StarDog URL 
				.credentials(username, password)															// Login and Pasword of Stardog
				.reasoning(paramreasoner);																	// Will it use reasoning (boollean)

		logger.debug("StarDog connection (reasoning : "+ConnectionConfiguration.REASONING_ENABLED.toString()+")"); 

		ConnectionPool connectionPool = createConnectionPool(connectionConfig);								// Create the Stardog connection 
		starDogConnection = connectionPool.obtain();														// Return the Stardog connection as a java Object
		logger.debug("Sucessfully created the StarDog connection (Database : "+db.toString()+")");


The issue here is that DESCRIBE is not a select query, so executing it as a SelectQuery is returning this error. What you want is a GraphQuery, since the end result will be an RDF graph:

final String aQuery = "DESCRIBE ?x WHERE {\n" +
		                      "  ?x rdf:type myOntology:human .\n" +

		try (Connection c ="myDb").server("http://localhost:5820").credentials("admin", "admin").connect();
		     GraphQueryResult r = c.graph(aQuery).execute()) {

Yes it works
Thank you very much

I was able to make many requests, and i used the pragma describe.strategy bidirectional, lie that
But in some cases i receive an error :
org.openrdf.query.QueryEvaluationException: LongHashSet can't handle long element which equal to 0
at com.complexible.stardog.protocols.http.client.BaseHttpClient.checkResponseCode(
at com.complexible.stardog.protocols.http.client.BaseHttpClient.execute(
at com.complexible.stardog.protocols.http.client.HttpClientImpl.graph(
at com.complexible.stardog.protocols.http.client.HttpConnection._graph(
at com.complexible.stardog.api.impl.AbstractConnection.executeGraph(
at com.complexible.stardog.api.impl.GraphQueryImpl.execute(
at com.complexible.stardog.api.impl.GraphQueryImpl.execute(
at repository.RequestBuilder.describeRequest(

But the same request works in StarDog

Do you know what is my error ?

Can you post the entire query that you are running, #pragma included? And where are you seeing the error happening?

A request : #pragma describe.strategy bidirectional

I see then in my java console, these requests are executed by my java server (and result is sent in Json to a HTML/Java script page )