javamavenmodule-info

Adding module-info.java to jar


There is styled-xml-parser-7.2.0.jar package and it doesn't have module-info.java. I generate dependencies

jdeps --ignore-missing-deps --generate-module-info jars jars/styled-xml-parser-7.2.0.jar

Then I compile

javac --patch-module styled.xml.parser=jars/styled-xml-parser-7.2.0.jar jars/styled.xml.parser/module-info.java

Then I add module-info.java to the styled-xml-parser-7.2.0.jar root. However, when I run my mvn clean install project, I get:

cannot access com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider

Contents of module-info.java for styled-xml-parser-7.2.0.jar

module styled.xml.parser {
    exports com.itextpdf.styledxmlparser;
    exports com.itextpdf.styledxmlparser.css;
    exports com.itextpdf.styledxmlparser.css.font;
    exports com.itextpdf.styledxmlparser.css.media;
    exports com.itextpdf.styledxmlparser.css.page;
    exports com.itextpdf.styledxmlparser.css.parse;
    exports com.itextpdf.styledxmlparser.css.parse.syntax;
    exports com.itextpdf.styledxmlparser.css.pseudo;
    exports com.itextpdf.styledxmlparser.css.resolve;
    exports com.itextpdf.styledxmlparser.css.resolve.shorthand;
    exports com.itextpdf.styledxmlparser.css.resolve.shorthand.impl;
    exports com.itextpdf.styledxmlparser.css.selector;
    exports com.itextpdf.styledxmlparser.css.selector.item;
    exports com.itextpdf.styledxmlparser.css.util;
    exports com.itextpdf.styledxmlparser.css.validate;
    exports com.itextpdf.styledxmlparser.css.validate.impl.datatype;
    exports com.itextpdf.styledxmlparser.css.validate.impl.declaration;
    exports com.itextpdf.styledxmlparser.exceptions;
    exports com.itextpdf.styledxmlparser.jsoup;
    exports com.itextpdf.styledxmlparser.jsoup.helper;
    exports com.itextpdf.styledxmlparser.jsoup.internal;
    exports com.itextpdf.styledxmlparser.jsoup.nodes;
    exports com.itextpdf.styledxmlparser.jsoup.parser;
    exports com.itextpdf.styledxmlparser.jsoup.safety;
    exports com.itextpdf.styledxmlparser.jsoup.select;
    exports com.itextpdf.styledxmlparser.logs;
    exports com.itextpdf.styledxmlparser.node;
    exports com.itextpdf.styledxmlparser.node.impl.jsoup;
    exports com.itextpdf.styledxmlparser.node.impl.jsoup.node;
    exports com.itextpdf.styledxmlparser.resolver.font;
    exports com.itextpdf.styledxmlparser.resolver.resource;
    exports com.itextpdf.styledxmlparser.util;
}

In my module-info.java this module is connected

module fezas.telegra {
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.web;
    requires org.controlsfx.controls;
    requires org.apache.commons.io;
    requires java.sql;
    requires html2pdf;
    requires styled.xml.parser;
    requires com.google.zxing;
    requires com.google.zxing.javase;
    requires java.desktop;

    opens fezas.telegra to javafx.graphics, javafx.fxml, javafx.base, javafx.web;
    opens fezas.telegra.controllers to javafx.fxml;
    opens fezas.telegra.entity to javafx.base;
    exports fezas.telegra.controllers;
}

My POM include

<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>styled-xml-parser</artifactId>
    <version>7.2.0</version>
</dependency>

Full trace

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< fezas.telegra:telegra >------------------------
[INFO] Building telegra 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ telegra ---
[INFO] Deleting C:\Users\Fezas\telegra\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ telegra ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 45 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ telegra ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 60 source files to C:\Users\Fezas\telegra\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/controllers/PreviewController.java:[184,23] cannot access com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider
  class file for com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider not found
[ERROR] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/controllers/PreviewController.java:[185,26] cannot access com.itextpdf.kernel.pdf.PdfDocument
  class file for com.itextpdf.kernel.pdf.PdfDocument not found
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.008 s
[INFO] Finished at: 2022-01-26T11:14:53+11:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project telegra: Compilation failure: Compilation failure: 
[ERROR] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/controllers/PreviewController.java:[184,23] cannot access com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider
[ERROR]   class file for com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider not found
[ERROR] /C:/Users/Fezas/telegra/src/main/java/fezas/telegra/controllers/PreviewController.java:[185,26] cannot access com.itextpdf.kernel.pdf.PdfDocument
[ERROR]   class file for com.itextpdf.kernel.pdf.PdfDocument not found
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project telegra: Compilation failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1220)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:187)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Solution

  • Find a solution elsewhere. Just JPackageScriptFX. Jmods from javafx copied to C:/jdk/jmods. Then in bat file:

    set manual_modules=,jdk.crypto.ec,jdk.localedata,javafx.controls,javafx.fxml,javafx.web,java.sql