View Full Version : Javascript Library

05-24-2006, 06:04 AM
I hope that I'm posting this in the correct forum.

I was toying with the JavascriptRule and noticed that the component-definition allows for the specification of a "library". The documentation in Pentaho_Creating_Solutions states that the library file must exist in the solution. I placed my "xxyy.js" script in the solution in a directory called "js-library" and added the following tag to the component-definition:


When I try to run my simple script I get the following error:

Error: JSRULE.ERROR_0004 - Javascript library not found - js-library/xxyy.js (org.pentaho.plugin.javascript.JavascriptRule)

I then moved that "xxyy.js" file to the root of the solution and modified the library tag to:


I received a similar error.

Any ideas on what my problem is?



05-24-2006, 07:01 AM
Hi Steve,

I tried your exact scenario and it worked for me.

I create a JS file in


and referenced it in my action sequence as


What version of Pentaho are you running?


Post edited by: jdixon, at: 05/24/2006 11:08

05-24-2006, 07:31 AM
i'm using

i was just able to get it working. i think the terminology messed me up. when the documentation stated that the file must exist in the solution, i though that meant:


it actually means:


now i got it...thanks for the help.


07-05-2006, 07:48 AM
After upgrading to 1.1.7, actions that used my Javascript libraries started to fail.

I don't know if it is noted anywhere else besides the code, but as of 1.1.7, the <library> tag of the Javascript component is no longer available. Javascript libraries must be specified as <resources> on the action.

The code seems to add any resources that are of the "text/javascript" mime type as libraries to all Javascript components:

while (iter.hasNext()) {
String name = iter.next().toString();
IActionResource libraryResource = getResource(name);
if ( "text/javascript".equalsIgnoreCase( libraryResource.getMimeType() ) ) { //$NON-NLS-1$
if (!PentahoSystem.getSolutionRepository(getSession()).resourceExists(libraryResource.getAddress())) {
error(Messages.getErrorString("JSRULE.ERROR_0004_LIBRARY_NOT_FOUND", name)); //$NON-NLS-1$
return false;
if (PentahoSystem.getSolutionRepository(getSession()).resourceSize(libraryResource.getAddress()) > Integer.MAX_VALUE) {
error(Messages.getErrorString("JSRULE.ERROR_0005_LIBRARY_TOO_LARGE", name, Integer.toBinaryString(Integer.MAX_VALUE))); //$NON-NLS-1$
return false;

Anyway, after some adjustments to my actions, I've got everything working properly now.


07-05-2006, 08:16 AM

Sorry about that, we added an <action-resources> node to the <action-definition> so it would work like the inputs and so resources could take advantage of the name mapping.

In order to help stay backward compatable if there is no action-resources node, we assume all resources. Any way, if you only want specific javascript files available to your action-definition you can add an action-resources node.