Hitachi Vantara Pentaho Community Forums
Results 1 to 9 of 9

Thread: Invoking Java from Kettle

  1. #1
    Join Date
    Oct 2007
    Posts
    16

    Default Invoking Java from Kettle

    Hi,

    I have written some Java code to convert SGML files to XML and I need to then use Spoon to load the XML files in a RDBMS.

    I can of course first convert the files outside of Kettle and then use the newly created files to load the data, but I was wandering if there is a way to call Java code from Kettle, so that I can have a packaged transformation. What I want to do is run code like:

    conv = new SGMLtoXML(....);
    conv.convert();

    Is this possible?

    Thanks

    Magi

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    via javascript you can get at java, look in the FAQ

    Regards,
    Sven

  3. #3
    Join Date
    Oct 2007
    Posts
    16

    Default

    Thank you. I couldn't find a FAQ that addresses Java, but I found a techtip http://wiki.pentaho.org/display/COM/...cess+in+Kettle that says that putting java in the begining of a JavaScript object and placing the jars in Kettle's classpath should do the trick.

    Anyway, I did that (put my jars in C:\Program Files\Pentaho Data Integration\lib) but Kettle doesn't see them.

    I would appreciate if you could help me with this. Where to copy, jars, what variables to set etc...

    Thanks
    Magi

  4. #4
    Join Date
    May 2006
    Posts
    4,882

    Default

    put them in libext.

    Regards,
    Sven

  5. #5
    Join Date
    Oct 2007
    Posts
    16

    Default

    Thanks

    I put it there but Kettle doesn't still see it. I still get :


    General error executing script:
    Reference Error: "tst" is not defined.

    My jar file contains a package tst, that contains a class Operation with two methods add and sub and in my Javascript Object I have

    java

    o = new tst.Operation(1,1);

    var res = o.add();

    What am I doing wrong now?
    Thanks
    Magi

  6. #6
    Join Date
    May 2006
    Posts
    4,882

    Default

    o = new Packages.tst.Operation(1,1);

  7. #7
    Join Date
    Oct 2007
    Posts
    16

    Default

    Thank you. Works well.

    Magi

  8. #8
    Join Date
    Sep 2007
    Posts
    2

    Smile Hi all

    i have similar problem, i need call a class of Java from one transformation kettle with script.


    I try this way.

    //var clas = Package.com.solbi.tsol.proceso.Create_Ejecuciones.getIdejecucion();

    //var clas = new Packages.com.solbi.tsol.proceso.Create_Ejecuciones.getIdejecucion();

    //var clas = new Packages.com.solbi.tsol.proceso.Create_Ejecuciones;
    //clas.getIdejecucion();


    but nothing, None of that run.

    Error Said :
    "General error executing script:
    TypeError: [JavaPackage com.solbi.tsol.proceso.Create_Ejecuciones] is not a function, it is org.mozilla.javascript.NativeJavaPackage. (script#11)"

    I create the class Create_Ejecuciones.java and into the method getIdejecucion()

    and after and copy the class generated for myeclipse and copy into of

    D:\ruta....\Pentaho\Kettle-3_1.0.0-RC2\classes\com\solbi\tsol\proceso\Create_Ejecuciones.class

    but that don't run, that don't Works

    what can i do ?,

    somebody who can help me.


    post: sorry for my English., i speak spanish.



  9. #9
    Join Date
    Jun 2009
    Posts
    26

    Default

    Hi,


    var clas = Packages.com.solbi.tsol.proceso.Create_Ejecuciones();
    clas.getIdejecucion();


    put the jar in libext\ path and try this code...


    Regards,
    kaleesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.