0

im working on a script, that should generate excel files for every cost center in my company. Because its my first time using apache poi i started with a regular java application, but now i want to change to JavaFX where i can drop the file with drag and drop. The regular java application works perfect but now when i want to use JavaFX i get a ClassNotFoundException for a class in the Apache Poi Jar. i use the exact same dependencies like i used in the regular java application i dont even get a real error just this:

Model created
Init
DROOOOOP
SETUPPPPPPP
Java Messsge:org/apache/poi/ss/usermodel/Sheet

The first three are all Outprints but the last is the error message. i debugged throught the whole project and it stops in the Throwable class and ther i see this:Variables from the debuger

First i thought its the same issue as here: NoClassDefFoundError org/apache/poi/ss/usermodel/Workbook

but all my jars have the same version 4.1.2 Here is my pom-File <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>
    <groupId>com.mycompany</groupId>
    <artifactId>RFCHelper</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <excludes>
                        <exclude>module-info.java</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <mainClass>com.mycompany.rfchelper.App</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <!-- Default configuration for running -->
                        <!-- Usage: mvn clean javafx:run -->
                        <id>default-cli</id>
                    </execution>
                    <execution>
                        <!-- Configuration for manual attach debugging -->
                        <!-- Usage: mvn clean javafx:run@debug -->
                        <id>debug</id>
                        <configuration>
                            <options>
                                <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
                            </options>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Configuration for automatic IDE debugging -->
                        <id>ide-debug</id>
                        <configuration>
                            <options>
                                <option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
                            </options>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- Configuration for automatic IDE profiling -->
                        <id>ide-profile</id>
                        <configuration>
                            <options>
                                <option>${profiler.jvmargs.arg1}</option>
                                <option>${profiler.jvmargs.arg2}</option>
                                <option>${profiler.jvmargs.arg3}</option>
                                <option>${profiler.jvmargs.arg4}</option>
                                <option>${profiler.jvmargs.arg5}</option>
                            </options>
                        </configuration>
                    </execution>
                </executions>
            </plugin>                
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>openjfx</id>
            <activation>
                <jdk>[11,)</jdk>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.openjfx</groupId>
                    <artifactId>javafx-controls</artifactId>
                    <version>11</version>
                </dependency>
                <dependency>
                    <groupId>org.openjfx</groupId>
                    <artifactId>javafx-fxml</artifactId>
                    <version>11</version>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
    <dependencies>
    
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>ooxml-schemas</artifactId>
            <version>1.4</version>
        </dependency>



        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20230227</version>
        </dependency>
    </dependencies>
</project>

and my jar-files:Jar-Files

I also tried adding the shade-plugin as descriped here: NoClassDefFoundError on Maven dependency

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.4.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

this also dosent work so i tried this solution:Java ClassNotFoundException with maven dependency also with no success so i hope that someone here can help me. im pretty a newbee in JavaFX if you need any further code like the model the controller or the App.java just ask: THANK YOU SO MUCH

7
  • 1
    You need to find the complete stack trace. If an exception is being thrown and you're not seeing a stack trace, it's almost certainly because somewhere in your code you have a try-catch block that suppresses it. Are you running this in an IDE? Or are you trying to run from a jar file? Commented May 3, 2023 at 13:53
  • i'm runnning it in netbeans. i also thoought this is the issue, but when i add outprints to my catch blocks i never see them in my output. Commented May 3, 2023 at 14:26
  • Please, no images of code/data/errors. Commented May 3, 2023 at 17:27
  • 1
    Your poi versions don't match, for example; also consider a more recent version. Commented May 3, 2023 at 17:33
  • 2
    Your build with the explicit module-info exclusion is strange. JavaFX is made to execute as a modular library (either via adding a module-info or VM args). Though shaded jars can sometimes be made to work, it is not supported. I don't think POI is modular, so probably best to make your app non-modular and either use a JDK that includes the JavaFX modules (e.g. Liberica "Full JDK") or add the JavaFX modules from the JavaFX SDK via VM arguments documented at openjfx.io: JavaFX and NetBeans, non-modular with Maven. Get the openjfx HelloWorld app working. Commented May 4, 2023 at 3:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.