Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Help : Scripted Data Source (Urgent)
Help : Scripted Data Source (Urgent) [message #253158] Tue, 21 August 2007 16:40 Go to next message
Eclipse UserFriend
Originally posted by: suryakant.in.ibm.com

Hello,
I am trying to develop a report using Scripted Data Source. I have a
sample java file which will populate the data which i wud be then feeding
to the tabel in the report. When i am placing the classes files in the
Eclipse/plugins/...viewer/scriptlib its working fine in the birt report
viewer
But i want it to get it working with a java standalone application. I have
a java program that would use BIRT report Engine API's to access the
rptdesign file and would generate the report


The java program :

//---------------- Java Program to Generate Report -------------------
import java.util.HashMap;
import org.eclipse.birt.report.engine.api.*;

public class viewtest2 {

public static void main(String[] args) {
EngineConfig conf = null;
ReportEngine eng = null;
IReportRunnable design = null;
IRunAndRenderTask task = null;
HTMLRenderOption renderOption_html=null;
HashMap<String,HTMLRenderOption> contextMap = null;
PDFRenderOption renderOption_pdf = null;
HashMap<String, PDFRenderOption> contextMap_pdf = new
HashMap<String,PDFRenderOption>();

DOCRenderContext renderOption_doc = new DOCRenderContext();

conf = new EngineConfig();
conf.setEngineHome("C:/Program
Files/BIRT/birt-runtime-2_2_0/ReportEngine");
eng = new ReportEngine( conf );

try
{
design =
eng.openReportDesign("C:/tmp/Test_Report.rptdesign");
}
catch (Exception e)
{
System.err.println("An error occured during the opening of
the report file!");
e.printStackTrace();
System.exit(-1);
}


task = eng.createRunAndRenderTask(design);


renderOption_html = new HTMLRenderOption();


renderOption_html.setImageDirectory("image");

contextMap = new HashMap<String,HTMLRenderOption>();
contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
renderOption_html );
task.setAppContext( contextMap );

renderOption_html.setOutputFileName("c:/tmp/output.html");
renderOption_html.setOutputFormat("html");
task.setRenderOption(renderOption_html);

try
{
task.run();

}
catch (Exception e)
{
System.err.println("An error occured while running the
report!");
e.printStackTrace();
System.exit(-1);
}


System.out.println("All went well. Closing program!");
eng.destroy();
}
}

//---------------The Java File to populate data--------------------------
import java.net.URL;
import java.io.DataInputStream;
import java.io.InputStream;

public class EvalTest {

DataInputStream dis;
public DataInputStream readData()
{

try
{
URL rurl= new java.net.URL("http://rss.cnn.com/rss/cnn_topstories.rss");
InputStream is = rurl.openStream();
dis = new java.io.DataInputStream( new java.io.BufferedInputStream( is ));

}
catch(Exception e)
{
e.printStackTrace();
}
return dis;
}
}

//------------------------------------------

And in the scripted dataset i used following codes .

//---------- open---------
sampleClass12 = new Packages.EvalTest();
dis = sampleClass12.readData();

// --------fetch------
if( ( rline=dis.readLine()) != null ){
dataSetRow["Test"] = rline;
return true;
}
return false;


//--------------------
I am new to BIRT and am not able to figure out how to execute this without
placing th jar files in the scriptlib or WEB_INF/lib directory

am getting the following error :
Aug 21, 2007 10:08:18 PM
org.eclipse.birt.report.engine.script.internal.DtEScriptExec utor handleJS
WARNING: A BIRT exception occurred: Error evaluating Javascript
expression. Script engine error: TypeError: [JavaPackage EvalTest] is not
a function. (DataSet[Data Set].__bm_OPEN#2)
Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
__bm_OPEN(). See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError:
[JavaPackage EvalTest] is not a function. (DataSet[Data Set].__bm_OPEN#2)
Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
__bm_OPEN()
org.eclipse.birt.data.engine.core.DataException: A BIRT exception
occurred: Error evaluating Javascript expression. Script engine error:
TypeError: [JavaPackage EvalTest] is not a function. (DataSet[Data
Set].__bm_OPEN#2)
Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
__bm_OPEN(). See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError:
[JavaPackage EvalTest] is not a function. (DataSet[Data Set].__bm_OPEN#2)
Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:


Thank you
Re: Help : Scripted Data Source (Urgent) [message #253203 is a reply to message #253158] Wed, 22 August 2007 06:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

You can try the following before starting up the platform.

System.setProperty( EngineConstants.WEBAPP_CLASSPATH_KEY,"c:/myclasses" );

Jason

suryakant wrote:
> Hello,
> I am trying to develop a report using Scripted Data Source. I have a
> sample java file which will populate the data which i wud be then
> feeding to the tabel in the report. When i am placing the classes files
> in the Eclipse/plugins/...viewer/scriptlib its working fine in the birt
> report viewer
> But i want it to get it working with a java standalone application. I
> have a java program that would use BIRT report Engine API's to access
> the rptdesign file and would generate the report
>
>
> The java program :
>
> //---------------- Java Program to Generate Report -------------------
> import java.util.HashMap;
> import org.eclipse.birt.report.engine.api.*;
>
> public class viewtest2 {
>
> public static void main(String[] args) {
> EngineConfig conf = null;
> ReportEngine eng = null;
> IReportRunnable design = null;
> IRunAndRenderTask task = null;
> HTMLRenderOption renderOption_html=null;
> HashMap<String,HTMLRenderOption> contextMap = null;
> PDFRenderOption renderOption_pdf = null;
> HashMap<String, PDFRenderOption> contextMap_pdf = new
> HashMap<String,PDFRenderOption>();
> DOCRenderContext renderOption_doc = new
> DOCRenderContext();
> conf = new EngineConfig();
> conf.setEngineHome("C:/Program
> Files/BIRT/birt-runtime-2_2_0/ReportEngine");
> eng = new ReportEngine( conf );
> try
> {
> design =
> eng.openReportDesign("C:/tmp/Test_Report.rptdesign");
> }
> catch (Exception e)
> {
> System.err.println("An error occured during the opening of
> the report file!");
> e.printStackTrace();
> System.exit(-1);
> }
> task = eng.createRunAndRenderTask(design);
> renderOption_html = new HTMLRenderOption();
> renderOption_html.setImageDirectory("image");
> contextMap = new HashMap<String,HTMLRenderOption>();
> contextMap.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
> renderOption_html );
> task.setAppContext( contextMap );
>
> renderOption_html.setOutputFileName("c:/tmp/output.html");
> renderOption_html.setOutputFormat("html");
> task.setRenderOption(renderOption_html);
> try
> {
> task.run();
> }
> catch (Exception e)
> {
> System.err.println("An error occured while running the
> report!");
> e.printStackTrace();
> System.exit(-1);
> }
> System.out.println("All went well. Closing
> program!");
> eng.destroy();
> }
> }
>
> //---------------The Java File to populate data--------------------------
> import java.net.URL;
> import java.io.DataInputStream;
> import java.io.InputStream;
>
> public class EvalTest {
>
> DataInputStream dis;
> public DataInputStream readData()
> {
> try
> {
> URL rurl= new java.net.URL("http://rss.cnn.com/rss/cnn_topstories.rss");
> InputStream is = rurl.openStream();
> dis = new java.io.DataInputStream( new java.io.BufferedInputStream( is ));
>
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> return dis;
> }
> }
>
> //------------------------------------------
>
> And in the scripted dataset i used following codes .
>
> //---------- open---------
> sampleClass12 = new Packages.EvalTest();
> dis = sampleClass12.readData();
>
> // --------fetch------
> if( ( rline=dis.readLine()) != null ){
> dataSetRow["Test"] = rline;
> return true;
> }
> return false;
>
>
> //--------------------
> I am new to BIRT and am not able to figure out how to execute this
> without placing th jar files in the scriptlib or WEB_INF/lib directory
> am getting the following error :
> Aug 21, 2007 10:08:18 PM
> org.eclipse.birt.report.engine.script.internal.DtEScriptExec utor handleJS
> WARNING: A BIRT exception occurred: Error evaluating Javascript
> expression. Script engine error: TypeError: [JavaPackage EvalTest] is
> not a function. (DataSet[Data Set].__bm_OPEN#2)
> Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
> __bm_OPEN(). See next exception for more information.
> Error evaluating Javascript expression. Script engine error: TypeError:
> [JavaPackage EvalTest] is not a function. (DataSet[Data Set].__bm_OPEN#2)
> Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
> __bm_OPEN()
> org.eclipse.birt.data.engine.core.DataException: A BIRT exception
> occurred: Error evaluating Javascript expression. Script engine error:
> TypeError: [JavaPackage EvalTest] is not a function. (DataSet[Data
> Set].__bm_OPEN#2)
> Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
> __bm_OPEN(). See next exception for more information.
> Error evaluating Javascript expression. Script engine error: TypeError:
> [JavaPackage EvalTest] is not a function. (DataSet[Data Set].__bm_OPEN#2)
> Script source: DataSet[Data Set].__bm_OPEN, line: 1, text:
>
>
> Thank you
>
Re: Help : Scripted Data Source (Urgent) [message #253215 is a reply to message #253203] Wed, 22 August 2007 09:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: suryakant.in.ibm.com

Hello Jason
Thankz for the help .. but still am not able to get the program running.
I am able to get the output when i place my jar files in the scriptlib or
WEB_INF/lib directory of the viewwer pluggin. But what my need is i want a
java standalone application with the .rptdesign file and the
reportgeneration java files and the Script java files (to be used as
scripted data source) to be together in the same eclipse java project and
then execute it .. Its giving error as :

Aug 22, 2007 2:46:31 PM
org.eclipse.birt.report.engine.script.internal.DtEScriptExec utor handleJS
WARNING: A BIRT exception occurred: Error evaluating Javascript
expression. Script engine error: TypeError: [JavaPackage EvalTest] is not
a function. (DataSet[DataSet].__bm_OPEN#2)
Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
__bm_OPEN(). See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError:
[JavaPackage EvalTest] is not a function. (DataSet[DataSet].__bm_OPEN#2)
Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
__bm_OPEN()
org.eclipse.birt.data.engine.core.DataException: A BIRT exception
occurred: Error evaluating Javascript expression. Script engine error:
TypeError: [JavaPackage EvalTest] is not a function.
(DataSet[DataSet].__bm_OPEN#2)
Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
__bm_OPEN(). See next exception for more information.
Error evaluating Javascript expression. Script engine error: TypeError:
[JavaPackage EvalTest] is not a function. (DataSet[DataSet].__bm_OPEN#2)
Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
__bm_OPEN()


Thanks in advance
greetings
surya
Re: Help : Scripted Data Source (Urgent) [message #253273 is a reply to message #253215] Wed, 22 August 2007 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Surya,

Did you try?

System.setProperty(
EngineConstants.WEBAPP_CLASSPATH_KEY,"c:/myclasses/myjar.jar " );


Jason

surya wrote:
> Hello Jason
> Thankz for the help .. but still am not able to get the program running.
> I am able to get the output when i place my jar files in the scriptlib
> or WEB_INF/lib directory of the viewwer pluggin. But what my need is i
> want a java standalone application with the .rptdesign file and the
> reportgeneration java files and the Script java files (to be used as
> scripted data source) to be together in the same eclipse java project
> and then execute it .. Its giving error as :
>
> Aug 22, 2007 2:46:31 PM
> org.eclipse.birt.report.engine.script.internal.DtEScriptExec utor handleJS
> WARNING: A BIRT exception occurred: Error evaluating Javascript
> expression. Script engine error: TypeError: [JavaPackage EvalTest] is
> not a function. (DataSet[DataSet].__bm_OPEN#2)
> Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
> __bm_OPEN(). See next exception for more information.
> Error evaluating Javascript expression. Script engine error: TypeError:
> [JavaPackage EvalTest] is not a function. (DataSet[DataSet].__bm_OPEN#2)
> Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
> __bm_OPEN()
> org.eclipse.birt.data.engine.core.DataException: A BIRT exception
> occurred: Error evaluating Javascript expression. Script engine error:
> TypeError: [JavaPackage EvalTest] is not a function.
> (DataSet[DataSet].__bm_OPEN#2)
> Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
> __bm_OPEN(). See next exception for more information.
> Error evaluating Javascript expression. Script engine error: TypeError:
> [JavaPackage EvalTest] is not a function. (DataSet[DataSet].__bm_OPEN#2)
> Script source: DataSet[DataSet].__bm_OPEN, line: 1, text:
> __bm_OPEN()
>
>
> Thanks in advance
> greetings
> surya
>
Re: Help : Scripted Data Source (Urgent) [message #253291 is a reply to message #253273] Wed, 22 August 2007 22:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: suryakant.in.ibm.com

Hello Jason,
Loads and Loads of THANKS to you . Everything is working fine now. I am
really grateful to you
Thank You
surya
Re: Help : Scripted Data Source (Urgent) [message #253292 is a reply to message #253291] Wed, 22 August 2007 22:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: suryakant.in.ibm.com

Hello Jason,
The funtion addScriptableJavaObject(...) is depricated. Which funtion
should be the work around for it
Thank you
suyra
Re: Help : Scripted Data Source (Urgent) [message #253312 is a reply to message #253292] Thu, 23 August 2007 15:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Surya,

You can use the application context object to do this. You can set this
for the task or the engine like:

DummyClass dl = new DummyClass();

//Configure the Engine and start the Platform
config = new EngineConfig( );
HashMap hm = config.getAppContext();
hm.put( "dummy", dl);
config.setAppContext(hm);

Jason

surya wrote:
> Hello Jason,
> The funtion addScriptableJavaObject(...) is depricated. Which funtion
> should be the work around for it
> Thank you suyra
>
Re: Help : Scripted Data Source (Urgent) [message #253514 is a reply to message #253312] Mon, 27 August 2007 11:03 Go to previous message
Eclipse UserFriend
Originally posted by: suryakant.in.ibm.com

Thanks jason

Regards
surya
Previous Topic:jndi datasource problem
Next Topic:IS this possible with CHART API?
Goto Forum:
  


Current Time: Thu Jul 25 14:02:16 GMT 2024

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

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

Back to the top