Partage
  • Partager sur Facebook
  • Partager sur Twitter

java.lang.NoClassDefFoundError: Could not initialize class

Sujet résolu
    20 juillet 2012 à 11:53:43

    Bonjour à tous,
    Je travaille sur une application de signature électronique et quand je l’exécute sur netbeans je suis redirigée vers l'exception suivante : Exception in thread "Thread-8" java.lang.NoClassDefFoundError:

    Le message complet sur le output run est:

    run:
    log4j:WARN No appenders could be found for logger (com...........MainForm).
    log4j:WARN Please initialize the log4j system properly.
    License about to read: .......
    License is available: chemin\..\file.key
    Exception in thread "Thread-8" java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.ComThread
    at .....java
    at ....java:103)
    at ....java:25)
    at ...java:15)
    at java.lang.Thread.run(Thread.java:619)


    Merci d'avance pour toute l'aide que vous pourrez m'apporter!!
    • Partager sur Facebook
    • Partager sur Twitter
      21 juillet 2012 à 16:18:25

      Je ne vois pas la source réelle de ton probleme mais ja te suggère de coder une exception personalisé pour savoir ou se situe le probleme
      Exemple

      try
      { // le code supcetible de generer cette erreur}
      
      catch (ExceptionPersonalise e)
      { e.printStackTrace;}
      
      // e.printStackTrace; te permet de savoir quel type d'erreur et a quelle ligne precisement
      


      por ce quiconcerne les exceptions personnalisées, tu prux faire un tour sur le cours de Cysboy precisement le chapitre des exception: ici
      • Partager sur Facebook
      • Partager sur Twitter
        22 juillet 2012 à 20:14:56

        tout d'abord merci de ta réponse et merci de bien vouloir m'aider!!

        Je pense avoir trouvé où ça bloquait dans le code mais je ne comprend tjrs pas pourquoi. néanmoins je pense que ça a un lien avec pdf creator..

        voici l'erreur complète :

        run:
        log4j:WARN No appenders could be found for logger (com.*.*.gui.MainForm).
        log4j:WARN Please initialize the log4j system properly.
        License about to read: ...
        License is available: C:\...\*....key
        Exception in thread "Thread-8" java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.ComThread
        at idainfront.pdfcreator4j.PdfCreatorApi.<init>(PdfCreatorApi.java:50)
        at com.*.*.converter.plugins.PdfCreatorConverter.isReady(PdfCreatorConverter.java:103)
        at com.*.*.converter.plugins.PdfCreatorIsAvalaible.command(PdfCreatorIsAvalaible.java:25)
        at com.*.*.util.Timeout$TimeoutThread.run(Timeout.java:15)
        at java.lang.Thread.run(Thread.java:662)


        et voici la où je pense que ça bloque dans le code, au niveau de la fonction initMTA():

        public PdfCreatorApi()
            {
                ComThread.InitMTA(true);
                mPdfCreator = new ActiveXComponent("PDFCreator.clsPDFCreator");
                mEventHandler = new EventHandler(this);
                mDispatcher = new DispatchEvents(mPdfCreator, mEventHandler);
            }
        


        voici en dessous comment se présente la classe "comThread" où se trouve cette fameuse fonction initMTA(); :
        package com.jacob.com;
        
        /**
         * Represents a COM level thread This is an abstract class because all the
         * methods are static and no instances are ever created.
         */
        public abstract class ComThread {
        	private static final int MTA = 0x0;
        
        	private static final int STA = 0x2;
        
        	/**
        	 * Comment for <code>haveSTA</code>
        	 */
        	public static boolean haveSTA = false;
        
        	/**
        	 * Comment for <code>mainSTA</code>
        	 */
        	public static MainSTA mainSTA = null;
        
        	/**
        	 * Initialize the current java thread to be part of the Multi-threaded COM
        	 * Apartment
        	 */
        	public static synchronized void InitMTA() {
        		InitMTA(false);
        	}
        
        	/**
        	 * Initialize the current java thread to be an STA
        	 */
        	public static synchronized void InitSTA() {
        		InitSTA(false);
        	}
        
        	/**
        	 * Initialize the current java thread to be part of the Multi-threaded COM
        	 * Apartment, if createMainSTA is true, create a separate MainSTA thread
        	 * that will house all Apartment Threaded components
        	 * 
        	 * @param createMainSTA
        	 */
        	public static synchronized void InitMTA(boolean createMainSTA) {
        		Init(createMainSTA, MTA);
        	}
        
        	/**
        	 * Initialize the current java thread to be an STA COM Apartment, if
        	 * createMainSTA is true, create a separate MainSTA thread that will house
        	 * all Apartment Threaded components
        	 * 
        	 * @param createMainSTA
        	 */
        	public static synchronized void InitSTA(boolean createMainSTA) {
        		Init(createMainSTA, STA);
        	}
        
        	/**
        	 * 
        	 */
        	public static synchronized void startMainSTA() {
        		mainSTA = new MainSTA();
        		haveSTA = true;
        	}
        
        	/**
        	 * 
        	 */
        	public static synchronized void quitMainSTA() {
        		if (mainSTA != null)
        			mainSTA.quit();
        	}
        
        	/**
        	 * Initialize the current java thread to be part of the MTA/STA COM
        	 * Apartment
        	 * 
        	 * @param createMainSTA
        	 * @param mode
        	 */
        	public static synchronized void Init(boolean createMainSTA, int mode) {
        		if (createMainSTA && !haveSTA) {
        			// if the current thread is going to be in the MTA and there
        			// is no STA thread yet, then create a main STA thread
        			// to avoid COM creating its own
        			startMainSTA();
        		}
        		if (JacobObject.isDebugEnabled()) {
        			JacobObject.debug("ComThread: before Init: " + mode);
        		}
        		doCoInitialize(mode);
        		if (JacobObject.isDebugEnabled()) {
        			JacobObject.debug("ComThread: after Init: " + mode);
        		}
        		ROT.addThread();
        		if (JacobObject.isDebugEnabled()) {
        			JacobObject.debug("ComThread: after ROT.addThread: " + mode);
        		}
        	}
        
        	/**
        	 * Call CoUninitialize to release this java thread from COM
        	 */
        	public static synchronized void Release() {
        		if (JacobObject.isDebugEnabled()) {
        			JacobObject.debug("ComThread: before clearObjects");
        		}
        		ROT.clearObjects();
        		if (JacobObject.isDebugEnabled()) {
        			JacobObject.debug("ComThread: before UnInit");
        		}
        		doCoUninitialize();
        		if (JacobObject.isDebugEnabled()) {
        			JacobObject.debug("ComThread: after UnInit");
        		}
        	}
        
        	/**
        	 * @deprecated the java model leave the responsibility of clearing up
        	 *             objects to the Garbage Collector. Our programming model
        	 *             should not require that the user specifically remove object
        	 *             from the thread.
        	 * 
        	 * This will remove an object from the ROT
        	 * @param o
        	 */
        	@Deprecated
        	public static synchronized void RemoveObject(JacobObject o) {
        		ROT.removeObject(o);
        	}
        
        	/**
        	 * @param threadModel
        	 */
        	public static native void doCoInitialize(int threadModel);
        
        	/**
        	 * 
        	 */
        	public static native void doCoUninitialize();
        
        	/**
        	 * load the Jacob DLL. We do this in case COMThread is called before any
        	 * other reference to one of the JacboObject subclasses is made.
        	 */
        	static {
        		LibraryLoader.loadJacobLibrary();
        	}
        }
        


        Selon toi, est-ce un soucis dans le code ou plutôt un soucis de compatibilité quelconque?
        En espérant que tout ceci pourra t'éclairer, et merci encore!
        • Partager sur Facebook
        • Partager sur Twitter
          24 juillet 2012 à 19:54:22

          Ja remarque que tu attribue comme type MainSTA a ta variable mainSTA :

          /**
           * Comment for <code>mainSTA</code>
           */
          	public static MainSTA mainSTA = null;
          

          ce qui sous entend que cet type est deja defini quelque part.
          si si cette classe n'est pas native a JAVA, alors il faut penser a la definir .
          sinon, fai atention a tes initialisations




          • Partager sur Facebook
          • Partager sur Twitter
            25 juillet 2012 à 15:07:50

            Tout d'abord merci de ta réponse!!

            oui cette classe est bien définie, mais comment je peux faire gaffe aux initialisations?

            Tu sais en fait je pense que mon soucis vient de PDF creator, car au debuggage, c'est arrivé à la fonction "public PdfCreatorApi()" que les erreurs sortent ...

            J'ai comme l'impression qu'il ne détecte pas que j'ai bien installer PDF creator....

            Car en effet, le même code fonctionne sur le pc d'un collègue et les mêmes erreur que moi ne s'affichent plus depuis qu'il a effectivement installer PDF creator...

            Voila j'espère ne pas avoir été trop brouillon... merci!
            • Partager sur Facebook
            • Partager sur Twitter
              26 juillet 2012 à 15:10:29

              Bah tente de le réinstaller, ça résoudra peut-être le problème ;)

              Sinon pour PDFCreator je ne connais pas mais si c'est pour générer un PDF regarde vers iText, c'est ce que j'ai utilisé dans un projet (et du coup ça enlève la dépendance de PDFCreator qui doit être installé)

              Sinon y'a JacobObject.isDebugEnabled() qu'il serait pas mal de mettre à true pour avoir plus de détails sur ce qu'il se passe et où ça bloque exactement ^^
              • Partager sur Facebook
              • Partager sur Twitter
                27 juillet 2012 à 14:40:59

                Merci bcp de vous être intéressé à mon problème et d'avoir tenté de m'aider orion78r et TechNov !

                @orion78fr: Oui je l'avais réinstaller mais rien à y faire!

                en fait il fallait mettre le fichier jacob-1.14.3-x**.dll dans le dossier "bin" du dossier "jre" correspondant au JDK que je possède
                et PADAM !!! Ça marche!! plus d'erreur!

                Bon bah ya plus qu'à marquer le sujet comme RESOLU! :):)

                • Partager sur Facebook
                • Partager sur Twitter

                java.lang.NoClassDefFoundError: Could not initialize class

                × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                • Editeur
                • Markdown