Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Error accesing java classes from a scripted dataset(BIRT scripting datasources: error accesing java classes )
Error accesing java classes from a scripted dataset [message #629892] Wed, 29 September 2010 20:59 Go to next message
Rajesh Indurthi is currently offline Rajesh IndurthiFriend
Messages: 7
Registered: September 2010
Junior Member
Hi,
Iam using BIRT version : 2.2.1 , along with my ILOG rule studio 6.7.3. Iam trying to create a BIRT scripted datasource, the java script in my dataset is trying to acces the java classes. I have done the following steps to achive it :

1) Have placed my compiled java classes under: JRules673\studio\eclipse\plugins\org.eclipse.birt.report.vie wer_2.2.1.r22x_v20070920\birt\WEB-INF\classes\
2) Have created a Dataset in my report which uses a scripted Datasource. The open scrip of the data set looks likes this :
count = 0;
// Create instance of
// the GetStockHistory class
gsh = new Packages.StockDaoMock(); 
//Load the List
stock = gsh.getStockValues("Java");

The java script in my fetch method looks like this :
if(count < stock.size()){
       row["columnDate"] = stock.get(count).getDate();
       row["columnOpen"] = stock.get(count).getOpen();
       row["columnHigh"] = stock.get(count).getHigh();
       row["columnLow"] = stock.get(count).getLow();
       row["columnClose"] = stock.get(count).getClose();
       row["columnVolume"] = stock.get(count).getVolume();
       count++;
       return true;
}

return false;

When I try to previe my results on the data set , I get the following error :
[B]
A BIRT exception occured : Error evaluating javascript expression. Script Engine error : TypeError:[JavaPackage StockDaoMock] is not a function.[/B]

My understanding is eclipse report in the design time is not able to find the java classes which the scrip is using. Following some suggestion on the forum I also tried to put a jar containing my compiled classes at the following location : \studio\eclipse\plugins\org.eclipse.birt.report.viewer_2.2.1 .r22x_v20070920\birt\scriptlib
But the script was not able to pick the classes. It still came back with the same exception.
TypeError:[JavaPackage]is not a funtion 
. What am I missing? Iam using BIRT 2.2.1 with ILOG rule studio 6.7.3. Struggling with this for a long time now , so any help/hints is highly appreciated.
Re: Error accesing java classes from a scripted dataset [message #630052 is a reply to message #629892] Thu, 30 September 2010 14:05 Go to previous messageGo to next message
Rajesh Indurthi is currently offline Rajesh IndurthiFriend
Messages: 7
Registered: September 2010
Junior Member
Any insights on the problem Iam facing!!! This is driving me nuts so any help is highly appreciated..Please !!!
Re: Error accesing java classes from a scripted dataset [message #630078 is a reply to message #630052] Thu, 30 September 2010 15:09 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I think this was an issue in version 2.2.1. While previewing the
dataset the call will fail, but if you drag the dataset onto the canvas
and preview the report it should work.

You can try putting your classes in a Package and then jar it.
Then put the jar in the scriptlib folder of the plugin.
Change your code to something like:

importPackage( Packages.my.test.obj );

gsh = new StockDaoMock();

This will still only work in preview of the report not the datset.
If you create a java project in the workspace with the classes then it
will work for preview. These issues have been fixed in the last couple
versions of BIRT.

Jason

On 9/30/2010 10:05 AM, Rajesh Indurthi wrote:
> Any insights on the problem Iam facing!!! This is driving me nuts so any
> help is highly appreciated..Please !!!
Re: Error accesing java classes from a scripted dataset [message #630134 is a reply to message #629892] Thu, 30 September 2010 17:54 Go to previous messageGo to next message
Rajesh Indurthi is currently offline Rajesh IndurthiFriend
Messages: 7
Registered: September 2010
Junior Member
Thanks Jason,
the report view did work as you explained. Thanks for the guidance, really appreciate it. I will go ahed and use scripted datasources for reporting in my porject , will ping you back if I have any more porblems going forward.

Thanks a bunch again
Rajesh

Re: Error accesing java classes from a scripted dataset [message #630169 is a reply to message #629892] Thu, 30 September 2010 21:13 Go to previous message
Rajesh Indurthi is currently offline Rajesh IndurthiFriend
Messages: 7
Registered: September 2010
Junior Member
Hi Jason,
I was able to get my report running by placing my jar files in the scriptlib folder as you asked me to. However is there a more elegant solution for BIRT report plugin to look up my java classes. I will bebundling the solution inot an RCP app , In my case I want BIRT viewer to have acces to my whole persistance stack, which include a whole bunch of jars. One thing I tried to do is add
Eclipse-BuddyPolicy: registered
to the manifest file of my BIRT report viewer, and then added the following to the Manifest file of the plugin which has my java classes
Eclipse-RegisterBuddy: org.eclipse.birt.report.viewer.ViewerPlugin

I assumed that this will allow BIRT report to actually have access to my java class , but it did not work. Please advise me as to how to set my classloader on the BIRT report viewer.Your help is highly appreciated.
Previous Topic:Updating Chart using a button click
Next Topic:Newbe issues
Goto Forum:
  


Current Time: Sat Apr 20 06:07:56 GMT 2024

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

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

Back to the top