Hitachi Vantara Pentaho Community Forums
Results 1 to 3 of 3

Thread: Javascript scripts and Classpaths

  1. #1

    Default Javascript scripts and Classpaths

    Hello,


    I'm trying to write a simple Javascript transform that SHA1 hashes a field. I am trying to use a small class that performs the hashing, yet I can't seem to load it up in the script itself. I've placed the .jar into the libext and modified the spoon.bat file to include the .jar in the classpath.



    Anytime I try to access the custom class, I receive a "Reference Error: "org" is not defined". In this case, "org" is the first element of the package name.



    My script contains:



    var hashed = org.apache.commons.codec.digest.DigestUtils.shaHex(ssn.getString());



    Any ideas on how to get arbitrary .jars into the classpath so that I can use them in the Javascript scripts? Thanks!

  2. #2

    Default RE: Javascript scripts and Classpaths

    To answer my own question, here's how you can refer to classes in arbitrary packages:


    var hashed = Packages.org.apache.commons.codec.digest.DigestUtils.shaHex(ssn.getString());



    Notice the use of Packages prefix to the package name.

  3. #3
    Join Date
    Nov 1999
    Posts
    9,729

    Default RE: Javascript scripts and Classpaths



    I really like it when you guys start to reply to your own questions ;-)



    Thanks for the tip. I am not a Rhino expert myself.



    There are some nice tips to be found on scripting on the Rhino website as well: http://www.mozilla.org/rhino/



    Cheers,

    Matt

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.