Christian Stempfle
Christian Stempfle

Reputation: 1

Maven Build Failure (module not found)

i have a question about Mavenbuilds. I wanted to try to make a little javafx testprogram in a mavenbuild in Eclipse IDE, i am using JavaSE 18 and JavaFX 19. so now if i want to run-> Maven build... and set the goal "clean javafx:run" i get this Failure / Error message:

[[1;34mINFO[m] Scanning for projects...
[[1;34mINFO[m] 
[[1;34mINFO[m] [1m---------------------< [0;36morg.openjfx:HauserProgram[0;1m >----------------------[m
[[1;34mINFO[m] [1mBuilding HauserProgram 0.0.1-SNAPSHOT[m
[[1;34mINFO[m] [1m--------------------------------[ jar ]---------------------------------[m
[[1;34mINFO[m] 
[[1;34mINFO[m] [1m--- [0;32mmaven-clean-plugin:2.5:clean[m [1m(default-clean)[m @ [36mHauserProgram[0;1m ---[m
[[1;34mINFO[m] Deleting D:\eclipse-workspace\javafxmav\target
[[1;34mINFO[m] 
[[1;34mINFO[m] [1m>>> [0;32mjavafx-maven-plugin:0.0.8:run[m [1m(default-cli)[0;1m > [0;1mprocess-classes[m @ [36mHauserProgram[0;1m >>>[m
[[1;34mINFO[m] 
[[1;34mINFO[m] [1m--- [0;32mmaven-resources-plugin:2.6:resources[m [1m(default-resources)[m @ [36mHauserProgram[0;1m ---[m
[[1;34mINFO[m] Using 'UTF-8' encoding to copy filtered resources.
[[1;34mINFO[m] Copying 3 resources
[[1;34mINFO[m] 
[[1;34mINFO[m] [1m--- [0;32mmaven-compiler-plugin:3.1:compile[m [1m(default-compile)[m @ [36mHauserProgram[0;1m ---[m
[[1;34mINFO[m] Changes detected - recompiling the module!
[[1;34mINFO[m] Compiling 6 source files to D:\eclipse-workspace\javafxmav\target\classes
[[1;34mINFO[m] -------------------------------------------------------------
[[1;31mERROR[m] COMPILATION ERROR : 
[[1;34mINFO[m] -------------------------------------------------------------
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[6,24] module not found: javafx.base
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[7,24] module not found: javafx.controls
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[8,35] module not found: javafx.fxml
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[9,35] module not found: javafx.graphics
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[11,32] module not found: org.apache.poi.poi
[[1;34mINFO[m] 5 errors 
[[1;34mINFO[m] -------------------------------------------------------------
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;31mBUILD FAILURE[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time:  0.683 s
[[1;34mINFO[m] Finished at: 2022-11-01T12:45:40+01:00
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-compiler-plugin:3.1:compile[m [1m(default-compile)[m on project [36mHauserProgram[m: [1;31mCompilation failure[m: Compilation failure: 
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[6,24] module not found: javafx.base
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[7,24] module not found: javafx.controls
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[8,35] module not found: javafx.fxml
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[9,35] module not found: javafx.graphics
[[1;31mERROR[m] /D:/eclipse-workspace/javafxmav/src/main/java/module-info.java:[11,32] module not found: org.apache.poi.poi
[[1;31mERROR[m] -> [1m[Help 1][m
[[1;31mERROR[m] 
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[[1;31mERROR[m] 
[[1;31mERROR[m] For more information about the errors and possible solutions, please read the following articles:
[[1;31mERROR[m] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

here is my module-info.java:

module HauserProgram {

    exports de.hauserwein;

    requires java.sql;
    requires javafx.base;
    requires javafx.controls;
    requires transitive javafx.fxml;
    requires transitive javafx.graphics;
    requires java.desktop;
    requires org.apache.poi.poi;

    opens de.hauserwein to javafx.fxml, javafx.base, javafx.controls, javafx.graphics;
    

}

and 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.openjfx</groupId>
  <artifactId>HauserProgram</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <maven.compiler.source>18</maven.compiler.source>
 <maven.compiler.target>18</maven.compiler.target>
</properties>
  
  <dependencies>
  
  <dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>8.0.30</version>
  </dependency>
  
  <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>18</version>
  </dependency>
  
  <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>5.2.3</version>
</dependency>

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-to-slf4j</artifactId>
    <version>2.19.0</version>
</dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>5.2.3</version>
</dependency>


  </dependencies>
  
  
    
  <build>
    <plugins>
    <plugin>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>0.0.8</version>
        <configuration>
<mainClass>de.hauserwein/Main.java</mainClass>

</configuration>
    </plugin>
    </plugins>
  </build>

</project>

i tried to add the javafx sdk to the buildpath, tested some different javafx versions 18/19 in the pom.xml, and wanted to add org.openjfx to the module-info.java file...

if i start it with "Run As JavaApplication" it will work, only the export to an runable file wont work.

Upvotes: 0

Views: 2614

Answers (1)

Vinz
Vinz

Reputation: 477

Firstly, make sure you have all the dependencies in your pom:

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>19</version>
        </dependency>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>19</version>
        </dependency>

Then, it sounds like you have your dependencies on the build path in eclipse, rather than the maven project. Run mvn clean install to resolve the dependencies.

(And please don't use <groupId>org.openjfx</groupId> for your artifacts. It causes unnecessary confusion.)

Upvotes: 1

Related Questions