how can I get java bindings in basex working?
Tuesday, 13 April 2010 · 2 messages · last reply 15 Apr 2010
SS
Sandra Maria Silcot13 Apr 2010 12:35 #
Fellow basex users,
First, I can report that the recent optimisation enhancements have solved the performance issue I had reported -- thanks to the basex team. Basex most definitely rocks.
Second, I am trying to implement a java binding as described here:
http://www.inf.uni-konstanz.de/dbis/basex/xquery
Thanks to the recent extra instruction added by the kindly basex developers, I have been able to use maven (2.2.1) on a ubuntu 64bit server to successfully compile basex from source. Excellent.
But I am now wanting to do this in a basex xquery:
declare namespace sim = "java:smstest.b4asims";
let $sim := sim:b4asims(xs:string("smith"), xs:string("smyth"))where this is a little jar I built around the simmetrics similarity library, like this:
jar -cvf smstest.jar smstest/b4asims.class
This successfully runs from the command line, under the same user the basex server runs under, like so (with the jar in my $CLASSPATH):
BaseX 6.0.8 [Server]
Server was started.
fas@devfas: ~ $ java smstest.b4asims smith smythe
..str1=smith first=m
Soundex score 0.9222222:smith:smythe
Levenshtein score 0.6666666:smith:smythe
JaroWinkler score 0.8577778:smith:smythe
- total [smythe]=2.4466667
== score=2.4466667 bestScore=2.4466667 bestMatch=[smythe]
#### bestScore=2.4466667 bestMatch=[smythe]
I have tried every possible variation of the namespace definition and invoking the function in basex but it always says;
[XPST0017] Unknown function "sim:b4asims(...)"
In the pom.xml for basex I have added this:
<groupId>smstest.b4asims</groupId>
<artifactId>b4asims</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>/media/disk2/fasrepo/common-bin/java/smstest.jar</systemPath>
</dependency>and it compiles successfully, and I can then do a mvn 'package', and deploy the jar to my basex home dir, and run it but I simply cannot get the java bindings to work. I also tried alot of variations here, but to no avail.
Clearly there is something really basic I am missing? I have tried the examples given on the basex documentation (the Math and file writer egs) and get exactly the same results -- Unknown function. All of my other java stuff on this box seems to work fine.
I'm guessing that there is something in maven or eclipse which supplies the magic which I'm missing. I'm just using maven on the server, not eclipse.
Any suggestions for a non-java developer would be most gratefully received.
Best wishes to all,
Sandra.
CG
Christian Grün15 Apr 2010 16:41 #
Sandra,
thanks for your comments. Just some quick answers back:
– I'm not sure if you were able to run the examples from our homepage (Math/file writer)?
– have you checked if the b4asims class is included in the resulting jar file (by simply opening it as zip file), and if it has the correct path?
Hope this helps,
Christian
Quoted text · Sandra Maria Silcot · 74 lines
On Tue, Apr 13, 2010 at 12:35 PM, Sandra Maria Silcot <ssilcot at unimelb.edu.au> wrote: > Fellow basex users, > > First, I can report that the recent optimisation enhancements have solved > the performance issue I had reported -- thanks to the basex team. Basex > most definitely rocks. > > Second, I am trying to implement a java binding as described here: > > http://www.inf.uni-konstanz.de/dbis/basex/xquery > > Thanks to the recent extra instruction added by the kindly basex > developers, I have been able to use maven (2.2.1) on a ubuntu 64bit server > to successfully compile basex from source. Excellent. > > But I am now wanting to do this in a basex xquery: > > declare namespace sim = "java:smstest.b4asims"; > let $sim := sim:b4asims(xs:string("smith"), xs:string("smyth")) > > where this is a little jar I built around the simmetrics similarity > library, like this: > > jar -cvf smstest.jar smstest/b4asims.class > > This successfully runs from the command line, under the same user the > basex server runs under, like so (with the jar in my $CLASSPATH): > > BaseX 6.0.8 [Server] > Server was started. > fas@devfas: ~ $ java smstest.b4asims smith smythe > ..str1=smith first=m > Soundex score 0.9222222:smith:smythe > Levenshtein score 0.6666666:smith:smythe > JaroWinkler score 0.8577778:smith:smythe > - total [smythe]=2.4466667 > == score=2.4466667 bestScore=2.4466667 bestMatch=[smythe] > #### bestScore=2.4466667 bestMatch=[smythe] > > I have tried every possible variation of the namespace definition and > invoking the function in basex but it always says; > > [XPST0017] Unknown function "sim:b4asims(...)" > > In the pom.xml for basex I have added this: > > <groupId>smstest.b4asims</groupId> > <artifactId>b4asims</artifactId> > <scope>system</scope> > <version>1.0</version> > <systemPath>/media/disk2/fasrepo/common-bin/java/smstest.jar</systemPath> > </dependency> > > and it compiles successfully, and I can then do a mvn 'package', and > deploy the jar to my basex home dir, and run it but I simply cannot get > the java bindings to work. I also tried alot of variations here, but to no > avail. > > Clearly there is something really basic I am missing? I have tried the > examples given on the basex documentation (the Math and file writer egs) > and get exactly the same results -- Unknown function. All of my other java > stuff on this box seems to work fine. > > I'm guessing that there is something in maven or eclipse which supplies > the magic which I'm missing. I'm just using maven on the server, not > eclipse. > > Any suggestions for a non-java developer would be most gratefully > received. > > Best wishes to all, > > Sandra.
___________________________
Christian Gruen
Universitaet Konstanz
Department of Computer & Information Science
D-78457 Konstanz, Germany
Tel: +49 (0)7531/88-4449, Fax: +49 (0)7531/88-3577
http://www.inf.uni-konstanz.de/~gruen
Written for BaseX 6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery