script can't load Java class?
Hi,
First of all, thank you very much for the great work you do for BIRT.
I am trying to invoke a Java method from a script in beforeOpen() in one
of the Data Sources. I have tried many things, but I can't get it to work.
Here's my beforeOpen() script.
importPackage( Packages.java.io,
Packages.com.mycompany.a.b.ScriptTest );
try {
var myScriptTest = new ScriptTest();
} catch (exception) {
printWriter.println(exception);
}
Here's my ScriptTest class. I've put the class file in test.jar. web.xml
has no configuration for BIRT_VIEWER_SCRIPTLIB_DIR; it leaves it as
default.
package com.mycompany.a.b;
public class ScriptTest {
public ScriptTest() {
}
}
I am deploying BIRT in a birtScriptTest.war file to an application server
(Tomcat).
I have put test.jar in "scriptlib" folder, which is at the top of
birtScriptTest.war.
When I run the script, I get this error message.
ReferenceError: "ScriptTest" is not defined.
I then tried specifying the full class name.
var myScriptTest = new Packages.com.mycompany.a.b.ScriptTest();
Now I get this error.
TypeError: [JavaPackage com.mycompany.a.b.ScriptTest] is not a
function, it is org.mozilla.javascript.NativeJavaPackage.
I suspect BIRT script cannot find test.jar. I have put it in several
places (/scriptlib at the top of birtScriptTest.war, c:/scriptlib,
c:/localhost/report/scriptlib, tomcat/shared/lib), and pointed
BIRT_VIEWER_SCRIPTLIB_DIR in web.xml to these locations. But I kept
getting the error messages above.
Am I missing something? Is BIRT failing to find the .jar file, or is it
facing another problem? Are there any work arounds? Is there a way to
gather more information?
Any help shall be greatly appreciated.
Thank you,
My environment:
BIRT 2.2.2
JDK 1.5.0_09
Tomcat 5.5.20
Windows XP SP2
|