Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > BIRT
BIRT Forum d'entraide sur BIRT (Business Intelligence and Reporting Tools). Avant de poster --> FAQ BIRT,Tutoriels BIRT
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 12/08/2007, 18h48   #1
Invité de passage
 
Inscription : juillet 2007
Messages : 26
Détails du profil
Informations forums :
Inscription : juillet 2007
Messages : 26
Points : 1
Points : 1
Par défaut [débutante]Intégrer un rapport dans l'appli

Bonjour, en exécutant ce bout de code:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
 
import java.util.HashMap;
import java.util.logging.Level;
 
 
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLActionHandler;
import org.eclipse.birt.report.engine.api.HTMLEmitterConfig;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
 
public class executionBirt {
private static Object object;
static void executionBirt() throws EngineException
{
HashMap<String,Integer> parameters = new HashMap<String,Integer>();
 
String name = "Top Count";
Integer pvalue = new Integer(4);
parameters.put(name, pvalue);
 
IReportEngine engine=null;
// EngineConfig config = null;
 
EngineConfig config = new EngineConfig();
try{
 
//Configure the Engine and start the Platform
config = new EngineConfig();
config.setEngineHome("C:/birtruntime/birt-runtime-2_1_2/ReportEngine");
//set log config using ( null, Level ) if you do not want a log file
config.setLogConfig("c:/birt/logs",Level.FINE);
 
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory)Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
engine.changeLogLevel(Level.WARNING);
 
}catch( Exception ex){
ex.printStackTrace();
}
 
//Configure the emitter to handle actions and images
HTMLEmitterConfig emitterConfig = new HTMLEmitterConfig();
emitterConfig.setActionHandler( new HTMLActionHandler());
HTMLServerImageHandler imageHandler = new HTMLServerImageHandler();
emitterConfig.setImageHandler(imageHandler);
object = config.getEmitterConfigs().put("html",emitterConfig); //$NON-NLS-1$
 
IReportRunnable design = null;
 
//Open the report design
design = engine.openReportDesign("new_report_2.rptdesign");
 
//Create task to run and render the report,
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
 
//Set Render context to handle url and image locataions
HTMLRenderContext renderContext = new HTMLRenderContext();
//Set the Base URL for all actions
renderContext.setBaseURL("http://localhost/");
//Tell the Engine to prepend all images with this URL - Note this requires using the HTMLServerImageHandler
renderContext.setBaseImageURL("http://localhost/myimages");
//Tell the Engine where to write the images to
renderContext.setImageDirectory("C:/xampplite/htdocs/myimages");
//Tell the Engine what image formats are supported. Note you must have SVG in the string
//to render charts in SVG.
renderContext.setSupportedImageFormats("JPG;PNG;BMP;SVG");
HashMap<String, HTMLRenderContext> contextMap = new HashMap<String, HTMLRenderContext>();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT, renderContext);
task.setAppContext(contextMap );
//Set parameters for the report
task.setParameterValues(parameters);
//Alternatively set each seperately
//task.setParameterValue("Top Count", new Integer(12));
task.validateParameters();
 
//Add a scriptable object, which will allow the report developer to put
//script in the report that references this Java object. eg in script
//pFilter.myjavamethod()
//ProcessFilter pf = new ProcessFilter();
//task.addScriptableJavaObject("pFilter", pf);
 
//Set rendering options - such as file or stream output,
//output format, whether it is embeddable, etc
HTMLRenderOption options = new HTMLRenderOption();
 
//Remove HTML and Body tags
//options.setEmbeddable(true);
 
//Set ouptut location
options.setOutputFileName("C:/test/2.1/output.html");
 
//Set output format
options.setOutputFormat("html");
task.setRenderOption(options);
 
//run the report and destroy the engine
//Note - If the program stays resident do not shutdown the Platform or the Engine
task.run();
task.close();
engine.shutdown();
Platform.shutdown();
System.out.println("Finished");
}
/**
* @param args
*/
public static void main(String[] args) {
try
{
executionBirt();
}
catch ( Exception e )
{
e.printStackTrace();
}
}
 
}
J'ai l'erreur suivante
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
org.eclipse.birt.core.exception.BirtException: $NO-RB$ Cant startup the OSGI framework
	at org.eclipse.birt.core.framework.Platform.startup(Platform.java:89)
	at executionBirt.executionBirt(executionBirt.java:42)
	at executionBirt.main(executionBirt.java:120)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:79)
Caused by: org.eclipse.birt.core.exception.BirtException: $NO-RB$ Could not start the Framework - C:/birtruntime/birt-runtime-2_1_2/ReportEngineC:/birtruntime/birt-runtime-2_1_2/ReportEngine
	at org.eclipse.birt.core.framework.osgi.OSGILauncher.startup(OSGILauncher.java:87)
	at org.eclipse.birt.core.framework.Platform.startup(Platform.java:77)
	... 7 more
java.lang.NullPointerException
	at executionBirt.executionBirt(executionBirt.java:61)
	at executionBirt.main(executionBirt.java:120)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:79)
sachant ke j'ai installer l'eclipse all in one (birt intégré).
A l'aide svp
nounowa est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 13/08/2007, 10h48   #2
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Bonjour,

Ca ressemble a du BIRT executé en RCP. Pour cela, il te faut lire la documentation du site BIRT correspondante : http://wiki.eclipse.org/BIRT/FAQ/Dep...n_.28RCP.29.3F
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/08/2007, 18h20   #3
Invité de passage
 
Inscription : juillet 2007
Messages : 26
Détails du profil
Informations forums :
Inscription : juillet 2007
Messages : 26
Points : 1
Points : 1
J'ai vraiment besoin d'aide
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import java.util.HashMap;
import java.util.logging.Level;
 
import org.eclipse.birt.core.exception.BirtException;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLActionHandler;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.data.oda.jdbc.*;
import org.eclipse.birt.report.engine.api.RenderOption;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.HTMLServerImageHandler;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
 
public class Example {
 
 public Example() {
  System.out.println("-------------Inside constructor");
 }
 
 public static void main(String[] args) {
  System.out.println("-------------Inside main method");
  Example reportRunner = new Example();
  reportRunner.runReport();
 }
 
 private void runReport() {
  System.out.println("Inside Report Generation");
  IReportEngine engine = null;
  IRunAndRenderTask task = null;
 
  try {
   EngineConfig config = new EngineConfig();
   IReportRunnable design = null;
 
   config.setEngineHome("birt-runtime-2_2_0/ReportEngine");
   //config.setLogConfig("C:/ProgramFiles/birt/log", Level.ALL);
 
   try {
	Platform.startup( config );
} catch (BirtException e1) {
	// TODO Auto-generated catch block
	e1.printStackTrace();
}
   IReportEngineFactory factory = (IReportEngineFactory) Platform
     .createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
   System.out.println(" ---FACTORY CREATED");
 
   engine = factory.createReportEngine( config );
   System.out.println(" ---REPORT ENGINE CREATED");
   engine.changeLogLevel( Level.WARNING );
 
   //Open the report design
   try {
	design = engine.openReportDesign("C:/Documents and Settings/Nouha.NOUNOWA-22C7099/workspace/Gestion_Parc/new_report_2.rptdesign");
} catch (EngineException e1) {
	// TODO Auto-generated catch block
	e1.printStackTrace();
}
   System.out.println(" ------------ DESIGN CREATED");
 
   //Create task to run and render the report,
   task = engine.createRunAndRenderTask(design);
   System.out.println(" ------------ TASK CREATED");
 
   HTMLRenderContext renderContextHTML = new HTMLRenderContext();
// PDFRenderContext renderContextPDF = new PDFRenderContext();
 
 //renderContextHTML.setImageDirectory("c:/nou");
 System.out.println("Image Directory :"+renderContextHTML.getImageDirectory());
// renderContextHTML.setSupportedImageFormats("JPG;PNG;BMP;SVG");
 
 HashMap contextMap = new HashMap();
 contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,renderContextHTML);
// contextMap.put(EngineConstants.APPCONTEXT_PDF_RENDER_CONTEXT,renderContextPDF);
 
 task.setAppContext(contextMap);
 
// set rendering option
// PDFRenderOption optionPDF = new PDFRenderOption();
 HTMLRenderOption optionHTML = new HTMLRenderOption();
 
 optionHTML.setOutputFileName("./html");
 optionHTML.setOutputFormat("html");
 task.setRenderOption(optionHTML);
 try {
 	task.run();
 	System.out.println("-- Successfully to generate pdf --");
 } catch (Exception e) {
 	e.printStackTrace();
 }}
   finally {
   task.close();
   engine.shutdown();
   Platform.shutdown();
  }
  System.out.println("Finished");
 }
}
me génère erreur suivante
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
 
 
 
 
 
 
 
 
 
 
 
-------------Inside main method
-------------Inside constructor
Inside Report Generation
14 août 2007 18:07:30 org.eclipse.birt.report.data.oda.sampledb.SampledbPlugin start
INFO: Sampledb plugin starts up. Current startCount=0
14 août 2007 18:07:30 org.eclipse.birt.report.data.oda.sampledb.SampledbPlugin init
INFO: Creating Sampledb database at location C:\DOCUME~1\NOUHA~1.NOU\LOCALS~1\Temp\/BIRTSampleDB_1187107650859_1035079
 ---FACTORY CREATED
 ---REPORT ENGINE CREATED
 ------------ DESIGN CREATED
 ------------ TASK CREATED
Image Directory :null
14 août 2007 18:07:34 org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadAndRegisterDriver
ATTENTION: Failed to load JDBC driver class: oracle.jdbc.driver.OracleDriver
14 août 2007 18:07:34 org.eclipse.birt.data.engine.odaconsumer.ConnectionManager openConnection
GRAVE: Cannot open connection.
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC Driver class: oracle.jdbc.driver.OracleDriver 
	at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.loadAndRegisterDriver(JDBCDriverManager.java:605)
	at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.doConnect(JDBCDriverManager.java:180)
	at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.getConnection(JDBCDriverManager.java:146)
	at org.eclipse.birt.report.data.oda.jdbc.Connection.connectByUrl(Connection.java:150)
	at org.eclipse.birt.report.data.oda.jdbc.Connection.open(Connection.java:111)
	at org.eclipse.datatools.connectivity.oda.consumer.helper.OdaConnection.open(OdaConnection.java:235)
	at org.eclipse.birt.data.engine.odaconsumer.ConnectionManager.openConnection(ConnectionManager.java:149)
	at org.eclipse.birt.data.engine.executor.DataSource.newConnection(DataSource.java:134)
	at org.eclipse.birt.data.engine.executor.DataSource.open(DataSource.java:121)
	at org.eclipse.birt.data.engine.impl.DataSourceRuntime.openOdiDataSource(DataSourceRuntime.java:214)
	at org.eclipse.birt.data.engine.impl.QueryExecutor.openDataSource(QueryExecutor.java:265)
	at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(QueryExecutor.java:210)
	at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQuery.java:486)
	at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(PreparedDataSourceQuery.java:161)
	at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(PreparedOdaDSQuery.java:142)
	at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.execute(DataRequestSessionImpl.java:423)
	at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:149)
	at org.eclipse.birt.report.engine.data.dte.DteDataEngine.doExecuteQuery(DteDataEngine.java:115)
	at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(AbstractDataEngine.java:178)
	at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery(ExecutionContext.java:1678)
	at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:82)
	at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:61)
	at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:45)
	at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:42)
	at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:45)
	at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:33)
	at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layoutChildren(HTMLPageLM.java:126)
	at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:84)
	at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:90)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:148)
	at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:71)
	at Example.runReport(Example.java:93)
	at Example.main(Example.java:30)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:79)
14 août 2007 18:07:34 org.eclipse.birt.report.engine.data.dte.DteDataEngine doExecuteQuery
GRAVE: Cannot open the connection for the driver: org.eclipse.birt.report.data.oda.jdbc
Cannot load JDBC Driver class: oracle.jdbc.driver.OracleDriver 
-- Successfully to generate pdf --
Finished
malgré que j'ai ajouté le jdbc oda.jar
je sais que cette erreur est fréquente mais j'ai pas trouvé de réponse sur le net.
A l'aide
nounowa est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/08/2007, 14h18   #4
BiM
Modératrice
 
Avatar de BiM
 
Femme
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
Inscription : janvier 2005
Messages : 7 299
Détails du profil
Informations personnelles :
Sexe : Femme
Âge : 26
Localisation : France, Haute Garonne (Midi Pyrénées)

Informations professionnelles :
Activité : Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT

Informations forums :
Inscription : janvier 2005
Messages : 7 299
Points : 8 650
Points : 8 650
Le JAR correspondant à cette classe se nomme : ojdbc14.jar
__________________
__~{@ BiM - Modératrice "Business Intelligence" @}~
Consultante/Formatrice BIRT & Ingénieur Java/J2EE/GWT
___________.~{@ Lapine crétine @}~
BiM est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h33.


 
 
 
 
Partenaires

Hébergement Web