1

I have trying to generate Javadoc using the maven-javadoc-plugin and a custom doclet. I am using JDK 11 and I have implemented the methods of the Doclet interface. However, in one of the methods, I am trying to unmarshal an XML file. I am receiving the following error:

javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.

I have configured the javadoc-plugin as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>3.0.1</version>
    <configuration>
        <doclint>none</doclint>
        <useStandardDocletOptions>false</useStandardDocletOptions>
        <outputDirectory>my.output.directory</outputDirectory>
        <doclet>my.doclet/doclet>
        <docletArtifact>
            <groupId>my.group.id</groupId>
            <artifactId>myartifact</artifactId>
            <version>my.project.version</version>
        </docletArtifact>
        <show>private</show>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.0</version>
        </dependency>
    </dependencies>
</plugin>

What should I do to solve this issue?

Naman
  • 27,789
  • 26
  • 218
  • 353
  • thought of giving this a try, how does [`javax.xml:jaxb-impl:2.3.0`](https://search.maven.org/search?q=g:javax.xml%20AND%20a:jaxb-impl&core=gav) work? – Naman Aug 29 '18 at 14:17
  • In your dependencies, you add jaxb-api from group javax.xml.bind and jaxb implementation from group javax.xml. There is another jaxb-api from group javax.xml (latest version is 2.1) Maybe try this? – Max Aug 29 '18 at 14:38
  • @nullpointer I tried using ` javax.xml jaxb-impl 2.1 javax.xml jaxb-api 2.1 ` and I got the following error: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory – RobotWizard Aug 29 '18 at 15:14
  • Try Adding those dependancies as addtionalDependancies inside - https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html#additionalDependencies – muttonUp Aug 30 '18 at 11:22
  • Tried this as well, didn't work. I am not sure if it is a problem with the javadoc plugin's compatibility with jdk 11 – RobotWizard Aug 30 '18 at 14:02
  • Was this working using JDK 10? – skomisa Aug 30 '18 at 17:28
  • I tested this on jdk 9,10, and 11. Faced the same problem. I fixed the problem by manually adding the classpath at runtime. I don't think it's an optimal solution though – RobotWizard Aug 30 '18 at 17:34

0 Answers0