Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » script can't load Java class?
script can't load Java class? [message #368273] Sat, 16 May 2009 00:07 Go to next message
Naomaru Itoi is currently offline Naomaru ItoiFriend
Messages: 1
Registered: July 2009
Junior Member
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
Re: script can't load Java class? [message #368285 is a reply to message #368273] Mon, 18 May 2009 15:58 Go to previous message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Naomaru,

Can you try to change this:
> importPackage( Packages.java.io,
> Packages.com.mycompany.a.b.ScriptTest );

to

importPackage(Packages.java.io );
importPackage(Packages.com.mycompany.a.b );

Jason


Naomaru Itoi wrote:
> 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
>
>
>
Previous Topic:Trigger BIRT preview box from application?
Next Topic:Deploying BIRT reports in JBOSS/TomCAT-issues
Goto Forum:
  


Current Time: Thu Apr 25 19:53:41 GMT 2024

Powered by FUDForum. Page generated in 0.02759 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top