9

When running 'maven install', I get the following..

[INFO] [javadoc:javadoc {execution: default}] [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] An error has occurred in JavaDocs report generation:Exit code: 1 - java.lang.NullPointerException at com.sun.tools.doclets.formats.html.PackageUseWriter.generatePackageUse(PackageUseWriter.java:180) at com.sun.tools.doclets.formats.html.PackageUseWriter.generatePackageList(PackageUseWriter.java:124) at com.sun.tools.doclets.formats.html.PackageUseWriter.generatePackageUse(PackageUseWriter.java:110) at com.sun.tools.doclets.formats.html.PackageUseWriter.generatePackageUseFile(PackageUseWriter.java:99) at com.sun.tools.doclets.formats.html.PackageUseWriter.generate(PackageUseWriter.java:78) at com.sun.tools.doclets.formats.html.ClassUseWriter.generate(ClassUseWriter.java:116) at com.sun.tools.doclets.formats.html.HtmlDoclet.generateOtherFiles(HtmlDoclet.java:92) at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:122) at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64) at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42) at com.sun.tools.doclets.standard.Standard.start(Standard.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269) at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143) at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340) at com.sun.tools.javadoc.Start.begin(Start.java:128) at com.sun.tools.javadoc.Main.execute(Main.java:41) at com.sun.tools.javadoc.Main.main(Main.java:31)

Command line was: /home/fsl/jdk1.6.0_12/jre/../bin/javadoc @options @packages @argfile

What am I doing wrong?

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
vpalle
  • 925
  • 3
  • 10
  • 15

5 Answers5

13

Also, if you have:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (default-cli) on project coolproject-api: MavenReportException: Error while creating archive:
[ERROR] Exit code: 1 - javadoc: warning - No source files for package org.coolproject.api
[ERROR] javadoc: warning - No source files for package org.coolproject.api
[ERROR] javadoc: warning - No source files for package org.coolproject.api.listeners
[ERROR] javadoc: error - No public or protected classes found to document.

Java compiler understands sources directories with package-style names like:

coolproject-api/java/org.coolproject.api/

and there are no problems with it, but maven-javadoc-plugin doesn't. So try to change your "physical" packages layout to:

coolproject-api/java/org/coolproject/api/
  • 1
    You would also encounter the error in this answer if you had the correct directory structure for maven but had entries in the pom to declare an alternate ; most likely the declared sourceDirectory is empty as reported. If running a release:perform, this error won't appear until the very end. – dan Dec 08 '16 at 12:18
3

To drop the -use option in maven-javadoc-plugin, use the following configuration:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
                <use>false</use>
                <links>
                    <link>http://java.sun.com/javase/6/docs/api/</link>
                </links>
            </configuration>
        </plugin>
javabrett
  • 7,020
  • 4
  • 51
  • 73
1

From that bug report, this will occur when one has classes in the default package and -use is on. So one solution is to move the classes in the default package into a named package.

Annoying that this bug hasn't been fixed in the javadoc tool distributed with some of the distributions, such as MacOS X Lion.

The bug appears to have been fixed in the openjdk 6, at least from inspection of the source code. Download of that source available at: http://download.java.net/openjdk/jdk6/

Peter N. Steinmetz
  • 1,252
  • 1
  • 15
  • 23
1

There is an unfixed bug that seems to be your problem. From the bug description the known workarounds are either to drop the -use option or use JDK 1.4.2. You're using Java 6 so this may be the case.

The line the NullPointerException is occuring at is:

printHyperLink("", pkg.name(), Util.getPackageName(pkg), true);

So perhaps the problem is occurring because of a typo in your package.html file?

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
0

Look at your environment variables and delete the CLASSPATH variable or add your package path.

javadoc uses the classpath to determine the packages. If the path is not in your variable it will fail.

Nipper
  • 2,350
  • 1
  • 21
  • 30