3

I am trying to use the external jars JOGL and GlueGen in a Maven poject. The build process works, but when i execute the jar i get this error message:

Exception in thread "main" java.lang.NoClassDefFoundError: com/jogamp/newt/event/KeyListener
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        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 com.jaamsim.ui.GUIFrame.main(GUIFrame.java:1995)
Caused by: java.lang.ClassNotFoundException: com.jogamp.newt.event.KeyListener
        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)
        ... 13 more

This is my pom.xml

<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>JaamSim</groupId>
    <artifactId>JaamSim</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <nd4j.version>1.0.0-beta2</nd4j.version>
        <dl4j.version>1.0.0-beta2</dl4j.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <!-- Build an executable JAR -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.jaamsim.ui.GUIFrame</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <!-- JOGL & Gluegen -->
        <dependency>
            <groupId>org.jogamp.gluegen</groupId>
            <artifactId>gluegen-rt</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.jogamp.jogl</groupId>
            <artifactId>jogl-all-main</artifactId>
            <version>2.3.2</version>
        </dependency>

    </dependencies>
</project>

I also tried building the jar with the shaded plugin and to install JOGL and GlueGen in the local repo, which yielded the same result.

Help to fix this problem is highly apreciated!

SirFartALot
  • 1,215
  • 5
  • 25
lmoh
  • 31
  • 3
  • You may be missing another dependency - on the [`newt` artifact](https://search.maven.org/artifact/org.jogamp.jogl/newt/2.3.2/jar) which defines the `KeyListener` interface. – kidney Jun 27 '19 at 08:58
  • 1
    @kidney No the version, the artifact ids and the group ids are correct except gluegen-rt that should be replaced by gluegen-rt-main, this is what I do in my example: https://jogamp.org/cgit/ardor3d.git/tree/pom.xml#n304 käyrätorvi is right, the dependencies aren't packaged with his program. – gouessej Jul 02 '19 at 09:44

1 Answers1

3

Maven does not package the dependency classes in the final .jar. Some options:

käyrätorvi
  • 371
  • 1
  • 9