Apache Jena on Google App Engine

Jena uses Http Client to query remote endpoints. When deploying on Google App Engine, you cannot use HttpClient. Here is a quick workaround that worked fine for me:

private ResultSet execSelect(String sparql, String endpoint) throws Exception{ HttpURLConnection connection = (HttpURLConnection) new URL(endpoint + "?query="+URLEncoder.encode(sparql, "UTF-8")).openConnection(); connection.setRequestProperty("Accept", "application/sparql-results+xml"); InputStream response = connection.getInputStream(); return ResultSetFactory.fromXML(response); }



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s