'java.lang.NoClassDefFoundError: org/w3c/dom/events/CustomEvent

I am working on a java project using maven for dependency management. I am trying to use the jeuclid package in order to render some more complex math equations like exponents and fractions. The expected outcome is to have a png file be generated with some rendered math.

I include jeuclid in my pom.xml , but when I run my test class (com.dajms3.pdf.JEuclidTest) I get an exception:

java.lang.NoClassDefFoundError: org/w3c/dom/events/CustomEvent

for a dependency of jeuclid (I ran java -cp target\quoteproject-1.3.3-SNAPSHOT-jar-with-dependencies.jar com.dajms3.pdf.JEuclidTest from the command line to make sure it wasn't an IDE issue, and you can see from the pom that I generate my jar file using maven-assembly-single plugin).

I have checked the dependencies in my local .m2 repo (batik-ext-1.7.jar is present and contains the org.w3c.dom.events.CustomEvent class) and the classpath maven is generating (the batik package containing the class is present). I know this is an older package compared to the java version I am compiling the rest of my java project against, but I don't see why that would be causing me these issues.

Attached are the relevant source files:

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>com.david</groupId>
    <artifactId>quoteproject</artifactId>
    <version>1.3.3-SNAPSHOT</version>
    <packaging>jar</packaging>
    <repositories>
        <repository>
            <id>mv-repo</id>
            <name>Local Project Repo</name>
            <url>file:${basedir}/mv-repo</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.qoppa</groupId>
            <artifactId>pdfWriter</artifactId>
            <version>v2021R1.00</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.6.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>5.6.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.6.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sourceforge.jeuclid</groupId>
            <artifactId>jeuclid-core</artifactId>
            <version>3.1.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>batik-ext</artifactId>
            <version>1.7</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>14</maven.compiler.source>
        <maven.compiler.target>14</maven.compiler.target>
    </properties>
    <scm>
        <developerConnection>scm:git:https://github.com/davidmstirn/quoteproject/</developerConnection>
      <tag>quoteproject-1.1</tag>
  </scm>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.0.0-M4</version>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                <archive>
                    <manifest>
                        <mainClass>com.dajms3.gui.AcrosticFrame</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
        </plugins>
    </build>
</project>

JEuclidTest:

package com.dajms3.pdf;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sourceforge.jeuclid.converter.Converter;

/**
 *
 * @author dajms
 */
public class JEuclidTest {
    public static void main(String[] args) {
        File in = new File("test.mml");
        File out = new File("test.png");
        Converter c = net.sourceforge.jeuclid.converter.Converter.getInstance();
        try {
            c.convert(in, out, "image/png");
        } catch (IOException ex) {
            Logger.getLogger(test1.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

math.mml (used in test function)

<math xmlns="http://www.w3.org/1998/Math/MathML">
 <mrow>
   <msup>
     <mfenced>
       <mrow>
         <mi>a</mi>
         <mo>+</mo>
         <mi>b</mi>
       </mrow>
     </mfenced>
     <mn>2</mn>
   </msup>
 </mrow> 
</math>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source