Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » ScriptedDatasource report
ScriptedDatasource report [message #542553] Fri, 25 June 2010 06:23 Go to next message
ronald Missing name is currently offline ronald Missing name
Messages: 48
Registered: July 2009
Member
Hi all,

I just downloaded Helios and installed BIRT 2.6 via the update site. It al seems to work very smooth; congrats!
I don't have the java SDK installed as my project is written in PHP unfortunately. Do I need the java SDK also?

I'm exploring BIRT and I need to create a report based on some JSON data. AFAIK, for JSON + BIRT you need a JSONParser as in the famous example on http://www.birt-exchange.org/org/devshare/designing-birt-rep orts/1053-scripted-data-source-using-json/#description

I downloaded the source, refactored the example to a nice maven project and now I'm trying to attach the resulting jar as a resource to the report. I can't find the resource properties tab however...

As I understand, I can add an external jar and use the java code in that jar when I import the right packages, can't I?

On the dataset, open event, I have:

importPackage(Packages.com.actuate.json);
count = 0;
controller = new Packages.com.actuate.json.JSONParser();
controller.loadData(params["JSONURL"]);
totalCount = controller.getChildCount("rows");


Which results in the error:

ReportDesign (id = 1):
+ There are errors evaluating script "importPackage(Packages.com.actuate.json);
count = 0;
controller = new Packages.com.actuate.json.JSONParser();
controller.loadData(params["JSONURL"]);
totalCount = controller.getChildCount("rows");
":
{1}.


Actually, it breaks on the 3rd line: controller = new Packages.com.actuate.json.JSONParser();

Any help or links to the right documentation are appreciated Smile
Ronaldo

Re: ScriptedDatasource report [message #542697 is a reply to message #542553] Fri, 25 June 2010 12:17 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

If you have the jar in the scriptlib dir you do not have to attach it.
In the designer you can also set the project classpath in the
preferences to add a Java project to your BIRT cp, but when deployed the
jar will need to be in the scriptlib dir as set in the web.xml. If you
want to attach the jar, import it to the resource folder and then select
the report and the resource tab is in the properties view. Make sure
you have the root node(report name) in the outline view selected.


Jason

On 6/25/2010 6:23 AM, ronald wrote:
> Hi all,
>
> I just downloaded Helios and installed BIRT 2.6 via the update site. It
> al seems to work very smooth; congrats!
> I don't have the java SDK installed as my project is written in PHP
> unfortunately. Do I need the java SDK also?
>
> I'm exploring BIRT and I need to create a report based on some JSON
> data. AFAIK, for JSON + BIRT you need a JSONParser as in the famous
> example on http://www.birt-exchange.org/org/devshare/designing-birt-rep
> orts/1053-scripted-data-source-using-json/#description
>
> I downloaded the source, refactored the example to a nice maven project
> and now I'm trying to attach the resulting jar as a resource to the
> report. I can't find the resource properties tab however...
>
> As I understand, I can add an external jar and use the java code in that
> jar when I import the right packages, can't I?
>
> On the dataset, open event, I have:
>
> importPackage(Packages.com.actuate.json);
> count = 0;
> controller = new Packages.com.actuate.json.JSONParser();
> controller.loadData(params["JSONURL"]);
> totalCount = controller.getChildCount("rows");
>
> Which results in the error:
>
> ReportDesign (id = 1):
> + There are errors evaluating script
> "importPackage(Packages.com.actuate.json);
> count = 0;
> controller = new Packages.com.actuate.json.JSONParser();
> controller.loadData(params["JSONURL"]);
> totalCount = controller.getChildCount("rows");
> ":
> {1}.
>
> Actually, it breaks on the 3rd line: controller = new
> Packages.com.actuate.json.JSONParser();
>
> Any help or links to the right documentation are appreciated :)
> Ronaldo
>
>


Jason Weathersby

BIRT Exchange
Re: ScriptedDatasource report [message #543671 is a reply to message #542697] Wed, 30 June 2010 05:10 Go to previous messageGo to next message
ronald Missing name is currently offline ronald Missing name
Messages: 48
Registered: July 2009
Member
Hi Jason,

Thanks for your reply. I tried several things but it doesn't work yet.

1)
I added a BIRT_HOME dir on my Mac, and did a 'export BIRT_HOME=~/Development/BIRT_HOME'
Now I have a $BIRT_HOME dir which includes a scriptlib (~/Development/BIRT_HOME/scriptlib) in which the jar resides.
I restarted eclipse and still I the script didn't work.

2)
I created a WEB-INF/classes directory in my eclipse-helios/plugings/org.eclipse.birt.resources_2.6.0.v20 100304 directory
(So the the com and org packages as downloaded from http://www.birt-exchange.org/org/devshare/designing-birt-rep orts/1053-scripted-data-source-using-json/ are in eclipse-helios/plugings/org.eclipse.birt.resources_2.6.0.v20 100304/WEB-INF/classes)
I restarted eclipse... Still, this message when debugging the report:
Jun 30, 2010 11:01:29 AM org.eclipse.birt.report.debug.internal.core.vm.ReportVMServer start
INFO: [Server] client accepted
Jun 30, 2010 11:01:29 AM org.eclipse.birt.report.debug.internal.core.vm.ReportVMServer$1 run
INFO: [Server] enter request dispatching
Jun 30, 2010 11:01:29 AM org.eclipse.birt.report.debug.internal.core.launcher.ReportLauncher configEngine
INFO: User class path received: 
>>>> Compiled Source: [/COLOR]
function __bm_OPEN() {
importPackage(Packages.com.actuate.json);

// This will track your current row later on
count = 0;

// Create instance of the Controller class
controller = new Packages.com.actuate.json.JSONParser();

// Load the JSON Source
//controller.loadData(params["JSONURL"]);

// Calculate the total rows we will have
//totalCount = controller.getChildCount("rows");
} 
>>>> end compilation.
>>>> Compiled Source: 
__bm_OPEN()
>>>> end compilation.
>>>> Frame Source Name: 
>>>> Frame Function Name: __bm_OPEN
>>>> Enter script. 1
>>>> Line changed to: 1
>>>> Line changed to: 4
>>>> Line changed to: 7
>>>> Debugger exception occured:
>>>> Exit script.
[COLOR=red]org.mozilla.javascript.EcmaError: TypeError: [JavaPackage com.actuate.json.JSONParser] is not a function, it is object. (#7)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
	at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
	at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
	at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
	at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3637)
	at org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3625)
	at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3367)
	at script.__bm_OPEN(:7)


So either the example doesn't work any more or I'm overlooking a very simple thingy...
BIRT still looks very promising, so I hope we can sort this out.

Ronaldo
Re: ScriptedDatasource report [message #543688 is a reply to message #543671] Wed, 30 June 2010 06:03 Go to previous messageGo to next message
ronald Missing name is currently offline ronald Missing name
Messages: 48
Registered: July 2009
Member
Hi,

Thanks Jason, I got it working, thanks to this example of yours to make sure I got it all in the right directory.
It was unclear to me where the BIRT_HOME directory for the viewer was; and for me it was counterintuitive that it actually is the
eclipse-helios/plugins/org.eclipse.birt.report.viewer_2.6.0. v20100605/birt/scriptlib dir where you can put the jars to be picked up when eclipse starts.
(When you design/view reports in eclipse)

I hope it will all work out now Smile

Ronald





Re: ScriptedDatasource report [message #543795 is a reply to message #543688] Wed, 30 June 2010 11:03 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Ronald,

Glad you got it working. I was assuming you were deploying BIRT to an
app server and the scriptlib directory can be set in that situation. In
the designer you do what you did or add the jar to the report resources
or set the classpath for a report project in the preferences:
http://www.eclipse.org/birt/phoenix/project/notable2.6.php#j ump_14
Note that this feature is also available in 2.5.2.

Jason

On 6/30/2010 6:03 AM, ronald wrote:
> Hi,
>
> Thanks Jason, I got it working, thanks to
> thttp://dev.eclipse.org/newslists/news.eclipse.birt/msg27057 .html to
> make sure I got it all in the right directory.
> It was unclear to me where the BIRT_HOME directory for the viewer was;
> and for me it was counterintuitive that it actually is the
> eclipse-helios/plugins/org.eclipse.birt.report.viewer_2.6.0.
> v20100605/birt/scriptlib dir where you can put the jars to be picked up
> when eclipse starts.
> (When you design/view reports in eclipse)
>
> I hope it will all work out now :)
>
> Ronald
>
>
>
>
>
>


Jason Weathersby

BIRT Exchange
Re: ScriptedDatasource report [message #545591 is a reply to message #543795] Thu, 08 July 2010 06:52 Go to previous messageGo to next message
ronald Missing name is currently offline ronald Missing name
Messages: 48
Registered: July 2009
Member
Hi,

For two days I've been trying to build a decent spring (3) app around the report engine.
I've seen some nice future solutions (See http://jira.springframework.org/browse/SPR-1220), but they don't provide a solution for now.
Most other links use older versions of BIRT, and I did not succeed in building something nice.

So, we're using the backup plan: call the shell script to generate a pdf. And again, I'm not sure where to put the external jar (Where's the scriptlib directory located when running birt from the command line?)

The sample report works just fine, indicating that the BIRT_HOME var is set:

./genReport.sh -m runrender -f PDF -o testpdf.pdf -e UTF-8 samples/hello_world.rptdesign

Here's my directory layout:


~/birt_runtime_2.6.0/ReportEngine/
configuration/
genReport.sh
lib/
plugins/
samples/
workspace/


So I created a scriptlib in the ~/birt_runtime_2.6.0/ReportEngine/ and added this scriptlib dir to the classpath set in genReport.sh:

~/birt_runtime_2.6.0/ReportEngine/
configuration/
genReport.sh
lib/
plugins/
scriptlib/
my-jar-with-dependencies.jar

samples/
workspace/


And the genReport.sh now contains:

export BIRTCLASSPATH="$BIRT_HOME/ReportEngine/scriptlib :$BIRT_HOME/ReportEngine/lib/chartengineapi.jar:$BIRT_HOME/R eportEngine/lib/chart.....

Still, when running the command line script from within the ~/birt_runtime_2.6.0/ReportEngine/ directory, I get all sorts of errors that indicat that the my-jar-with-dependencies.jar is not correctly loaded.
(The same my-jar-with-dependencies.jar added to the classpath in the designer as indicated above works just fine from withing the designer)

I also tried to copy the org.eclipse.birt.report.viewer_2.6.0. v20100605/birt/scriptlib from within eclipse to the ~/birt_runtime_2.6.0/plugins directory... Didn't help.

So, what should I do?

TIA
Ronald

[Updated on: Thu, 08 July 2010 08:04]

Report message to a moderator

Re: ScriptedDatasource report [message #545608 is a reply to message #545591] Thu, 08 July 2010 08:22 Go to previous message
ronald Missing name is currently offline ronald Missing name
Messages: 48
Registered: July 2009
Member
Dudes, I need more coffee...

Change the genReport.sh to contain

export BIRTCLASSPATH="$BIRT_HOME/ReportEngine/scriptlib/my-jar-with-dependencies.jar:$BIRT_HOME/ReportEngine/lib/chartengineapi.jar:.....

And explicitely name the jar you wan to include. That works.

Ronald
Previous Topic:SAXParseException: Premature end of file.
Next Topic:Font sizes larger in 2.6 than in 2.3?
Goto Forum:
  


Current Time: Sun May 19 17:21:10 EDT 2013

Powered by FUDForum. Page generated in 0.02530 seconds