简体   繁体   中英

How to setup a maven project using fop and java-11?

When I set up a maven project using Apache fop and Java 11 I get warnings and a NullPointerException with maven-compiler-plugin 3.8.0.

The used archetype is working fine with Java 11 to quickly create a desktop application, but only if I do not add the dependency to fop-2.3. (I also wonder how it is possible that the same Java code works fine in mvn test but fails when adding the fop dependency.)

adding

    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>fop</artifactId>
        <version>2.3</version>
    </dependency>

to pom.xml and running with mvn test leads to

[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ checkXslt ---
[WARNING] Can't extract module name from batik-script-1.10.jar: Provider class org.apache.batik.bridge.RhinoInterpreterFactory not in module
[WARNING] Can't extract module name from xalan-2.7.2.jar: Provider class org.apache.bsf.BSFManager not in module

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project checkXslt: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile failed. NullPointerException -> [Help 1]

I wonder if there is a pom.xml using fop dependency and compiling for Java 11.

The nullpointer problem disappears if using the trunk of fop 2.4.0-SNAPSHOT. Going back to 2.3 gives the nullpointer again.

Note that for fop just the dependency has been added to pom.xml. It has not been used yet in the java source code.

The warnings remain.

have you tried

 <dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>fop</artifactId>
            <version>2.3</version>
            <exclusions>
                <exclusion>
                  <groupId>xalan</groupId>
                  <artifactId>serializer</artifactId>          
                </exclusion>
                 <exclusion>
                  <groupId>xalan</groupId>
                  <artifactId>xalan</artifactId>          
                </exclusion>
              </exclusions> 
        </dependency>

I started to set up a project using FOP 2.3; I used a module-info.java containing:

requires fop;
requires avalon.framework.api;
requires avalon.framework.impl;

However, ultimately I had to defer, owing to avalon splitting packages.

That particular problem will be gone when FOP 2.4 is released: https://github.com/apache/fop/commit/bd7d5048785c691e6e3e152af10805f3127b760d

The Xalan problem I had addressed earlier by modularising it myself:- https://github.com/plutext/xalan-j/tree/Plutext_Java11_Repackaged_Docx4j

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM