1

I'm trying to update my fuseki data end-point from Jena. I am using Jena DatasetAccessor Class, but i cannot compile my code. This is the sample code i'm using :

public class Tutorial01 {

public static void main(String args[]) {
    // Create a simple model
    Model model = ModelFactory.createDefaultModel();
    Resource johnSmith = model.createResource("http://somewhere/JohnSmith");
    johnSmith.addProperty(VCARD.FN, "John Smith");


    //Create an HTTP Data accessor
    DatasetAccessor accessor=DatasetAccessorFactory.createHTTP("http://localhost:3030/FirstONe/data");
    //Store the model on the server
    accessor.putModel(model);
}

-On the last code line i receive the following error :

Exception in thread "main" java.lang.NoSuchFieldError: DEF_CONTENT_CHARSET
at org.apache.http.impl.client.DefaultHttpClient.setDefaultHttpParams(DefaultHttpClient.java:181)
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:159)
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:466)
at org.apache.http.impl.client.AbstractHttpClient.determineParams(AbstractHttpClient.java:1005)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:824)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.apache.jena.riot.web.HttpOp.exec(HttpOp.java:1097)
at org.apache.jena.riot.web.HttpOp.execHttpPut(HttpOp.java:979)
at org.apache.jena.web.DatasetGraphAccessorHTTP.doPut(DatasetGraphAccessorHTTP.java:175)
at org.apache.jena.web.DatasetGraphAccessorHTTP.httpPut(DatasetGraphAccessorHTTP.java:165)
at org.apache.jena.web.DatasetAdapter.putModel(DatasetAdapter.java:63)
at Main.Tutorial01.main(Tutorial01.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

I've read online that it should be a problem with HttpCore and HttpClient incompatibles versions (StackOverflow question) or HttpCore multiple versions in class path (jena mailing list) or versions that are incompatible with Jena.

I've tried with 4.2.6, 4.2.5, 4.4 and none of them has worked.

Someone knows which are the right version to use or has solved a similar problem ?

Thanks everyone

Community
  • 1
  • 1
Luca Ambrosini
  • 159
  • 1
  • 9
  • 1
    Eiother use the jars provided in the Jena download (the binary zip comes with the right Apache Common Http jars) or, better, use maven (gradle, ant/ivy,...) to manage the dependencies and they will pull in the right version. The published POM name the right version if you want to browse those. – AndyS Mar 05 '16 at 16:19

0 Answers0