We're having persistent (but not necessarily consistent) ClassCastExceptions in our Java JBoss application when trying to write query results to a byte stream.
The trace is :
Unhandled exception from service: java.lang.ClassCastException: Cannot cast com.stardog.stark.query.io.json.SPARQLJSONBooleanResultWriter to com.stardog.stark.query.io.SelectQueryResultWriter at java.lang.Class.cast(Class.java:3369) at java.util.Optional.map(Optional.java:215) at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:120) .... (our code line here)
The calls are generally of the form :
ByteArrayOutputStream os = new ByteArrayOutputStream(); QueryResultFormat format = QueryResultFormats.forMime("application/sparql-results+json"); SelectQuery squery = connection.select(...some query ...); SelectQueryResult result = squery.execute(); QueryResultWriters.write(result, os, format.get()); String outResult = new String(os.toByteArray(), Charsets.UTF_8);
outResult is then returned in the HTTP Response with the correct MIME type encoding back to the calling RESTful client.
Similar code is used in a few methods and once the error occurs then all executions of this type of code throws the exception.
The queries are fairly simple "SELECT" queries that return mostly text values that have worked for the last year or so.
The exceptions have only started since we've upgraded the Stardog server to 7.0.2.
Sometimes restarting the JBoss server (occasionally a few times might be required) will "clear" the error, but it often soon reappears.
Restarting the Stardog server has no effect.
There are no server errors logged to stardog.log.
We know that queries are working - other methods that run queries but don't use QueryResultWriters (ie build a bespoke result using .hasNext() ) work as expected.
Any thoughts on resolving this would be very much appreciated!