简体   繁体   English

Javadoc生成失败:ClassCastException:com.sun.tools.javadoc.ClassDocImpl无法强制转换为com.sun.javadoc.AnnotationTypeDoc

[英]Javadoc generation failed : ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc

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 [错误]退出代码:1 - .java:3:包javax.inject不存在
[ERROR] import javax.inject.Named; [错误]导入javax.inject.Named;
[ERROR] ^ [错误] ^
[ERROR] TransactionServiceExternalImpl.java:5: cannot find symbol [ERROR] TransactionServiceExternalImpl.java:5:找不到符号
[ERROR] symbol: class Named [错误]符号:类命名
[ERROR] @Named("transactionServiceExternal") [错误] @Named(“transactionServiceExternal”)
[ERROR] ^ [错误] ^
[ERROR] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc [错误] java.lang.ClassCastException:com.sun.tools.javadoc.ClassDocImpl无法强制转换为com.sun.javadoc.AnnotationTypeDoc

The POM is this... POM就是这个......

<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.5.0_22
  • jdk1.6.0_29 jdk1.6.0_29
  • jdk1.6.0_43 jdk1.6.0_43
  • jdk1.6.0_43_32bit jdk1.6.0_43_32bit

But NOT with... 但不是......

  • jdk1.7.0_05 jdk1.7.0_05

Anyone have any ideas? 有人有想法么?

Notes: Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000) 备注: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. 我现在知道原因是Maven Javadoc插件已经从2.9.1变为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. [警告] org.apache.maven.plugins的'build.plugins.plugin.version':缺少maven-javadoc-plugin。 [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing. [警告] org.apache.maven.plugins的'build.plugins.plugin.version':缺少maven-deploy-plugin。

By setting the following in my pom.... 通过在我的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. 我将向Maven Javadoc创建者提出一个错误。


http://jira.codehaus.org/browse/MJAVADOC-407 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. 请注意:您可以克隆版本2.9.1的SVN repo,将pom更新为2.10.1,执行mvn安装将其放入您的M2文件夹中。 You should be up and working again, you just need to remove this tmp version when the real release comes out. 你应该重新开始工作,只需要在真正发布时删除这个tmp版本。

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. 很多人都有这个问题所以应该是关于maven-javadoc-plugin的问题,因为maven-javadoc-plugin打破了mvn release:在第一个答案中说明了。 The jira issue is http://jira.codehaus.org/browse/MJAVADOC-408 . jira问题是http://jira.codehaus.org/browse/MJAVADOC-408

Temporal solutions: 时间解决方案:

  • Execute build with -Dmaven.javadoc.skip=true option 使用-Dmaven.javadoc.skip=true选项执行构建
  • Add this property in pom.xml <maven.javadoc.failOnError>false</maven.javadoc.failOnError> 在pom.xml中添加此属性<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
  • Fix maven-javadoc-plugin version to 2.9.1 in your pluginManagement section like 将maven-javadoc-plugin版本修复到你的pluginManagement部分中的2.9.1
 <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". 更新根据Noremac的评论,如果您正在使用发布插件并希望将参数传递给它,正确的方法是-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. 在我的回答中保持另一种方式,因为这发生在使用javadoc的任何maven构建中。

Update 2 Also TheConstructor in comments says that 2.10.1 version fix the problem. 更新2此外,评论中的TheConstructor说2.10.1版本修复了这个问题。 Im not able to check it out. 我无法检查出来。

我们遇到了同样的问题,我们通过明确地将Maven Javadoc插件版本指定为2.9.1来暂时解决了这个问题

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

build classes (including 3rd-parties dependencies) are not on javadoc classpath anymore 构建类(包括第三方依赖项)不再位于javadoc类路径上

But if I add dependecies to maven-javadoc-plugin: 但是,如果我将依赖添加到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. 这没有用。

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>

add this to parent pom: 将此添加到父pom:

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

solve problem 解决问题

Use following plugin to generate java docs. 使用以下插件生成java文档。

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Mojo开发:访问javadoc com.sun.tools.javadoc.Main类 - Mojo development : access to javadoc com.sun.tools.javadoc.Main class 导入com.sun.javadoc无法在Eclipse中解析 - The import com.sun.javadoc cannot be resolved in Eclipse 查找Maven依赖项“ com.sun.javadoc” - Find maven dependency “com.sun.javadoc” 如何在eclipse中导入com.sun.javadoc。*? - How to import com.sun.javadoc.* in eclipse? 取决于Eclipse中tools.jar(Sun JDK)的com.sun.javadoc - Depending on com.sun.javadoc from tools.jar (Sun JDK) in Eclipse 如何在com.sun.javadoc.Taglet中获取{@docroot}的值? - How to get value of {@docroot} in a com.sun.javadoc.Taglet? 导入com.sun.javadoc,与Eclipse和Ant结合使用 - Import com.sun.javadoc, using with Eclipse and Ant com.sun.tools.javadoc.Main.execute在jdk 11中运行Doclet的替代方法是什么? - What is the alternative of com.sun.tools.javadoc.Main.execute to run Doclet in jdk 11? tools.jar 未打包到 maven package 中。 获取 java.lang.NoClassDefFoundError: com/sun/tools/javadoc/Main - tools.jar not packaged into the maven package. Getting java.lang.NoClassDefFoundError: com/sun/tools/javadoc/Main Android javadoc,com.sun.tools.javac.util.FatalError:致命错误:无法在类路径或引导类路径中找到包java.lang - Android javadoc, com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM