Erreur ?!?

zut69 Messages postés 354 Date d'inscription lundi 26 juillet 2004 Statut Membre Dernière intervention 26 juin 2012 - 9 juin 2008 à 19:16
zut69 Messages postés 354 Date d'inscription lundi 26 juillet 2004 Statut Membre Dernière intervention 26 juin 2012 - 16 juin 2008 à 21:01
Bonsoir,
J'essaie d'envoyer des informations par POST en Java à un fichier php, j'ai écrit mon code, mais je ne trouve pas ce qui ne va pas, j'utilise la librairie HTTPClient d'Apache.
Voici l'erreur retournée par la console, suivie de ma source:

Exception in thread "AWT-EventQueue-1" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.apache.commons.httpclient.HttpMethodBase.<clinit>(Unknown Source)
    at cryptage.Applet_TM.actionPerformed(Applet_TM.java:61)
    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.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)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 26 more

Code Java:

package cryptage;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.methods.multipart.*;

public class Applet_TM extends JApplet implements ActionListener
{
    JButton button1 = new JButton();
    boolean successful=true;
    JOptionPane jop = new JOptionPane();
 
    public void init()
    {
        button1.setLabel("Parcourir...");
        this.getContentPane().add(button1, BorderLayout.SOUTH);
        button1.setBounds(20,200,98,30);
        button1.addActionListener(this);
    }
 
 
    public void actionPerformed(ActionEvent ae)
    {
        if(ae.getSource().equals(button1))
        {
            String contenu = null;
            String contenu_crypte = null;
            String temp = null;
            int i = 0; //nb de lignes
           
            try
            {
                    JFileChooser fileDialog = new JFileChooser();
                    int retour = fileDialog.showSaveDialog(this); // 1 si aucun fichier soumis, sinon 0
                    fileDialog.show( );
                    System.out.println(fileDialog.getSelectedFile());
                    FileReader fichier = new FileReader(fileDialog.getSelectedFile());
                    BufferedReader br = new BufferedReader(fichier);
                    temp = new String();
                    contenu = new String();
                   
                    while((temp = br.readLine()) != null)
                    {
                        contenu = contenu + "\n" + temp;
                        i++;
                        //System.out.println(i+": "+contenu);
                    }
                    System.out.println(contenu);
                   
                    /* Cryptage */
                    contenu_crypte = contenu;
                    /* Fin Cryptage */

                    PostMethod methodePost = new PostMethod("http://www.monsite.com/index.php");

                    Part[] parts={   new StringPart("nom", "test"),
                                     new StringPart("fichier", contenu_crypte) };
                   
                    methodePost.setRequestEntity(new MultipartRequestEntity(parts, methodePost.getParams()) );
                   
                    HttpClient client = new HttpClient();
                    client.executeMethod(methodePost);
                   
                    //affiche la réponse du serveur
                    System.out.println(new String(methodePost.getResponseBody()));
            }
            catch(IOException e)
            {
                System.out.println("Erreur IOException!");
                e.printStackTrace(); // affiche les infos sur l erreur
            }
        }
    }
}

5 réponses

boumarsel Messages postés 298 Date d'inscription jeudi 12 juin 2003 Statut Membre Dernière intervention 9 juillet 2008 1
13 juin 2008 à 17:10
Bonjour,

Je pense qu'il te manque le jar commons-logging-1.0.4.jar

Essaie de vérifier stp
0
zut69 Messages postés 354 Date d'inscription lundi 26 juillet 2004 Statut Membre Dernière intervention 26 juin 2012 1
13 juin 2008 à 19:16
Merci pour ta réponse,
J'ai esssayé, mais il me dit logging...jar is never used en warning, et meme en testant ça passe pas!
Une autre idée?
T'aurais msn si jamais? Parce que j'aurais vraiment besoin d'aide pour ça et ce serait plus simple.
Ou si t'as une autre idée...
0
boumarsel Messages postés 298 Date d'inscription jeudi 12 juin 2003 Statut Membre Dernière intervention 9 juillet 2008 1
16 juin 2008 à 14:29
0
boumarsel Messages postés 298 Date d'inscription jeudi 12 juin 2003 Statut Membre Dernière intervention 9 juillet 2008 1
16 juin 2008 à 15:23
Si tu testes avec Eclipse essaie plutôt avec run as au lieu de debug as, le debugage crée des problèmes des fois liés au class loader
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
zut69 Messages postés 354 Date d'inscription lundi 26 juillet 2004 Statut Membre Dernière intervention 26 juin 2012 1
16 juin 2008 à 21:01
Merci de ta réponse,

J'y avais pensé aussi et téléchargé exactement la meme lib que tu mets ici, mais c'est pas ça... Toujours l'erreur...
0
Rejoignez-nous