IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Jasper Discussion :

[JAVA] Erreur lors de la génération du rapport


Sujet :

Jasper

  1. #1
    Membre actif
    Profil pro
    100
    Inscrit en
    Juillet 2007
    Messages
    585
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : 100

    Informations forums :
    Inscription : Juillet 2007
    Messages : 585
    Points : 270
    Points
    270
    Par défaut [JAVA] Erreur lors de la génération du rapport
    Bonjour,

    J'aimerais créer un rapport avec JasperReports mais j'obtiens une erreur lors de cette instruction :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    JasperDesign design = JRXmlLoader.load("/Jasper/liste.jrxml");
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
    at ssca.presentation.exportation.GeneratePDF.createPDF(GeneratePDF.java:40)
    at ssca.presentation.membre.GUIMembres.genererPDF(GUIMembres.java:685)
    at ssca.presentation.membre.GUIMembres.actionPerformed(GUIMembres.java:563)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    J'imagine qu'il me manque qqch, mais quoi ?

    Qqun a-t-il une idée ?
    Merci d'avance

  2. #2
    Membre régulier
    Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Décembre 2006
    Messages
    156
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Décembre 2006
    Messages : 156
    Points : 110
    Points
    110
    Par défaut
    Il manque la librairie "Digester", tu peux la trouver sur:

    http://commons.apache.org/

  3. #3
    Rédacteur
    Avatar de JauB
    Homme Profil pro
    Freelancer
    Inscrit en
    Octobre 2005
    Messages
    1 792
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Maroc

    Informations professionnelles :
    Activité : Freelancer
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Octobre 2005
    Messages : 1 792
    Points : 2 914
    Points
    2 914
    Par défaut
    +1
    Citation Envoyé par Nico820 Voir le message
    Il manque la librairie "Digester", tu peux la trouver sur:

    http://commons.apache.org/
    Mes articles, Mon Blog

    Rubrique Jasper/iReport :
    ------- Forum Jasper --------
    ----- FAQ Jasper/iReport -----


  4. #4
    Membre actif
    Profil pro
    100
    Inscrit en
    Juillet 2007
    Messages
    585
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : 100

    Informations forums :
    Inscription : Juillet 2007
    Messages : 585
    Points : 270
    Points
    270
    Par défaut
    Merci, il manquait bien plusieures librairies.

    Si jamais, je les ai toutes trouvé dans le dossier "lib" de IReport

    Merci pour votre aide

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    238
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2002
    Messages : 238
    Points : 125
    Points
    125
    Par défaut Appel des rapports en java ...
    bonjour,

    je suis bloqué à un niveau dont tu connais probblement une solution !
    Comment fais-tu pour faire appel aux rapports en java ?

    Merci pour to aide

  6. #6
    Membre actif
    Profil pro
    100
    Inscrit en
    Juillet 2007
    Messages
    585
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations professionnelles :
    Activité : 100

    Informations forums :
    Inscription : Juillet 2007
    Messages : 585
    Points : 270
    Points
    270
    Par défaut
    Hello,

    Ce tuto devrait faire l'affaire ...
    http://ericreboisson.developpez.com/...er-report/pdf/

  7. #7
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    238
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2002
    Messages : 238
    Points : 125
    Points
    125
    Par défaut
    ok,merci,
    je suis en train de télécharger Eclispe
    je réviendrai probablement à la charge,
    dés que j'aurai testé ce qu'il y a dans le tuto du lien ci dessus.
    Car je n'y connais par grand chose en JAVA

  8. #8
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    238
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2002
    Messages : 238
    Points : 125
    Points
    125
    Par défaut
    Re,
    j'ai bien installer Java (+version française)
    Ensuite :
    Création du projet et de la classe "GeneratePDF"
    mais j'ai un soucis au niveau de l'import des classes
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    import net.sf.jasperreports.engine.JRException;
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.engine.xml.JRXmlLoader;
     
    import com.mysql.jdbc.Driver;
    Il semble ne pas les trouver

  9. #9
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    238
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2002
    Messages : 238
    Points : 125
    Points
    125
    Par défaut
    Oups, de ma faute, j'avais oublié "le ADD des JAR

  10. #10
    Membre habitué
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    238
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2002
    Messages : 238
    Points : 125
    Points
    125
    Par défaut
    J'avance
    j'ai modifié le code de ma classe pour qu'il se conencte via ODBC
    et il génère bien mon PDF si j'exécute ma classe.

    Maintenant j'aimerais afficher à lécran un POPUP qui permet de choisir si on veut ouvrir ou télécharger le fichier...
    j'ai donc modifié le code,mais j'ai un problème au niveau de cette ligne là

    "FacesContext context = FacesContext.getCurrentInstance();"

    j'ai un "IMPORT" qui manque, mais lequel ?

    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
     
    import java.sql.*;
    //import java.sql.Connection;
    //import java.sql.DriverManager;
    //import java.sql.SQLException;
    import java.util.HashMap;
    import java.util.Map;
    import net.sf.jasperreports.engine.JRException;
    import net.sf.jasperreports.engine.JasperCompileManager;
    import net.sf.jasperreports.engine.JasperExportManager;
    import net.sf.jasperreports.engine.JasperFillManager;
    import net.sf.jasperreports.engine.JasperPrint;
    import net.sf.jasperreports.engine.JasperReport;
    import net.sf.jasperreports.engine.design.JasperDesign;
    import net.sf.jasperreports.engine.xml.JRXmlLoader;
    import java.lang.Object;
     
    //import com.mysql.jdbc.Driver;
     
    public class GeneratePDF {
     
        public static void main(String[] args) {
     
            // - Paramètres de connexion à la base de données
            String login = "prov_work";
            String password = "prov_work";
            Connection con =null;
            //
            try 
            {
            	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            } 
            catch(java.lang.ClassNotFoundException e) 
            {
            	System.err.print("ClassNotFoundException (try): ");
            	System.err.println(e.getMessage());
            }
           	String dataSourceName = "DB_ODI";
           	String url = "jdbc:odbc:" + dataSourceName;
           	//
           	try 
           	{
           		con = DriverManager.getConnection(url,login,password) ;
       		}
            	catch(SQLException sqle) 
       		{
            	System.err.println(sqle.getMessage());
            }
            //
            try 
            {
                // - Chargement et compilation du rapport
                JasperDesign jasperDesign = JRXmlLoader.load("D:\\Z_A_MOI\\ODI\\utils\\jasper_ireport\\iReport-1.2.5\\iReport-1.2.5\\rep1.jrxml");
                JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
                // - Paramètres à envoyer au rapport
                Map parameters = new HashMap();
                //parameters.put("Titre", "Titre");
                // - Execution du rapport
                JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, con);
                // - Création du rapport au format PDF
                //JasperExportManager.exportReportToPdfFile(jasperPrint, "D:\\Z_A_MOI\\ODI\\utils\\jasper_ireport\\iReport-1.2.5\\iReport-1.2.5\\rep1.pdf");
     
     
                byte[] bytes = JasperExportManager.exportReportToPdf(jasperPrint);
        		FacesContext context = FacesContext.getCurrentInstance();
        		HttpServletResponse response = (HttpServletResponse) context
        				.getExternalContext().getResponse();
     
    /**************************************** 
    Pour afficher une boîte de dialogue pour enregistrer le fichier sous
    le nom rapport.pdf
     ****************************************/
        		response.addHeader("Content-disposition",
        				"attachment;filename=rapport.pdf");
        		response.setContentLength(bytes.length);
        		response.getOutputStream().write(bytes);
        		response.setContentType("application/pdf");
        		context.responseComplete();
     
     
            } catch (JRException e) 
            {
     
                        e.printStackTrace();
            } finally {
                try {
                     con.close();
                    } catch (SQLException e) {
     
                            e.printStackTrace();
                    }
            }
     
        }
    }

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Checkstyle] [Maven]Erreur lors de la génération d'un rapport
    Par alex77722 dans le forum Qualimétrie
    Réponses: 1
    Dernier message: 23/08/2012, 10h27
  2. Réponses: 0
    Dernier message: 14/09/2011, 00h32
  3. Réponses: 1
    Dernier message: 07/09/2010, 11h00
  4. Réponses: 2
    Dernier message: 30/06/2010, 11h20
  5. Réponses: 7
    Dernier message: 02/08/2006, 08h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo