0

I am working in a swing java project, and there's 6 projects

  • calendar
  • controller
  • entity
  • persistence
  • desktop ( Main.java )
  • tools

I'm managing the dependencies using Maven. After package the project, I tried run the jar myproject-desktop.jar and I got the error:

Exception in thread "main" java.lang.NoClassDefFoundError: br/com/cpqd/smqa/tools/logging/SmqaLogging at br.com.cpqd.smqa.desktop.Main.main(Main.java:89)

Java Main code: `

import br.com.cpqd.smqa.tools.logging.SmqaLogging;

public static void main(String[] args) 
    {
        System.setProperty("log4j.configuration","smqaLog4jConfigurationFile.properties");

        try
        {
            defineSystemPaths();
        }
        catch (Throwable t)
        {
            SmqaLogging.fatal(Main.class, "Erro ao definir os diretórios/arquivos do sistema", t);
            System.exit(0);
        }

`

**My Pom.xml declaration **

<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/maven-v4_0_0.xsd">


<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>br.com.cpqd.smqa</groupId>
<artifactId>maven-common</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../../../aplicacoes/maven-common</relativePath>
</parent>

<artifactId>smqa-desktop</artifactId>
<version>1.0-SNAPSHOT</version>
<name>smqa-desktop</name> 
<packaging>jar</packaging>
<description>Componente Desktop-Core para o SMQA</description>


<dependencies>
<!-- Tools -->
<dependency>
<groupId>br.com.cpqd.smqa</groupId>
<artifactId>smqa-tools</artifactId>
<scope>compile</scope>
</dependency>

<!-- Entity -->
<dependency>
<groupId>br.com.cpqd.smqa</groupId>
<artifactId>smqa-entity</artifactId>
<scope>compile</scope>
</dependency>

<!-- Controller -->
<dependency>
<groupId>br.com.cpqd.smqa</groupId>
<artifactId>smqa-controller</artifactId>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>br.com.cpqd.smqa</groupId>
<artifactId>smqa-persistence</artifactId>
<scope>compile</scope>
</dependency>

<!-- JFreeChart -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>${cpqd.smqa.dep.jfreechart.version}</version>
</dependency>

<!-- Para o calculo do Teste de Grubbs -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
<version>2.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.0</version>
</dependency>

<!-- Calendar -->
<dependency>
<groupId>net.sourceforge.jdatepicker</groupId>
<artifactId>jdatepicker</artifactId>
<scope>compile</scope>
</dependency>

<!-- commons email -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.4</version>
</dependency>

<!-- JTerminal with fonts -->
<dependency>
<groupId>com.grahamedgecombe</groupId>
<artifactId>jterminal</artifactId>
<version>${cpqd.smqa.dep.jterminal.version}</version>
<scope>system</scope>
<systemPath>${basedir}/../../../../aplicacoes/libraries/jterminal-fonts.jar</systemPath>
</dependency>

<!-- http://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.2</version>
</dependency>
<!-- http://mvnrepository.com/artifact/commons-collections/commons-collections -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
</dependency>

<!-- http://mvnrepository.com/artifact/com.github.virtuald/curvesapi -->
<dependency>
<groupId>com.github.virtuald</groupId>
<artifactId>curvesapi</artifactId>
<version>1.03</version>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.1</version>
</dependency>

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.4.0</version>
</dependency>
<!-- http://mvnrepository.com/artifact/javax.servlet/servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
</dependency>

<!-- http://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans -->
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.6.0</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.swinglabs/swingx -->
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId>
<version>1.6.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.jgoodies/forms -->
<dependency>
<groupId>com.jgoodies</groupId>
<artifactId>forms</artifactId>
<version>1.0.7</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.vividsolutions/jts -->
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>

</dependencies>

<build>

<pluginManagement>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestEntries>
<Class-Path>../. jterminal-fonts.jar</Class-Path>
</manifestEntries>
<manifest>
<addClasspath>true</addClasspath>
                                <mainClass>br.com.cpqd.smqa.desktop.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
  • Can you post your whole pom.xml file? – Gab Oct 17 '17 at 01:59
  • How did you package it? see https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven – Oleg Oct 17 '17 at 02:00
  • You need to supply some additional configurations to get maven to build and deploy dependent libraries - [for one solution](https://stackoverflow.com/questions/24028921/in-maven-my-dependencies-are-set-up-but-i-get-a-classnotfoundexception-when-i-r/24030042#24030042), this will copy the dependencies (to `lib`) and update the manifest of your application to include the required class-path entry. The other choice is to generate a "fat" jar, but I don't like them as they affect other areas of my design – MadProgrammer Oct 17 '17 at 02:17
  • maybe one of maven dependency not suitable android sdk ver. – reinhard.lee Oct 17 '17 at 02:28

0 Answers0