Skip to main content



      Home
Home » Archived » BIRT » Java class location for a scripted data source
Java class location for a scripted data source [message #247713] Thu, 12 July 2007 15:56 Go to next message
Eclipse UserFriend
I've placed my custom java classes in a jar file located in:
birt-rcp-report-designer-2_2_0\plugins\org.eclipse.birt.repo rt.viewer_2.2.0.v20070620\birt\WEB-INF\lib

I'm able to see the report just fine in the viewer, but when I do other
things that rely on the class definition, such as Preview Results in the
Edit Data Set dialog or select the data set in the chart creation dialog,
I get an error dialog:

A BIRT exception occurred: Error evaluating Javascript expression. Script
engine error: ReferenceError: "TestReport" is not
defined.(DataSet[DataSet].__bm_open#5)

Where do I need to put the jar file so the report designer (not viewer)
can see it?

I'm using birt-rcp-report-designer-2_2_0.

Here is my open and fetch scripts:

importPackage(Packages.org.mytest.report);
importPackage(Packages.org.mytest.domain);

reportQuery = new TestReport();
qData = reportQuery.getData();
iterator = qData.iterator();
--------

if (!iterator.hasNext() ) { return false;
}
else {
node = iterator.next();
row.Name = node.getName( );
row.Id = node.getId();

return true;
}

---
Thanks,
James
Re: Java class location for a scripted data source [message #247725 is a reply to message #247713] Thu, 12 July 2007 16:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

James,

Have you tried the
\birt\scriptlib

directory under the viewer?

Jason

James Cox wrote:
> I've placed my custom java classes in a jar file located in:
> birt-rcp-report-designer-2_2_0\plugins\org.eclipse.birt.repo rt.viewer_2.2.0.v20070620\birt\WEB-INF\lib
>
>
> I'm able to see the report just fine in the viewer, but when I do other
> things that rely on the class definition, such as Preview Results in the
> Edit Data Set dialog or select the data set in the chart creation
> dialog, I get an error dialog:
>
> A BIRT exception occurred: Error evaluating Javascript expression.
> Script engine error: ReferenceError: "TestReport" is not
> defined.(DataSet[DataSet].__bm_open#5)
>
> Where do I need to put the jar file so the report designer (not viewer)
> can see it?
>
> I'm using birt-rcp-report-designer-2_2_0.
>
> Here is my open and fetch scripts:
>
> importPackage(Packages.org.mytest.report);
> importPackage(Packages.org.mytest.domain);
>
> reportQuery = new TestReport();
> qData = reportQuery.getData();
> iterator = qData.iterator();
> --------
>
> if (!iterator.hasNext() ) { return false; }
> else {
> node = iterator.next();
> row.Name = node.getName( );
> row.Id = node.getId();
>
> return true;
> }
>
> ---
> Thanks,
> James
>
>
>
Re: Java class location for a scripted data source [message #247729 is a reply to message #247725] Thu, 12 July 2007 17:47 Go to previous messageGo to next message
Eclipse UserFriend
The viewer works if the java class is located in a jar file under
birt\scriptlib or birt\WEB-INF\lib. Still getting the error when the
designer refs the class.

I also tried it with the jar in neither, just to make sure that it was not
somewhere else on my classpath. The viewer threw an error as expected.

James
Re: Java class location for a scripted data source [message #247733 is a reply to message #247729] Thu, 12 July 2007 17:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

James,

Did you shutdown the designer and start it back up?
I just tried adding a jar to the scriptlib directory, restarted eclipse
and it worked.

Jason


James Cox wrote:
> The viewer works if the java class is located in a jar file under
> birt\scriptlib or birt\WEB-INF\lib. Still getting the error when the
> designer refs the class.
>
> I also tried it with the jar in neither, just to make sure that it was
> not somewhere else on my classpath. The viewer threw an error as expected.
>
> James
>
>
Re: Java class location for a scripted data source [message #247747 is a reply to message #247733] Thu, 12 July 2007 22:03 Go to previous messageGo to next message
Eclipse UserFriend
I started over just to make sure that something was not amiss. Again, the
report shows up fine in the preview pane, but when I select the data set
in the Data Explorer, then Edit -> Preview results, I get the error dialog.

My class is in a jar file in birt/scriptlib:

package my.pkg;

import java.util.ArrayList;
import java.util.List;

public class WithPackage {
public List getData() {
List ret = new ArrayList();
ret.add("Hello");
ret.add("World");
return ret;
}
}
Re: Java class location for a scripted data source [message #247751 is a reply to message #247747] Thu, 12 July 2007 22:06 Go to previous messageGo to next message
Eclipse UserFriend
I guess I should add that my open javascript function is:

reportQuery = new Packages.my.pkg.WithPackage();
qData = reportQuery.getData();
iterator = qData.iterator();

and the fetch is:
if (!iterator.hasNext() ) { return false; }
else {
row.Text = iterator.next();

return true;
}

Also, I tried compiling the file under both 1.4 and 5.0.
Re: Java class location for a scripted data source [message #247785 is a reply to message #247747] Fri, 13 July 2007 07:30 Go to previous messageGo to next message
Eclipse UserFriend
I suppose that your issue is described in bug
https://bugs.eclipse.org/bugs/show_bug.cgi?id=190500

I have solved this issue using buddy classloading (the org.mozilla.rhino
plugin).

Snjeza

James Cox wrote:
> I started over just to make sure that something was not amiss. Again,
> the report shows up fine in the preview pane, but when I select the data
> set in the Data Explorer, then Edit -> Preview results, I get the error
> dialog.
>
> My class is in a jar file in birt/scriptlib:
>
> package my.pkg;
>
> import java.util.ArrayList;
> import java.util.List;
>
> public class WithPackage {
> public List getData() {
> List ret = new ArrayList();
> ret.add("Hello");
> ret.add("World");
> return ret;
> }
> }
>
>
Re: Java class location for a scripted data source [message #247791 is a reply to message #247751] Fri, 13 July 2007 10:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

James,

I tried your code and it worked fine for me, but this may be because my
code is in my workspace.

Jason

James Cox wrote:
> I guess I should add that my open javascript function is:
>
> reportQuery = new Packages.my.pkg.WithPackage();
> qData = reportQuery.getData();
> iterator = qData.iterator();
>
> and the fetch is:
> if (!iterator.hasNext() ) { return false; }
> else {
> row.Text = iterator.next();
>
> return true;
> }
>
> Also, I tried compiling the file under both 1.4 and 5.0.
>
Re: Java class location for a scripted data source [message #247816 is a reply to message #247785] Fri, 13 July 2007 11:16 Go to previous messageGo to next message
Eclipse UserFriend
That is my problem.

Can you elaborate on your solution? Do you create a plugin with your
custom classes and register it as a buddy to rhino? I've done some
googling to little avail...

Thanks,
James
Re: Java class location for a scripted data source [message #247824 is a reply to message #247791] Fri, 13 July 2007 11:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jason. I created the report in the same workspace as my java source
files, everything works. I think I'll change my project structure to work
this way, it seems easier than toying with the buddy classpath.

Thanks,
James
Re: Java class location for a scripted data source [message #247866 is a reply to message #247816] Fri, 13 July 2007 14:39 Go to previous message
Eclipse UserFriend
I have added the following line to the org.mozilla.rhino plugin:

Eclipse-BuddyPolicy: registered

and the following line to my viewer plugin:

Eclipse-RegisterBuddy: org.mozilla.rhino

You would probably add that to the BIRT viewer plugin.

See the thread with subject "Java event handler and the List Box
Parameter" for more information.

Regards,
Snjeza



James Cox wrote:
> That is my problem.
>
> Can you elaborate on your solution? Do you create a plugin with your
> custom classes and register it as a buddy to rhino? I've done some
> googling to little avail...
>
> Thanks,
> James
>
Previous Topic:Locale set via report parameter
Next Topic:How to display BIRT Report output embedded in browser
Goto Forum:
  


Current Time: Fri Oct 24 17:55:52 EDT 2025

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

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

Back to the top