我的Sub模块项目真的很奇怪。
项目结构如下所示。
TestPomProject
* DAOProject
* SchemaProject
* EJBProject
* EarProject
如果我在这些项目上执行“mvn javadoc:javadoc”命令(DAOProject,SchemaProject,EarProject)它运行正常并成功完成。
但是当我在EJBProject上执行此命令时,它给了我以下异常,并且EJBProject中没有任何不同的javadoc条目,它们都具有相同的javadoc插件条目........
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EJBProject 3.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-javadoc-plugin:2.8:javadoc (default-cli) @ EJBProject >>>
[INFO]
[INFO] <<< maven-javadoc-plugin:2.8:javadoc (default-cli) @ EJBProject <<<
[INFO]
[INFO] --- maven-javadoc-plugin:2.8:javadoc (default-cli) @ EJBProject ---
[INFO]
..............
.................
Standard Doclet version 1.6.0_29
Building tree for all the packages and classes
...............
.................
44 warnings
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.547s
[INFO] Finished at: Wed Dec 21 16:47:57 PST 2011
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.8:javadoc (default-cli) on project EJBProject : An error has occurred in JavaDocs report generation:
[ERROR] Exit code: 1 - C:\jboss\workspace\TestPomProject\EJBProject\src\main\java\com\SampleEJB.java:6: package javax.ejb does not exist
[ERROR] import javax.ejb.Local;
[ERROR] ^
[ERROR] C:\jboss\workspace\TestPomProject\EJBProject\src\main\java\com\SampleEJB.java:7: package javax.ejb does not exist
[ERROR] import javax.ejb.Remote;
[ERROR] ^
[ERROR] \jboss\workspace\TestPomProject\EJBProject\src\main\java\com\SampleEJB.java:8: package javax.ejb does not exist
[ERROR] import javax.ejb.SessionContext;
[ERROR] ^
........................
...................
[ERROR] @EJB
[ERROR] ^
[ERROR] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc
[ERROR] at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46)
[ERROR] at com.sun.tools.doclets.internal.toolkit.util.Util.isDeprecated(Util.java:811)
[ERROR] at com.sun.tools.doclets.formats.html.ClassWriterImpl.writeClassDeprecationInfo(ClassWriterImpl.java:242)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildDeprecationInfo(ClassBuilder.java:229)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildClassDoc(ClassBuilder.java:124)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
[ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:108)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:155)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:164)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:106)
[ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64)
[ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42)
[ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:597)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269)
[ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143)
[ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340)
[ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:128)
[ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:41)
[ERROR] at com.sun.tools.javadoc.Main.main(Main.java:31)
[ERROR] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc
_________________________________________________________________________________________________________
有趣的是mvn install命令不会抱怨我关于IMPORT语句的任何内容并且它构建成功!!!!
请告诉我这里有什么问题?发生了什么事?
答案 0 :(得分:1)
此问题的正确解决方案是使用JDK 1.7版本,这是JDK 1.6版本的问题。它已在Jdk 1.7中修复。
答案 1 :(得分:0)
真正的问题是进一步下降(见堆栈跟踪)
java.lang.ClassCastException:com.sun.tools.javadoc.ClassDocImpl 无法转换为com.sun.javadoc.AnnotationTypeDoc
请参阅Why am I getting a ClassCastException when generating javadocs?了解解决方案。