Bonjour,

Quand je génère un rapport Birt sur mon code java, le rapport apparaît bien au bout de plusieurs minute, mais j’obtiens 2 erreurs, j'ignore la cause et encore moins la solution.

voici les 2 erreurs :

14-sept.-2011 0:06:01 org.eclipse.birt.report.data.adapter.impl.ModelAdapter adaptDataSet
ATTENTION: handle type: org.eclipse.birt.report.model.api.OdaDataSetHandle
14-sept.-2011 0:06:04 org.eclipse.birt.report.data.adapter.impl.ModelAdapter adaptDataSet
ATTENTION: handle type: org.eclipse.birt.report.model.api.OdaDataSetHandle
si vous avez une idée, je suis preneur.

voici mon code java :

Edition


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
 
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
 
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.EngineException;
import org.eclipse.birt.report.engine.api.IRenderOption;
import org.eclipse.birt.report.engine.api.IRenderTask;
import org.eclipse.birt.report.engine.api.IReportDocument;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunTask;
import org.eclipse.birt.report.engine.api.RenderOption;
 
/**
* Cette classe permet la génération dans n'importe quel format
* de n'importe quelle édition.
* Il faut d'abord l'instancier, puis on lance le rapport et on
* fait le rendu.
* Si nécessaire, cette classe peut être threadée facilement.
* 
* @author BiM
*
*/
public final class Edition {
private static final String ENGINE_PATH = "C:\\eclipse\\birt-runtime-2_5_2\\ReportEngine";
private static final String REPORT_PATH = "C:\\MesRapports\\";
private static Edition m_Instance = null;
private IReportEngine engine;
 
/**
* Constructeur.
* Il configure le moteur BIRT de sorte à ce qu'il puisse retrouver
* les ressources BIRT mais également les librairies le faisant tourner
* Il est alors démarré avec cette configuration.
* @throws BirtException
*/
private Edition() throws BirtException {
EngineConfig config = new EngineConfig();
config.setBIRTHome(ENGINE_PATH);
Platform.startup(config);
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
engine = factory.createReportEngine(config);
}
 
/**
* Instanciation du service.
* @return l'instance en cours du service
* @throws BirtException
*/
public static synchronized Edition getInstance() throws BirtException {
if (m_Instance == null) {
m_Instance = new Edition();
}
return m_Instance;
}
 
/**
* Génération de l'état.
* @param _input Nom du fichier d'entrée sans l'extension (rptdesign), le fichier de sortie portera le même nom
* @param _langue Locale pour définir la langue de génération du rapport
* @param _parameters Map contenant les paramètres du rapport sous la forme <Nom, Valeur>
* @throws EngineException 
*/
public synchronized void run(String _input, Locale _langue, Map<String, Object> _parameters) throws EngineException {
this.run(_input, _input, _langue, _parameters);
}
 
/**
* Génération de l'état.
* @param _input Nom du fichier d'entrée sans l'extension (rptdesign)
* @param _output Nom du fichier de sortie sans l'extension (rptdocument)
* @param _langue Locale pour définir la langue de génération du rapport
* @param _parameters Map contenant les paramètres du rapport sous la forme <Nom, Valeur>
* @throws EngineException 
*/
public synchronized void run(String _input, String _output, Locale _langue, Map<String, Object> _parameters) throws EngineException {
IRunTask runTask = null;
try {
/* Récupération du rptDesign */
IReportRunnable design = engine.openReportDesign(REPORT_PATH +"rapport\\"+ _input + ".rptdesign");
 
/* Création de la tâche d'éxécution */
runTask = engine.createRunTask(design);
 
/* Paramètres */
runTask.setParameterValues(_parameters);
 
/* Langue */
runTask.setLocale(_langue);
 
/* Exécution */
runTask.run(REPORT_PATH +"rptdoc\\"+ _output + ".rptdocument");
}
finally {
if (runTask != null) {
runTask.close();
}
}
}
 
/**
* Rendu de l'état.
* @param _input Nom du fichier d'entrée sans l'extension (rptdocument)
* @param _format Format de sortie du fichier
* @throws EngineException
*/
public synchronized void render(String _input, String _format) throws EngineException {
this.render(_input, _input, _format);
}
 
/**
* Rendu de l'état.
* @param _input Nom du fichier d'entrée sans l'extension (rptdocument), le fichier de sortie portera le même nom.
* @param _output Nom du fichier de sortie sans l'extension (format final)
* @param _format Format de sortie du fichier
* @throws EngineException
*/
public synchronized void render(String _input, String _output, String _format) throws EngineException {
IReportDocument doc = null;
IRenderTask renderTask = null;
try {
/* Création des options de rendu */
IRenderOption option = new RenderOption();
 
/* Fichier et format de sortie */
option.setOutputFileName(REPORT_PATH + _format +"\\"+ _output + "." + _format);
option.setOutputFormat(_format);
 
/* Récupération du rptDocument */
doc = engine.openReportDocument(REPORT_PATH +"rptdoc" +"\\"+ _input + ".rptdocument");
 
/* Rendu */
renderTask = engine.createRenderTask(doc);
 
/* Chargement des options de rendu */
renderTask.setRenderOption(option);
 
/* Création du fichier de rendu */
renderTask.render();
}
finally {
if (renderTask != null) {
renderTask.close();
}
if (doc != null) {
doc.close();
}
}
}
 
/**
* Permet de détruire le moteur de façon propre.
*/
public void destructeur() {
engine.destroy();
Platform.shutdown();
}


Main


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern; 
import java.util.regex.Matcher; 
import java.util.*;
 
import org.eclipse.birt.core.exception.BirtException;
 
public class listRepertoire
{
 
public static void main (String[]args) throws IOException
{
Scanner sc = new Scanner(System.in);
 
String path= "c://MesRapports//rapport"; 
String filtre = "." +".*\\.(rptdesign)$"; 
 
 
Pattern p = Pattern.compile(filtre); 
String [] s = new File(path).list(); 
List<String> listeFichiers = new ArrayList<String>(); 
 
 
 
System.out.println("____ Liste des rapports : ____");
for (int i=0; i<s.length;i=i+1) 
{ 
Matcher m = p.matcher(s[i]); 
if ( m.matches()) 
{ 
listeFichiers.add(s[i]); 
System.out.println(s[i].substring(0, s[i].length()-10));
} 
} 
 
 
System.out.println("---- Choissisez un rapport : ----");
String rapport = sc.nextLine(); 
System.out.println("---- Choissisez le format (pdf,doc,xls,...) : ----");
String format = sc.nextLine();
System.out.println("---- Choissisez un nom : ----");
String nom = sc.nextLine();
 
System.out.println("____ En cours de création du rapport ____");
try
{
Edition ed = Edition.getInstance();
ed.run(rapport+""+langue, Locale.FRENCH, new HashMap<String, Object>());
ed.render(rapport, nom, format);
ed.destructeur();
 
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler c:/MesRapports/"+format+"/"+nom+"."+format); 
 
 
}
catch (BirtException e)
{
e.printStackTrace();
System.out.println("!!!!! Erreur:BirtException !!!!!");
}
 
 
System.out.println("______ FINIS ______");
 
}
 
 
 
}