Open rom1504 opened 9 years ago
My guess is this would be like config-default.json from the JavaScript client. Basically, it mentions a default start fragment and prefixes.
Agree that this should be in the package though. @laurensdv, can you verify?
Hmm apparently there's actually a https://github.com/LinkedDataFragments/Client.Java/blob/master/src/main/conf/config-default.json .
I'm not sure what are the parameter of that main actually, it seems the query parameter is actually a file ? What format should be that file ?
I'm trying to make something work, because I'm having other problem if I simply try to add it to my projet through maven (using mvn install:install-file -Dfile=Client.Java/target/ldf-client-jar-with-dependencies.jar -DgroupId=org.linkeddatafragments -DartifactId=ldf-client -Dversion=0.1-SNAPSHOT -Dpackaging=jar
since it's not (yet ?) published in some maven repo) :
I'm getting "Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE" which seems to be coming from httpasyncclient or something..
If I make a file query containing only SELECT distinct ?o WHERE { <http://dbpedia.org/resource/Bill_Clinton> <http://dbpedia.org/ontology/child> ?o }
and then try to run java -jar target/ldf-client-jar-with-dependencies.jar query
, I get :
java.lang.IllegalArgumentException: URI to read from is null
at org.apache.jena.riot.RDFDataMgr.parse(RDFDataMgr.java:644)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:211)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:184)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:122)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:113)
at org.apache.jena.riot.adapters.RDFReaderRIOT.read(RDFReaderRIOT.java:77)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:247)
at org.linkeddatafragments.client.LinkedDataFragmentsClient.getBaseFragment(LinkedDataFragmentsClient.java:58)
at org.linkeddatafragments.model.LinkedDataFragmentGraph.graphBaseFind(LinkedDataFragmentGraph.java:71)
at com.hp.hpl.jena.graph.impl.GraphBase.find(GraphBase.java:268)
at com.hp.hpl.jena.graph.impl.GraphBase.graphBaseFind(GraphBase.java:290)
at com.hp.hpl.jena.graph.impl.GraphBase.find(GraphBase.java:287)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterTriplePattern$TripleMapper.<init>(QueryIterTriplePattern.java:80)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterTriplePattern.nextStage(QueryIterTriplePattern.java:53)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.makeNextStage(QueryIterRepeatApply.java:115)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:67)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterBlockTriples.hasNextBinding(QueryIterBlockTriples.java:64)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterConvert.hasNextBinding(QueryIterConvert.java:59)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterDistinctReduced.hasNextBinding(QueryIterDistinctReduced.java:54)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:40)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:40)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.ResultSetStream.hasNext(ResultSetStream.java:75)
at org.linkeddatafragments.client.QueryResultsWriter.writeResults(QueryResultsWriter.java:52)
at org.linkeddatafragments.client.QueryResultsWriter.main(QueryResultsWriter.java:114)
I was just told by @mielvds that he has a local version that is more advanced than the tree here. It addresses most of the issues you mention, so I'll leave it to him to follow up.
I managed to make the main of QueryResultsWriter work by using the config-default.json
in the repo, but I think it should use that one automatically when no config file is given (using maven resources maybe ?).
Using the project as a dependency from my project still gives me these errors :
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/people/beaumont/.m2/repository/org/slf4j/slf4j-log4j12/1.7.6/slf4j-log4j12-1.7.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/people/beaumont/.m2/repository/org/linkeddatafragments/ldf-client/0.1-SNAPSHOT/ldf-client-0.1-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.impl.nio.codecs.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)
at org.apache.http.impl.nio.codecs.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
at org.apache.http.impl.nio.codecs.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<init>(ManagedNHttpClientConnectionFactory.java:75)
at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<init>(ManagedNHttpClientConnectionFactory.java:83)
at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<clinit>(ManagedNHttpClientConnectionFactory.java:64)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingNHttpClientConnectionManager.java:519)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.<init>(PoolingNHttpClientConnectionManager.java:161)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.<init>(PoolingNHttpClientConnectionManager.java:145)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.<init>(PoolingNHttpClientConnectionManager.java:117)
at org.apache.http.impl.nio.client.HttpAsyncClientBuilder.build(HttpAsyncClientBuilder.java:605)
at org.apache.http.impl.nio.client.HttpAsyncClients.createDefault(HttpAsyncClients.java:62)
at org.linkeddatafragments.client.LinkedDataFragmentsClient.<init>(LinkedDataFragmentsClient.java:37)
at org.linkeddatafragments.model.LinkedDataFragmentGraph.<init>(LinkedDataFragmentGraph.java:38)
at client.JenaDBpediaClient.main(JenaDBpediaClient.java:15)
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:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
I'm just trying to make some basic thing work using the code from the README and some jena example :
public static void main(String[] args)
{
LinkedDataFragmentGraph ldfg = new LinkedDataFragmentGraph("http://data.linkeddatafragments.org/dbpedia");
Model model = ModelFactory.createModelForGraph(ldfg);
String queryString = "SELECT distinct ?o WHERE { <http://dbpedia.org/resource/Bill_Clinton> <http://dbpedia.org/ontology/child> ?o }" ;
Query query = QueryFactory.create(queryString) ;
try (QueryExecution qexec = QueryExecutionFactory.create(query, model)) {
ResultSet results = qexec.execSelect() ;
for ( ; results.hasNext() ; )
{
QuerySolution soln = results.nextSolution() ;
//RDFNode x = soln.get("varName") ; // Get a result variable by name.
Resource r = soln.getResource("VarR") ; // Get a result variable - must be a resource
//Literal l = soln.getLiteral("VarL") ; // Get a result variable - must be a literal
System.out.println(r);
}
}
}
The error is actually on the first line (the new LinkedDataFragmentGraph).
I think it would be nice to have a (working) simple such example on the README.
I managed to make something work by removing the up to date jena from my project and using the one LinkedDataFragments has and by changing the code a bit for that older jena version :
public static void main(String[] args)
{
LinkedDataFragmentGraph ldfg = new LinkedDataFragmentGraph("http://data.linkeddatafragments.org/dbpedia");
Model model = ModelFactory.createModelForGraph(ldfg);
String queryString = "SELECT distinct ?o WHERE { <http://dbpedia.org/resource/Bill_Clinton> <http://dbpedia.org/ontology/child> ?o }" ;
Query query = QueryFactory.create(queryString) ;
QueryExecution qexec = QueryExecutionFactory.create(query, model);
ResultSet results = qexec.execSelect() ;
for ( ; results.hasNext() ; )
{
QuerySolution soln = results.next() ;
System.out.println(soln);
}
}
I'm not sure if this is a good way to use it though, it's slower than QueryResultsWriter and the loop doesn't seem to end.
Ok it just takes some times to initialize ldfg and model, but the querying is fast. Apparently a System.exit(0); is needed at the end of the main for it to exit, so the loop is ok.
So in short :
But anyway, it works ! Thanks for this lib, LinkedDataFragments really seems like a good idea !
@mielvds @laurensdv Any action still needed for this one? If not, please close.
There are indeed some issues. I guess https://github.com/LinkedDataFragments/Client.Java/blob/master/src/main/java/org/linkeddatafragments/client/QueryResultsWriter.java#L80 will have to change, amongst others. I'll keep this open for now
QueryResultsWriter main want a config-default.json file and it's not in the repo.
What should be in that config file ?