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

Maven Java Discussion :

(maven 3,eclipse) substance : ClassNotFoundException


Sujet :

Maven Java

  1. #1
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2006
    Messages
    958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2006
    Messages : 958
    Points : 213
    Points
    213
    Par défaut (maven 3,eclipse) substance : ClassNotFoundException
    bonjour,

    je suis débutant avec maven et j'ai un petit problème avec maven; j'ai créé d'abord un projet à partir d'eclipse, un projet maven.
    j'ai ajouté une JFRAME swing dans ce projet et ai défini la classe à lancer.
    un petit "maven install" et j'ai pu obtenir ma fenêtre via un "java -jar monappli.jar".

    ensuite, et parce que j'aime bien le gestionnaire de look-and-feel "substance", j'ai essayé de l'inclure dans mon projet, le projet étant disponible sur le repo central de maven.

    et là, impossible de lancer le jar.
    pourtant j'ai un "build successfull" lorsque je lance "maven install" à partir d'eclipse.
    enfin, j'avais, car j'ai fait quelques modifs depuis et maintenant àa ne marche plus.

    voici quelques bouts de code:

    pom.xml
    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
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
     
    	<groupId>olivier_maison</groupId>
    	<artifactId>test_swing_1_swing</artifactId>
    	<version>0.0.1-SNAPSHOT</version>
    	<packaging>jar</packaging>
     
    	<name>test_swing_1_swing</name>
    	<url>http://maven.apache.org</url>
     
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    	</properties>
     
    	<dependencies>
    		<dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>3.8.1</version>
    			<scope>test</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.java.net.substance</groupId>
    			<artifactId>substance</artifactId>
    			<version>6.0</version>
    			<type>jar</type>
    			<scope>runtime</scope>
    		</dependency>
    	</dependencies>
     
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-jar-plugin</artifactId>
    				<configuration>
    					<archive>
    						<manifest>
    							<addClasspath>true</addClasspath>
    							<mainClass>frames.fenetre_hello_world</mainClass>
    						</manifest>
    					</archive>
    				</configuration>
    			</plugin>
     
    			<plugin>
    				<artifactId>maven-assembly-plugin</artifactId>
    				<configuration>
    					<descriptors>
    						<descriptor>src/assembly/dist.xml</descriptor>
    					</descriptors>
    				</configuration>
    			</plugin>
     
     
    		</plugins>
    	</build>
    </project>
    extrait de ma JFRAME
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    public static void main(String[] args) {
     
    		SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin());
    		EventQueue.invokeLater(new Runnable() {
    			public void run() {
    				try {
    					fenetre_hello_world frame = new fenetre_hello_world();
    					frame.setVisible(true);
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    		});
    dist.xml
    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
    <assembly>
      <id>dist</id>
      <formats>
        <format>dir</format>
      </formats>
      <includeBaseDirectory>false</includeBaseDirectory>
      <fileSets>
        <fileSet>
          <directory>target</directory>
          <outputDirectory></outputDirectory>
          <includes>
            <include>*.jar</include>
          </includes>
        </fileSet>
      </fileSets>
      <dependencySets>
        <dependencySet>
          <outputDirectory>/lib</outputDirectory>
          <unpack>false</unpack>
          <scope>runtime</scope>
        </dependencySet>
      </dependencySets>
    </assembly>
    (ça j'ai pas trop compris).

    l'erreur sous eclipse, avec le code précédent:
    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
    [INFO] Scanning for projects...
    [WARNING] 
    [WARNING] Some problems were encountered while building the effective model for olivier_maison:test_swing_1_swing:jar:0.0.1-SNAPSHOT
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 35, column 12
    [WARNING] 
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING] 
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING] 
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building test_swing_1_swing 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ test_swing_1_swing ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ test_swing_1_swing ---
    [INFO] Compiling 2 source files to /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/target/classes
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR : 
    [INFO] -------------------------------------------------------------
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[12,38] package org.pushingpixels.substance.api does not exist
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[13,43] package org.pushingpixels.substance.api.skin does not exist
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,35] cannot find symbol
    symbol  : class BusinessBlackSteelSkin
    location: class frames.fenetre_hello_world
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,2] cannot find symbol
    symbol  : variable SubstanceLookAndFeel
    location: class frames.fenetre_hello_world
    [INFO] 4 errors 
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.324s
    [INFO] Finished at: Sun Jun 05 03:04:30 CEST 2011
    [INFO] Final Memory: 7M/82M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project test_swing_1_swing: Compilation failure: Compilation failure:
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[12,38] package org.pushingpixels.substance.api does not exist
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[13,43] package org.pushingpixels.substance.api.skin does not exist
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,35] cannot find symbol
    [ERROR] symbol  : class BusinessBlackSteelSkin
    [ERROR] location: class frames.fenetre_hello_world
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,2] cannot find symbol
    [ERROR] symbol  : variable SubstanceLookAndFeel
    [ERROR] location: class frames.fenetre_hello_world
    [ERROR] -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
    l'erreur lorsque je lance "java -jar monjar.jar":
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    [olivier@fedora target]$ java -jar test_swing_1_swing-0.0.1-SNAPSHOT.jar 
    Exception in thread "main" java.lang.NoClassDefFoundError: org/pushingpixels/substance/api/SubstanceSkin
    Caused by: java.lang.ClassNotFoundException: org.pushingpixels.substance.api.SubstanceSkin
            at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: frames.fenetre_hello_world. Program will exit.
    [olivier@fedora target]$ java -jar test_swing_1_swing-0.0.1-SNAPSHOT.jar 
    Unable to access jarfile test_swing_1_swing-0.0.1-SNAPSHOT.jar


    un coup de main serait grandement apprécié!

    olivier

  2. #2
    Membre averti Avatar de ZnhaarX
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2011
    Messages
    146
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2011
    Messages : 146
    Points : 307
    Points
    307
    Par défaut
    Salut,

    Bon je vais faire mon possible pour démêler tes erreurs, car il y en a dans le POM et ainsi qu'à la compilation.

    Donc prenons les choses pas à pas

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    [WARNING] Some problems were encountered while building the effective model for olivier_maison:test_swing_1_swing:jar:0.0.1-SNAPSHOT
    [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 35, column 12
    Cette erreur te dit concrètement que tu as oublié de donner un numéro de version à ton plugin. Donc il suffit de mettre une balise
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <version>tonNuméroVersion</version>
    et ce sera bon.

    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[12,38] package org.pushingpixels.substance.api does not exist
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[13,43] package org.pushingpixels.substance.api.skin does not exist
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,35] cannot find symbol
    symbol : class BusinessBlackSteelSkin
    location: class frames.fenetre_hello_world
    [ERROR] /home/olivier/Documents/progs_eclipse_2/test_swing_1_swing/src/main/java/frames/fenetre_hello_world.java:[24,2] cannot find symbol
    symbol : variable SubstanceLookAndFeel
    location: class frames.fenetre_hello_world
    Ça cela signifie que tu as utilisé dans ton code source le mot clé package que tu n'aurais pas du utiliser ici (du moins ça en a l'air). Il nous faudrait le code source avec les package/import pour confirmer ou infirmer cela. Quoiqu'il en soit, si tu as utilisé un package ce n'est pas bon. Quand tu importes une librairie externe dans ton build/classpath (équivalant à ce que fait maven), il faut utiliser import.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Exception in thread "main" java.lang.NoClassDefFoundError: org/pushingpixels/substance/api/SubstanceSkin
    Caused by: java.lang.ClassNotFoundException: org.pushingpixels.substance.api.SubstanceSkin
    ...
    Tout ça t'indique qu'à la compilation, aucune classe n'a été trouvée dans l'API.
    Ton POM est bon (hormis l'erreur de version), donc ça l'a bien importé, mais il se peut que ce soit ce problème de package/import dont j'ai parlé précédemment.
    Si tu as mal importé ton org/pushingpixels/substance/api dans ton code source java, tu ne pourras pas utiliser ses classes et méthodes.

    Bonne chance!
    « War is peace. Freedom is slavery. Ignorance is strength. » - George Orwell

  3. #3
    Membre actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2006
    Messages
    958
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2006
    Messages : 958
    Points : 213
    Points
    213
    Par défaut
    salut ZnhaarX,

    merci pour ta réponse.

    mais je crois que tu te trompes, pour les une des explications que tu as données.

    j'ai depuis réussi à corriger le projet et voilà comment ça marche :

    il faut ajouter les dépendances dans le jar, et le moyen que j'ai trouvé est ce pom:

    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
    	<plugins>
      		<plugin>
    				<groupId>org.apache.maven.plugins</groupId>
    				<artifactId>maven-jar-plugin</artifactId>
    				<configuration>
    					<archive>
    						<manifest>
    							<addClasspath>true</addClasspath>
    							<mainClass>App</mainClass>
    						</manifest>
    					</archive>
    				</configuration>
    			</plugin>
     
    			<plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>App</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
     
     
      	</plugins>
    ça me semble nécessaire.
    tellement que je me demande pourquoi maven n' inclut pas les librairies automatiquement.
    mauvaise configuration de maven / eclipse?

    mais pour le problème de version je crois que tu as raison (je me souviens avoir lu que sans la version maven cherche automatiquement la dernière).

    olivier


    NB : à noter que la bonne instruction pour utiliser substance est :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    try{
    						UIManager.setLookAndFeel("org.pushingpixels.substance.api.skin.SubstanceDustCoffeeLookAndFeel");
    					}catch (Exception e){
    						System.out.println(e);
    					}
     
     
    					App frame = new App();
    					frame.setVisible(true);

Discussions similaires

  1. Réponses: 3
    Dernier message: 20/09/2007, 17h55
  2. [MAVEN 2 & Eclipse] Génération du site
    Par moulette85 dans le forum Maven
    Réponses: 11
    Dernier message: 07/12/2006, 14h53
  3. Maven et eclipse RCP
    Par Aldouille dans le forum Maven
    Réponses: 4
    Dernier message: 23/11/2006, 10h49
  4. Maven pour Eclipse
    Par edwin301 dans le forum Maven
    Réponses: 15
    Dernier message: 02/11/2006, 12h27
  5. [Maven 2][Eclipse] Deux questions pour comprendre!!
    Par Sniper37 dans le forum Maven
    Réponses: 5
    Dernier message: 08/03/2006, 12h18

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