Re: [basex-talk] Java Modules - Constructor
Hi Ilko,
The repo folder was completely empty. So you want to install it in the repository, using repo install?
My test was installing via copying the jar to basex/lib/ where it works (for me). If I use repo install I get the same problem as you. This may be a bug/feature. It is possible that using the full EXPath Packaging [1] xar would work although I have not tried it. This would involve adding an XQuery file with expath-pkg.xml and basex.xml files to create a xar wrapping the jar, structured as here [2] The issue [3] may be relevant. Regards /Andy hello-test.jar <https://drive.google.com/file/d/0B_HWsgek7hAeTjFnSFg3cGVpMXc/view?usp=drive_web> [1] http://docs.basex.org/wiki/Repository#Java_2 [2] https://github.com/expkg-zone58/metadata-extract/tree/master/src/main [3] https://github.com/BaseXdb/basex/issues/1413 On 8 May 2017 at 11:44, kovacic <kovacic@dke.uni-linz.ac.at> wrote:
Hi Andy,
I have removed all other existing modules before installing this module. The repo folder was completely empty.
Regards Ilko
Am 05.05.2017 um 19:29 schrieb Andy Bunce:
Hi IIko
Your code and:
declare namespace t='org.basex.modules.Hello'; let $obj := t:new('works for me') return t:hello($obj)
Returns:
Hello works for me
Could be be that you have multiple versions of the jar on the path?
Regards /Andy
On 5 May 2017 at 11:20, kovacic <kovacic@dke.uni-linz.ac.at> wrote:
Hi all,
I am running BaseX 8.6.3 currently and struggling with the inclusion of modules written in Java. I have extended the Hello World example:
package org.basex.modules;
public class Hello {
private String str = "BaseX";
public Hello() {}
public Hello(String str) { this.str = str; }
public String hello(final String world) { return "Hello " + world; }
public String hello() { return "Hello " + str; } }
I can pack it into a jar-file and install it successfully. My jar-file is structured as following:
hello.jar - META-INF - MANIFEST.MF - org - basex - modules - Hello.class
Here is the content of my manifest.mf:
Manifest-Version: 1.0 Main-Class: org.basex.modules.Hello
The methods of the Hello-class can be called without any problems when the module is imported:
import module namespace t='org.basex.modules.Hello';
t:hello('text')
However, when I try to explicitly create the object by calling the constructor (new) with arguments it fails:
declare namespace t='org.basex.modules.Hello';
let $obj := t:new('test')
return ''
When I try to call the constructor I receive the error [XPST0017] Unknown function: Q{org.basex.modules.Hello}new.
Since I am able to execute the FileWriter example ( http://docs.basex.org/wiki/Java_Bindings#Namespace_Declarations) which calls a constructor with an argument I would like to know if this behavior is a bug or if I am missing an important point.
Regards, Ilko
-- *Ilko Kovacic* Wissenschaftlicher Mitarbeiter Institut für Wirtschaftsinformatik - Data & Knowledge Engineering
*JOHANNES KEPLER UNIVERSITÄT LINZ* Altenberger Straße 69 Science Park III, S3 111 4040 Linz, Österreich T +43 732 2468 4286 <+43%20732%2024684286> ilko.kovacic@jku.at www.dke.jku.at
participants (1)
-
Andy Bunce