eng.createRunAndRenderTask [message #236775] |
Thu, 03 May 2007 16:16  |
Eclipse User |
|
|
|
Originally posted by: joannem.smartmech.com
I am having an issue where I am unable to get past the following in my
java program to create my report using BIRT
task = eng.createRunAndRenderTask(design);
When I display the value of design I get the following
"org.eclipse.birt.report.engine.api.impl.ReportRunnable@1de891b"
The following is my java program....
import java.io.*;
import java.lang.*;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.birt.report.engine.api.*;
import org.eclipse.birt.core.framework.Platform;
public class BIRT {
public static void main(String[] args) {
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
try
{
// Create a new file output stream
out = new FileOutputStream("myfile.txt",true);
// Connect print stream to the output stream
p = new PrintStream( out );
p.println ("This is written to a file");
// Variables used to control BIRT engine instance
EngineConfig conf = null;
ReportEngine eng = null;
IReportRunnable design = null;
IRunAndRenderTask task = null;
HTMLRenderContext renderContext = null;
HashMap contextMap = null;
HTMLRenderOption options = null;
// Setup the BIRT engine configuration. The Engine Home is hardcoded
// here, this is proably better set in an environment variable or in
// a configuration file. No other options need to be set
conf = new EngineConfig( );
conf.setEngineHome("/home/rci/BIRT2/birt-runtime-2_1_1/ReportEngine ");
conf.setLogConfig("/usr/Local", Level.ALL);
// System.out.println("I am here!");
p.println ("I am here");
// Create new Report engine based off of the configuration
eng = new ReportEngine( conf );
// With our new engine, lets try to open the report design
try
{
// System.out.println("I am here!");
p.println ("before design");
design =
eng.openReportDesign("/home/rci/BIRT2/workspace/netrec/netrecloc.rptdesign ");
p.println ("After design");
}
catch (Exception e)
{
p.println ("An error occured during the opening of the report
file!");
//System.err.println("An error occured during the opening of the
report file!");
e.printStackTrace();
System.exit(-1);
}
p.println ("Before assign task");
p.println ("The design is " + design);
// With the file open, create the Run and Render task to run the report
task = eng.createRunAndRenderTask(design);
p.println ("after task");
p.println ("task is " + task);
// Set Render context to handle url and image locations, and apply to
the
// task
renderContext = new HTMLRenderContext();
renderContext.setImageDirectory("image");
contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEX T,
renderContext );
task.setAppContext( contextMap );
p.println ("task set appcontext");
// This will set the output file location, the format to render to, and
// apply to the task
options = new HTMLRenderOption();
options.setOutputFileName("/var/www/html/smech/repout/test.html ");
options.setOutputFormat("html");
task.setRenderOption(options);
try
{
p.println ("before task.run");
task.run();
}
catch (Exception e)
{
p.println ("An error occured while running the report!");
//System.err.println("An error occurred while running the report!");
e.printStackTrace();
System.exit(-1);
}
// Destroy the engine and let the garbage collector
// do its thing
p.println ("All went well. Closing program!");
//System.out.println("All went well. Closing program!");
eng.destroy();
p.close();
} // try
catch (Exception eout)
{
System.err.println ("Error writing to file");
} // catch
} // main
} // BIRT
Any suggestions why I can't get past the createRunAndRenderTask , would be
greatly appreciated.
|
|
|
Re: eng.createRunAndRenderTask [message #236780 is a reply to message #236775] |
Thu, 03 May 2007 18:11   |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Jo-Anne,
Take a look at this example.
http://wiki.eclipse.org/index.php/Simple_Execute
Also can you post the stack trace?
Jason
Jo-Anne wrote:
> I am having an issue where I am unable to get past the following in my
> java program to create my report using BIRT
>
> task = eng.createRunAndRenderTask(design);
>
> When I display the value of design I get the following
>
> "org.eclipse.birt.report.engine.api.impl.ReportRunnable@1de891b"
>
> The following is my java program....
>
> import java.io.*;
> import java.lang.*;
> import java.util.HashMap;
> import java.util.List;
> import java.util.logging.Level;
> import org.eclipse.birt.report.engine.api.*;
> import org.eclipse.birt.core.framework.Platform;
>
> public class BIRT {
> public static void main(String[] args) {
>
> FileOutputStream out; // declare a file output object
> PrintStream p; // declare a print stream object
>
> try
> {
> // Create a new file output stream
> out = new FileOutputStream("myfile.txt",true);
>
> // Connect print stream to the output stream
> p = new PrintStream( out );
> p.println ("This is written to a file");
>
> // Variables used to control BIRT engine instance
> EngineConfig conf = null;
> ReportEngine eng = null;
> IReportRunnable design = null;
> IRunAndRenderTask task = null;
> HTMLRenderContext renderContext = null;
> HashMap contextMap = null;
> HTMLRenderOption options = null;
>
> // Setup the BIRT engine configuration. The Engine Home is hardcoded
> // here, this is proably better set in an environment variable or in
> // a configuration file. No other options need to be set
> conf = new EngineConfig( );
> conf.setEngineHome("/home/rci/BIRT2/birt-runtime-2_1_1/ReportEngine ");
> conf.setLogConfig("/usr/Local", Level.ALL);
>
> // System.out.println("I am here!");
> p.println ("I am here");
>
> // Create new Report engine based off of the configuration
> eng = new ReportEngine( conf );
>
> // With our new engine, lets try to open the report design
> try
> { // System.out.println("I am here!");
> p.println ("before design");
>
> design =
> eng.openReportDesign("/home/rci/BIRT2/workspace/netrec/netrecloc.rptdesign ");
>
> p.println ("After design");
> }
>
> catch (Exception e)
> {
> p.println ("An error occured during the opening of the report file!");
> //System.err.println("An error occured during the opening of the
> report file!");
> e.printStackTrace();
> System.exit(-1);
> }
>
> p.println ("Before assign task");
> p.println ("The design is " + design);
>
> // With the file open, create the Run and Render task to run the report
> task = eng.createRunAndRenderTask(design);
>
> p.println ("after task");
> p.println ("task is " + task);
>
>
> // Set Render context to handle url and image locations, and apply to the
> // task
> renderContext = new HTMLRenderContext();
> renderContext.setImageDirectory("image");
> contextMap = new HashMap();
> contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEX T,
> renderContext );
> task.setAppContext( contextMap );
>
> p.println ("task set appcontext");
>
> // This will set the output file location, the format to render to, and
> // apply to the task
> options = new HTMLRenderOption();
> options.setOutputFileName("/var/www/html/smech/repout/test.html ");
> options.setOutputFormat("html");
> task.setRenderOption(options);
>
> try
> {
> p.println ("before task.run");
> task.run();
> }
> catch (Exception e)
> {
> p.println ("An error occured while running the report!");
> //System.err.println("An error occurred while running the report!");
> e.printStackTrace();
> System.exit(-1);
> }
>
> // Destroy the engine and let the garbage collector
> // do its thing
> p.println ("All went well. Closing program!");
> //System.out.println("All went well. Closing program!");
> eng.destroy();
>
> p.close();
> } // try
> catch (Exception eout)
> {
> System.err.println ("Error writing to file");
> } // catch
> } // main
>
> } // BIRT
>
>
> Any suggestions why I can't get past the createRunAndRenderTask , would
> be greatly appreciated.
>
|
|
|
Re: eng.createRunAndRenderTask [message #237102 is a reply to message #236780] |
Tue, 08 May 2007 13:52   |
Eclipse User |
|
|
|
Originally posted by: joannem.smartmech.com
This is a portion of my log file from when I run the report.... It's 1926
lines so I didn't put it all on. I'm not sure what I'm doing wrong!
May 3, 2007 3:48:26 PM
org.eclipse.birt.report.engine.api.impl.ReportEngine setu
pScriptScope
INFO: Error occurs while initialze script scope
org.mozilla.javascript.EvaluatorException: Cannot add a property to a
sealed obj
ect. ()
at
org.mozilla.javascript.DefaultErrorReporter.runtimeError(Def aultError
Reporter.java:76)
at
org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:591)
at
org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:630)
at
org.mozilla.javascript.Context.reportRuntimeError0(Context.j ava:600)
at
org.mozilla.javascript.ScriptableObject.addSlot(ScriptableOb ject.java
:1685)
at
org.mozilla.javascript.ScriptableObject.getSlotToSet(Scripta bleObject
java:1647)
at
org.mozilla.javascript.ScriptableObject.put(ScriptableObject .java:247
)
at org.mozilla.javascript.IdScriptable.put(IdScriptable.java:11 1)
at
org.mozilla.javascript.ScriptableObject.defineProperty(Scrip tableObje
ct.java:1077)
at
org.mozilla.javascript.IdScriptable.defineProperty(IdScripta ble.java:
194)
at
org.mozilla.javascript.ScriptableObject.defineProperty(Scrip tableObje
ct.java:1103)
at
org.mozilla.javascript.IdScriptable.addIdFunctionProperty(Id Scriptabl
e.java:451)
at
org.mozilla.javascript.NativeString.fillConstructorPropertie s(NativeS
tring.java:71)
at
org.mozilla.javascript.IdScriptable.addAsPrototype(IdScripta ble.java:
424)
at org.mozilla.javascript.NativeString.init(NativeString.java:5 7)
at
org.mozilla.javascript.Context.initStandardObjects(Context.j ava:703)
at
org.eclipse.birt.report.engine.api.impl.ReportEngine.setupSc riptScope
(ReportEngine.java:122)
at
org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEng
ine.java:89)
at
org.eclipse.birt.report.engine.api.impl.ReportEngineFactory. createRep
ortEngine(ReportEngineFactory.java:13)
at
org.eclipse.birt.report.engine.api.ReportEngine.<init>(ReportEngine.j
ava:55)
at BIRT.main(BIRT.java:70)
May 3, 2007 3:48:26 PM
org.eclipse.birt.report.engine.api.impl.ReportEngine open
ReportDesign
....... ( a lot more lines in between ) ........
FINE: ReportEngine.openReportDesign:
designName=/home/rci/BIRT2/workspace/netrec
/netrecloc.rptdesign
May 3, 2007 3:48:26 PM
org.eclipse.birt.report.model.metadata.ChoicePropertyType
validateXml
FINE: return internal name for choice Fixed
May 3, 2007 3:48:28 PM
org.eclipse.birt.report.model.metadata.DimensionPropertyT
ype validateXml
FINE: return dimension value with user defined unit 0.075in
May 3, 2007 3:48:28 PM
org.eclipse.birt.report.model.metadata.ChoicePropertyType
validateXml
FINE: return internal name for choice Fixed
May 3, 2007 3:48:28 PM
org.eclipse.birt.report.model.metadata.DimensionPropertyT
ype validateXml
FINE: return dimension value with user defined unit 0.075in
May 3, 2007 3:48:28 PM
org.eclipse.birt.report.model.metadata.ChoicePropertyType
validateXml
FINE: return internal name for choice Fixed
May 3, 2007 3:48:28 PM
org.eclipse.birt.report.model.metadata.DimensionPropertyT
ype validateXml
FINE: return dimension value with user defined unit 0.075in
May 3, 2007 3:48:28 PM
org.eclipse.birt.report.model.metadata.ChoicePropertyType
validateXml
FINE: return internal name for choice Fixed
May 3, 2007 3:48:28 PM
org.eclipse.birt.report.engine.api.impl.ReportEngine crea
teRunAndRenderTask
FINE: ReportEngine.createRunAndRenderTask:
reportRunnable=org.eclipse.birt.repor
t.engine.api.impl.ReportRunnable@1de891b
|
|
|
Re: eng.createRunAndRenderTask [message #237135 is a reply to message #237102] |
Tue, 08 May 2007 14:42   |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Jo-Anne,
Does this just happen with the one report?
Can you create a report that just has a label and try it?
Also what version of BIRT are you using to design the reports?
Jason
Jo-Anne wrote:
> This is a portion of my log file from when I run the report.... It's
> 1926 lines so I didn't put it all on. I'm not sure what I'm doing wrong!
>
>
> May 3, 2007 3:48:26 PM
> org.eclipse.birt.report.engine.api.impl.ReportEngine setu
> pScriptScope
> INFO: Error occurs while initialze script
> scope
> org.mozilla.javascript.EvaluatorException: Cannot add a property to a
> sealed obj
> ect.
> ()
> at
> org.mozilla.javascript.DefaultErrorReporter.runtimeError(Def aultError
> Reporter.java:76)
> at
> org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:591)
> at
> org.mozilla.javascript.Context.reportRuntimeError(Context.ja va:630)
> at
> org.mozilla.javascript.Context.reportRuntimeError0(Context.j ava:600)
> at
> org.mozilla.javascript.ScriptableObject.addSlot(ScriptableOb ject.java
> :1685)
> at
> org.mozilla.javascript.ScriptableObject.getSlotToSet(Scripta bleObject
> java:1647)
> at
> org.mozilla.javascript.ScriptableObject.put(ScriptableObject .java:247
> )
> at
> org.mozilla.javascript.IdScriptable.put(IdScriptable.java:11 1)
> at
> org.mozilla.javascript.ScriptableObject.defineProperty(Scrip tableObje
> ct.java:1077)
> at
> org.mozilla.javascript.IdScriptable.defineProperty(IdScripta ble.java:
> 194)
> at
> org.mozilla.javascript.ScriptableObject.defineProperty(Scrip tableObje
> ct.java:1103)
> at
> org.mozilla.javascript.IdScriptable.addIdFunctionProperty(Id Scriptabl
> e.java:451)
> at
> org.mozilla.javascript.NativeString.fillConstructorPropertie s(NativeS
> tring.java:71)
> at
> org.mozilla.javascript.IdScriptable.addAsPrototype(IdScripta ble.java:
> 424)
> at
> org.mozilla.javascript.NativeString.init(NativeString.java:5 7)
> at
> org.mozilla.javascript.Context.initStandardObjects(Context.j ava:703)
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngine.setupSc riptScope
> (ReportEngine.java:122)
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngine.<init>(ReportEng
> ine.java:89)
> at
> org.eclipse.birt.report.engine.api.impl.ReportEngineFactory. createRep
> ortEngine(ReportEngineFactory.java:13)
> at
> org.eclipse.birt.report.engine.api.ReportEngine.<init>(ReportEngine.j
> ava:55)
> at
> BIRT.main(BIRT.java:70) May
> 3, 2007 3:48:26 PM org.eclipse.birt.report.engine.api.impl.ReportEngine
> open
> ReportDesign ...... ( a lot more lines in between )
> ........
> FINE: ReportEngine.openReportDesign:
> designName=/home/rci/BIRT2/workspace/netrec
> /netrecloc.rptdesign
> May 3, 2007 3:48:26 PM
> org.eclipse.birt.report.model.metadata.ChoicePropertyType
> validateXml
> FINE: return internal name for choice
> Fixed May 3, 2007 3:48:28 PM
> org.eclipse.birt.report.model.metadata.DimensionPropertyT
> ype
> validateXml
> FINE: return dimension value with user defined unit
> 0.075in May 3, 2007 3:48:28 PM
> org.eclipse.birt.report.model.metadata.ChoicePropertyType
> validateXml
> FINE: return internal name for choice
> Fixed May 3, 2007 3:48:28 PM
> org.eclipse.birt.report.model.metadata.DimensionPropertyT
> ype
> validateXml
> FINE: return dimension value with user defined unit
> 0.075in May 3, 2007 3:48:28 PM
> org.eclipse.birt.report.model.metadata.ChoicePropertyType
> validateXml
> FINE: return internal name for choice
> Fixed May 3, 2007 3:48:28 PM
> org.eclipse.birt.report.model.metadata.DimensionPropertyT
> ype
> validateXml
> FINE: return dimension value with user defined unit
> 0.075in May 3, 2007 3:48:28 PM
> org.eclipse.birt.report.model.metadata.ChoicePropertyType
> validateXml
> FINE: return internal name for choice
> Fixed May 3, 2007 3:48:28 PM
> org.eclipse.birt.report.engine.api.impl.ReportEngine crea
> teRunAndRenderTask
> FINE: ReportEngine.createRunAndRenderTask:
> reportRunnable=org.eclipse.birt.repor
> t.engine.api.impl.ReportRunnable@1de891b
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
Re: eng.createRunAndRenderTask [message #237666 is a reply to message #237648] |
Thu, 10 May 2007 15:21  |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Jo-Anne,
That looks proper. Can you try using the Allinone Linux distro to
create a Java Project? If you can get it working in the designer this
may lead to what the issue is in deployment. First create a new project
in the allione and specify it as a java project. Right click on the new
project and modify the build path. Choose libs and add all the libs
under the ReportEngine/lib folder. Next right click on the new Java
Class and enter the code I sent you. Make sure you modify the paths to
yours. After it compiles, right click on the class and choose debug as
Java application. This should bring up the launch configuration. Select
ok and the output should show in the console view.
Alternatively you could use the genReport.bat file and run it. Open the
bat file and modify the classpath and set BIRT_HOME. Verify that the
program runs fine.
Jason
Jo-Anne wrote:
> I'm very new to this, and not so familiar with java, so I'll try to
> explain what I've done.
>
> The BIRT Allinone 2.1.1 download was used for installation. I am using
> a linux system, if that makes a difference. I created a report template
> in BIRT. I added the files from ReportEngine/lib to my classpath. I
> have created a java program, then used the one you sent me to try and
> generate this report.... but can't get past the RunAndRenderTask. This
> java program is called from a background process created with php.
> This is the class path that I'm using.
>
> CLASSPATH=/usr/java142/lib/tools.jar:.:/opt/StyleReportEE/bi n/lax.jar:/opt/Style
>
> ReportEE/lib/design_pro.jar:/opt/StyleReportEE/lib/etools.ja r:/opt/StyleReportEE
>
> /lib/sree_pro.jar:/var/www/html/smech:/home/rci/BIRT2/eclips e/plugins/com.lowagi
>
> e.itext_1.3.0.v20060909-0630/lib/itext-1.3.jar:/home/rci/BIR T2/birt-runtime-2_1_
>
> 1/ReportEngine:/home/rci/BIRT2/birt-runtime-2_1_1/ReportEngi ne/lib/chartengineap
>
> i.jar:/home/rci/BIRT2/birt-runtime-2_1_1/ReportEngine/lib/co m.ibm.icu_3.4.4.1.ja
>
> r:/home/rci/BIRT2/birt-runtime-2_1_1/ReportEngine/lib/common s-cli-1.0.jar:/home/
>
> rci/BIRT2/birt-runtime-2_1_1/ReportEngine/lib/commons-codec- 1.3.jar:/home/rci/BI
>
> RT2/birt-runtime-2_1_1/ReportEngine/lib/coreapi.jar:/home/rc i/BIRT2/birt-runtime
>
> -2_1_1/ReportEngine/lib/dataadapterapi.jar:/home/rci/BIRT2/b irt-runtime-2_1_1/Re
>
> portEngine/lib/dteapi.jar:/home/rci/BIRT2/birt-runtime-2_1_1 /ReportEngine/lib/en
>
> gineapi.jar:/home/rci/BIRT2/birt-runtime-2_1_1/ReportEngine/ lib/flute.jar:/home/
>
> rci/BIRT2/birt-rutnime-2_1_1/ReportEngine/lib/js.jar:/home/r ci/BIRT2/birt-runtim
>
> e-2_1_1/ReportEngine/lib/modelapi.jar:/home/rci/BIRT2/birt-r untime-2_1_1/ReportE
>
> ngine/lib/org.eclipse.emf.common_2.2.0.v200606051102.jar:/ho me/rci/BIRT2/birt-ru
>
> ntime-2_1_1/ReportEngine/lib/org.eclipse.emf.ecore_2.2.0.v20 0606051102.jar:/home
>
> /rci/BIRT2/birt-runtime-2_1_1/ReportEngine/lib/org.eclipse.e mf.ecore.xmi_2.2.0.v
>
> 200606051102.jar:/home/rci/BIRT2/birt-runtime-2_1_1/ReportEn gine/lib/sac.jar:/ho
>
> me/rci/BIRT2/birt-runtime-2_1_1/ReportEngine/lib/scriptapi.j ar:/home/rci/BIRT2/e
>
> clipse/plugins:/opt/sybase/SYBSsa9/java/jodbc.jar:
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04713 seconds