1

I'm trying to generate a PDF file from XML using Apache FOP, but there is a list of errors that appears when I import the needed packages.

    - The package javax.xml.transform.stream is accessible from more than one module: java.xml, 
     xml.apis
    - The package javax.xml.transform is accessible from more than one module: java.xml, xml.
     apis
    - The package javax.xml.transform is accessible from more than one module: java.xml, xml.
     apis
    - The package javax.xml.transform is accessible from more than one module: java.xml, xml.
     apis
    - The package javax.xml.transform.sax is accessible from more than one module: java.xml, xml.
     apis
    - The package javax.xml.transform is accessible from more than one module: java.xml, xml.
     apis 

I have tried excluding the xml-apis, but it has no effect. Here are thr dependencies:

<dependencies>      
    <dependency>
        <groupId>org.apache.xmlgraphics</groupId>
        <artifactId>fop</artifactId>
        <version>2.6</version>
        <exclusions>
            <exclusion>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

I also read that this problem appears after Java 8. Is there any other solution to this problem that does not include using Java 8?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Hemus
  • 11
  • 1
  • 2

1 Answers1

5

There are already several answers with respect to this error message:

In my case, I use the following exclusions on FOP in the pom file:

<dependency>
    <groupId>org.apache.xmlgraphics</groupId>
    <artifactId>fop</artifactId>
    <version>2.6</version>
    <exclusions>
        <exclusion>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
        </exclusion>
        <exclusion>
            <groupId>java.xml</groupId>
            <artifactId>java.xml</artifactId>
        </exclusion>
    </exclusions>
</dependency>

In my case, the problem occurred within Eclipse. Compiling the system using Maven showed no error messages. I had to update the Eclipse JRE to use the same parameters than Maven. The Eclipse issue is described in the second link above.