Javadoc generation failed : ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc
Asked Answered
L

6

11

I'm getting the following error when I do

mvn clean deploy -DperformRelease=true

[ERROR] Exit code: 1 - .java:3: package javax.inject does not exist
[ERROR] import javax.inject.Named;
[ERROR] ^
[ERROR] TransactionServiceExternalImpl.java:5: cannot find symbol
[ERROR] symbol: class Named
[ERROR] @Named("transactionServiceExternal")
[ERROR] ^
[ERROR] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc

The POM is this...

<groupId>com.xxx</groupId>
<artifactId>ts-impl/artifactId>
<version>2.4.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
</dependencies>

There is only one class...

import javax.inject.Named;

@Named("transactionServiceExternal")
public class TransactionServiceExternalImpl 
{
}

I get the error with

  • jdk1.5.0_22
  • jdk1.6.0_29
  • jdk1.6.0_43
  • jdk1.6.0_43_32bit

But NOT with...

  • jdk1.7.0_05

Anyone have any ideas?

Notes: Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)


I now know that the reason is that the Maven Javadoc Plugin has changed from 2.9.1 to 2.10. and this is the cause of the problem.

I can see this warning...

[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing.

By setting the following in my pom....

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.9.1</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
     </plugin>

I can fix the version back to the last release.

I will raise a bug with the Maven Javadoc creators.


http://jira.codehaus.org/browse/MJAVADOC-407


On a side note: you can clone the SVN repo for version 2.9.1, update the pom to 2.10.1, do a mvn install to put it in you M2 folder. You should be up and working again, you just need to remove this tmp version when the real release comes out.

Langille answered 22/9, 2014 at 10:25 Comment(0)
A
13

Were having same problems in our projects. Theres a lot of people having this problem so should be a issue regarding maven-javadoc-plugin as maven-javadoc-plugin breaks mvn release:perform stated in first answer. The jira issue is http://jira.codehaus.org/browse/MJAVADOC-408.

Temporal solutions:

  • Execute build with -Dmaven.javadoc.skip=true option
  • Add this property in pom.xml <maven.javadoc.failOnError>false</maven.javadoc.failOnError>
  • Fix maven-javadoc-plugin version to 2.9.1 in your pluginManagement section like
<pluginManagement>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>2.9.1</version>
    </plugin>
  </plugins>
</pluginManagement>

I hope issue is fixed soon.

Update According to Noremac in comments, if you are using release plugin and want to pass arguments to it, the right way to do it is -Darguments="-Dmaven.javadoc.skip=true".

Ill keep the other way in my answer, because this is happening in any maven build that is using javadoc.

Update 2 Also TheConstructor in comments says that 2.10.1 version fix the problem. Im not able to check it out.

Augsburg answered 23/9, 2014 at 14:25 Comment(5)
This is a good summary of options as of 2014-09-23. The only thing I could add is to watch/monitor and vote up jira.codehaus.org/browse/MJAVADOC-408 .. or submit a patch :)Aurore
It's worth noting that -Dmaven.javadoc.skip=true doesn't help if you run mvn release:perform.Semiotics
@MarcelStör this is incorrect. Following typical use of the release plugin, you need to pass arguments into it through something like -Darguments="-Dmaven.javadoc.skip=true". This is what we have done here to get around the problem on our releases. maven.apache.org/maven-release/maven-release-plugin/…Upland
@Noremac, ahh sigh...those forked executions...totally forgot about -Darguments. Thanks.Semiotics
2.10.1 is available and seems to fix this problem.Entablement
M
2

We have the same problem and we temporarily solved this issue by explicitly specify Maven Javadoc Plugin version to 2.9.1

Mongolian answered 24/9, 2014 at 2:50 Comment(0)
S
1

From jira http://jira.codehaus.org/browse/MJAVADOC-407:

build classes (including 3rd-parties dependencies) are not on javadoc classpath anymore

But if I add dependecies to maven-javadoc-plugin:

...
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.cayenne</groupId>
                            <artifactId>cayenne-server</artifactId>
                            <version>3.1B2</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
...

this not help.

Staffordshire answered 23/9, 2014 at 8:44 Comment(0)
H
1

This somewhat worked for me, I had to add the plugin this way since we already had other plugins set for builds. Note I removed our other plugins from the example below:

<build>     
    <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>2.9.1</version>
        </plugin>
    </plugins>
</build>
Hemichordate answered 29/9, 2014 at 16:10 Comment(0)
S
0

add this to parent pom:

<build>
...
<pluginManagement>
  <plugins>
    <plugin>
      <artifactId>maven-javadoc-plugin</artifactId>
      <version>2.9.1</version>
    </plugin>
  </plugins>
</pluginManagement>
...
<build>

solve problem

Staffordshire answered 26/9, 2014 at 8:55 Comment(0)
T
0

Use following plugin to generate java docs.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
    </build>
Tetrahedron answered 21/11, 2014 at 14:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.