That exception doesn't appear to have anything to do with extension functions. 
It indicates a problem between client and server.

Please show at _least_ your actual query execution code, your complete Fuseki 
config, and a complete stacktrace.


ajs6f

> On Dec 26, 2017, at 1:17 PM, Marc Agate <[email protected]> wrote:
> 
> I forgot to mention that according to 
> https://jena.apache.org/documentation/query/java-uri.html
> I tried for testing purpose to set a PREFIX f:
> <java:io.bdrc.ldsearch.query.functions.CustomARQFunctions.>and added
> the following to fuseki config : 
> ja:loadClass "io.bdrc.ldsearch.query.functions.CustomARQFunctions" .
> where CustomARQFunctions is :
> public class CustomARQFunctions {             public static
> NodeValue myFilter(NodeValue value1){                 int i =
> value1.asString().length();         return
> NodeValue.makeInteger(i);     }
> }
> since according to 
> https://jena.apache.org/documentation/query/writing_functions.html
> using the java:URI scheme "dynamically loads the code, which must be on
> the Java classpath. With this scheme, the function URI gives the class
> name. There is automatic registration of a wrapper into the function
> registry. This way, no explicit registration step is needed by the
> application and queries issues with the command line tools can load
> custom functions."
> but no luck: I keep getting the following exception:
> Exception in thread "main" HttpException: 404 at
> org.apache.jena.sparql.engine.http.HttpQuery.execGet(HttpQuery.java:328
> )     at
> org.apache.jena.sparql.engine.http.HttpQuery.exec(HttpQuery.java:288) 
> at
> org.apache.jena.sparql.engine.http.QueryEngineHTTP.execResultSetInner(Q
> ueryEngineHTTP.java:348)      at
> org.apache.jena.sparql.engine.http.QueryEngineHTTP.execSelect(QueryEngi
> neHTTP.java:340)
> I am stuck !
> Marc
> Le mardi 26 décembre 2017 à 18:56 +0100, Marc Agate a écrit :
>> Hi,
>> Adam's gave me the right direction.
>> I managed to load my function class in fuseki config using
>> ja:loadClass
>> but now remains the following issue (the function is not
>> registered)seefuseki logs :
>> [2017-12-26 16:10:13] exec       WARN  URI <http://purl.bdrc.io/funct
>> ions#MyFilterFunction> has no registered function factory
>> How can I register this function now that I have the code available
>> onthe endpoint side ?
>> Thanks for helping
>> Marc.
>> 
>> Le mardi 26 décembre 2017 à 17:43 +0000, Andy Seaborne a écrit :
>>> As well s Adam's point (and all the libraries your function
>>> needs, transitively)
>>> What is in the Fuseki log file?How was the data loaded into Fuseki?
>>>  >> I printed out the >> FunctionRegistry
>>>      And
>>> On 26/12/17 14:51, ajs6f wrote:
>>>> I'm not as familiar with the extension points of ARQ as I
>>>> wouldlike to be, but as I understand what you are doing, you
>>>> areregistering a new function with your _local_ registry, then
>>>> firinga query at a _remote_ endpoint (which has a completely
>>>> independentregistry in a different JVM in a different process,
>>>> potentially ina different _system_).
>>>> The query is getting interpreted and executed by that
>>>> remoteservice, not locally. So you need to register the function
>>>> _there_.
>>>> Take a look at this thread:
>>>> https://lists.apache.org/thread.html/1cda23332af4264883e88697d994
>>>> 605770edcde2f93ddea51240e4b8@%3Cusers.jena.apache.org%3E
>>>> It should get you started as to how to register
>>>> extensionfunctionality in Fuseki.
>>>> 
>>>> Adam Soroka
>>>>> On Dec 26, 2017, at 9:34 AM, Marc Agate <[email protected]>
>>>>> wrote:
>>>>> 
>>>>> Hi !
>>>>> 
>>>>> I successfully implemented sparql queries using custom ARQ
>>>>> functions
>>>>> using the following (custom function code):
>>>>> 
>>>>> ****************
>>>>> public class LevenshteinFilter extends FunctionBase2 {
>>>>> 
>>>>>      public LevenshteinFilter() { super() ; }
>>>>> 
>>>>>      public NodeValue exec(NodeValue value1, NodeValue value2){
>>>>>          LevenshteinDistance LD=new LevenshteinDistance();
>>>>>          int i = LD.apply(value1.asString(),
>>>>> value2.asString());
>>>>>          return NodeValue.makeInteger(i);
>>>>>      }
>>>>> }
>>>>> ***************
>>>>> 
>>>>> it works fine when I query against a Model loaded from a turtle
>>>>> file,
>>>>> like this:
>>>>> 
>>>>> ***************
>>>>> InputStream input =
>>>>> QueryProcessor.class.getClassLoader().getResourceAsStream("full
>>>>> .t
>>>>> tl");
>>>>>              model =
>>>>> ModelFactory.createMemModelMaker().createModel("default");
>>>>>              model.read(input,null,"TURTLE"); // null base URI,
>>>>> since
>>>>> model URIs are absolute
>>>>>              input.close();
>>>>> ***************
>>>>> 
>>>>> with the query being sent like this :
>>>>> 
>>>>> ***************
>>>>> String functionUri = "http://www.example1.org/LevenshteinFuncti
>>>>> on
>>>>> ";
>>>>>          FunctionRegistry.get().put(functionUri ,
>>>>> LevenshteinFilter.class);
>>>>> 
>>>>>          String s = "whatever you want";
>>>>>          String sparql = prefixes+" SELECT DISTINCT ?l WHERE {
>>>>> ?x
>>>>> rdfs:label ?l . " +  "FILTER(fct:LevenshteinFunction(?l, \"" +
>>>>> s
>>>>> + "\")
>>>>> < 4) }";
>>>>>          Query query = QueryFactory.create(sparql);
>>>>>          QueryExecution qexec =
>>>>> QueryExecutionFactory.create(query,
>>>>> model);
>>>>>          ResultSet rs = qexec.execSelect();
>>>>> ***************
>>>>> 
>>>>> However, if i use a working fuseki endpoint for the same
>>>>> dataset
>>>>> (full.ttl) like this :
>>>>> 
>>>>> ***************
>>>>> fusekiUrl="http://localhost:3030/ds/query";;
>>>>> ***************
>>>>> 
>>>>> sending the query like this (using
>>>>> QueryExecutionFactory.sparqlService(fusekiUrl,query) instead of
>>>>> QueryExecutionFactory.create(query,model) ):
>>>>> 
>>>>> ***************
>>>>> String functionUri = "http://www.example1.org/LevenshteinFuncti
>>>>> on
>>>>> ";
>>>>>          FunctionRegistry.get().put(functionUri ,
>>>>> LevenshteinFilter.class);
>>>>> 
>>>>>          String s = "whatever you want";
>>>>>          String sparql = prefixes+" SELECT DISTINCT ?l WHERE {
>>>>> ?x
>>>>> rdfs:label ?l . " + "FILTER(fct:LevenshteinFunction(?l, \"" + s
>>>>> +
>>>>> "\")
>>>>> < 4) }";
>>>>>          Query query = QueryFactory.create(sparql);
>>>>>          QueryExecution qexec =
>>>>> QueryExecutionFactory.sparqlService(fusekiUrl,query);
>>>>>          ResultSet rs = qexec.execSelect();
>>>>> ***************
>>>>> 
>>>>> Then I don't get any results back. In both cases I printed out
>>>>> the
>>>>> FunctionRegistry and they contain exactly the same entries,
>>>>> especially
>>>>> :
>>>>> 
>>>>> key=http://www.example1.org/LevenshteinFunction value:
>>>>> org.apache.jena.sparql.function.FunctionFactoryAuto@5a45133e
>>>>> 
>>>>> Any clue ?
>>>>> 
>>>>> Thanks

Reply via email to