Précédent   Forum des professionnels en informatique > Logiciels > Solutions d'entreprise > Business Intelligence > Jasper
Jasper Forum d'entraide sur Jasper Reports. Avant de poster --> FAQ Jasper, Tutoriels Jasper
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 04/06/2007, 13h51   #1
Membre habitué
 
Inscription : septembre 2005
Messages : 747
Détails du profil
Informations forums :
Inscription : septembre 2005
Messages : 747
Points : 132
Points : 132
Par défaut [Java] Exception lors du chargement d'un fichier .jrxml

Bonjour,

j'ai généré le fichier .jrxml suivant à l'aide de IReport :
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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
 
<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
		 name="classic"
		 columnCount="1"
		 printOrder="Vertical"
		 orientation="Portrait"
		 pageWidth="595"
		 pageHeight="842"
		 columnWidth="535"
		 columnSpacing="0"
		 leftMargin="30"
		 rightMargin="30"
		 topMargin="20"
		 bottomMargin="20"
		 whenNoDataType="NoPages"
		 isTitleNewPage="false"
		 isSummaryNewPage="false">
	<property name="ireport.scriptlethandling" value="0" />
	<property name="ireport.encoding" value="UTF-8" />
	<import value="java.util.*" />
	<import value="net.sf.jasperreports.engine.*" />
	<import value="net.sf.jasperreports.engine.data.*" />
 
	<queryString><![CDATA[SELECT     [Seq.Closed By], [Close Date & Time]
FROM         _SMDBA_.Incident
WHERE     ([Close Date & Time] BETWEEN '20070520 00:00:00.000' AND '20070523 23:59:59.999')
ORDER BY [Seq.Closed By]]]></queryString>
 
	<field name="Seq.Closed By" class="java.lang.Integer"/>
	<field name="Close Date & Time" class="java.sql.Timestamp"/>
 
		<background>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</background>
		<title>
			<band height="50"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="61"
						y="5"
						width="412"
						height="40"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="staticText"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Center">
						<font size="30"/>
					</textElement>
				<text><![CDATA[Classic Report Template]]></text>
				</staticText>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="48"
						width="534"
						height="0"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="3"
						width="534"
						height="0"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</title>
		<pageHeader>
			<band height="10"  isSplitAllowed="true" >
				<line direction="BottomUp">
					<reportElement
						x="0"
						y="9"
						width="535"
						height="0"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
			</band>
		</pageHeader>
		<columnHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnHeader>
		<detail>
			<band height="50"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="127"
						y="2"
						width="398"
						height="17"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="textField"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font size="12"/>
					</textElement>
				<textFieldExpression   class="java.lang.Integer"><![CDATA[$F{Seq.Closed By}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement
						x="0"
						y="2"
						width="267"
						height="17"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="staticText"
						positionType="Float"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[Seq.Closed By]]></text>
				</staticText>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="127"
						y="21"
						width="398"
						height="17"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="textField"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font size="12"/>
					</textElement>
				<textFieldExpression   class="java.sql.Timestamp"><![CDATA[$F{Close Date & Time}]]></textFieldExpression>
				</textField>
				<staticText>
					<reportElement
						x="0"
						y="21"
						width="267"
						height="17"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="staticText"
						positionType="Float"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font size="12"/>
					</textElement>
				<text><![CDATA[Close Date & Time]]></text>
				</staticText>
			</band>
		</detail>
		<columnFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnFooter>
		<pageFooter>
			<band height="27"  isSplitAllowed="true" >
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="325"
						y="4"
						width="170"
						height="19"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="textField"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement textAlignment="Right">
						<font size="10"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="499"
						y="4"
						width="36"
						height="19"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="textField"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font size="10"/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>
				</textField>
				<line direction="TopDown">
					<reportElement
						x="0"
						y="3"
						width="535"
						height="0"
						key="line"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="1"
						y="6"
						width="209"
						height="19"
						forecolor="#000000"
						backcolor="#FFFFFF"
						key="textField"/>
					<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
					<textElement>
						<font size="10"/>
					</textElement>
				<textFieldExpression   class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>
				</textField>
			</band>
		</pageFooter>
		<summary>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</summary>
</jasperReport>
La base de données que j'utilise est sql-server
La classe java est la 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
 
import java.sql.*;
 
import java.util.Map;
import java.util.HashMap;
 
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JRException;
 
import sun.jdbc.odbc.JdbcOdbcDriver;
 
 
public class Test{
	public static void main(String arg[]){
		//Parametre de connexion a la base de données
		String url="jdbc:odbc:MAGIC";
    String login = "root";
    String password = "root";
    Connection connection = null;
		try{
			Driver monDriver = new JdbcOdbcDriver();
      DriverManager.registerDriver(monDriver);
			connection=DriverManager.getConnection(url,login,password);
 
			//Chargement et compilation du rapport
			JasperDesign jasperDesign = JRXmlLoader.load("D:\\Documents and Settings\\pierre\\Desktop\\classic.jrxml");
			JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
 
			//Parametre à envoyer au rapport
			Map parameters = new HashMap();
			parameters.put("Titre", "Titre");
 
			//Execution du rapport
			JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, connection);
 
			//Creation du rapport au format PDF
			JasperExportManager.exportReportToPdfFile(jasperPrint, "D:\\Documents and Settings\\pierre\\Desktop\\classic.pdf");
 
		}catch(JRException e){
			e.printStackTrace();
		}catch(SQLException e){
			e.printStackTrace();
		}finally{
			try{
				connection.close();
			}catch(SQLException e){
				e.printStackTrace();
			}
		}
	}
}
Je ne comprends pas pourquoi toutes ces exceptions sont générées lorsque le chargement du fichier jrxml a lieu.
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
 
4 juin 2007 13:56:25 org.apache.commons.digester.Digester fatalError
GRAVE: Parse Fatal Error at line 32 column 27: The entity name must immediately follow the '&' in the entity reference.
org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.commons.digester.Digester.parse(Digester.java:1647)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:239)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:168)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)
	at Test.main(Test.java:31)
net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
	at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:243)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:226)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:214)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:168)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)
	at Test.main(Test.java:31)
Caused by: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanAttributeValue(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanAttribute(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.apache.commons.digester.Digester.parse(Digester.java:1647)
	at net.sf.jasperreports.engine.xml.JRXmlLoader.loadXML(JRXmlLoader.java:239)
	... 5 more
Merci
Premium est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/06/2007, 14h09   #2
Membre confirmé
 
Inscription : juillet 2002
Messages : 239
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : juillet 2002
Messages : 239
Points : 200
Points : 200
Salut,

Dans ton fichier jasper tu as la ligne suivante :
Code :
1
2
 
<field name="Close Date & Time" class="java.sql.Timestamp"/>
Il vaut mieux utiliser les caractères spéciaux HTML pour le & : &amp;.

Essaye et dis si ça compile
sleepy2002 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/06/2007, 15h36   #3
Membre habitué
 
Inscription : septembre 2005
Messages : 747
Détails du profil
Informations forums :
Inscription : septembre 2005
Messages : 747
Points : 132
Points : 132
Ça fonctionne.
Merci
Premium est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/06/2007, 16h39   #4
Membre Expert
 
Inscription : janvier 2007
Messages : 1 243
Détails du profil
Informations personnelles :
Âge : 35
Localisation : France, Paris (Île de France)

Informations forums :
Inscription : janvier 2007
Messages : 1 243
Points : 1 416
Points : 1 416
N'oublie pas le tag
chtig est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/06/2007, 13h48   #5
Membre confirmé
 
Inscription : juillet 2002
Messages : 239
Détails du profil
Informations personnelles :
Localisation : France

Informations forums :
Inscription : juillet 2002
Messages : 239
Points : 200
Points : 200
Code :
1
2
 
Caused by: java.io.IOException: Cannot run program "javac": CreateProcess error=2, Le fichier spécifié est introuvable
Vérifie que le répertoire bin de ton JDK est bien dans ta variable d'environnement PATH. (Terminal -> java -version et si tu n'as pas d'erreur c'est bon)
sleepy2002 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/03/2011, 11h07   #6
Invité de passage
 
Inscription : mars 2011
Messages : 2
Détails du profil
Informations forums :
Inscription : mars 2011
Messages : 2
Points : 1
Points : 1
Bonjour moi aussi j'ai eu les même problèmes et je les ai résolu en ajoutant ces fichiers .jar à la bibliothèque d'Eclipse dossier "bib":commons-javaflow-20060411.jar et jdt-compiler-3.1.1.jar
j’espère que ça aide des prochains débutants
estudianteisi est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 07h39.


 
 
 
 
Partenaires

Hébergement Web