Saturday, August 08, 2009

Maven Javadoc workaround: Unable to find package java.lang in classpath or bootclasspath

Seen this before?


Embedded error: Error rendering Maven report: Exit code: 1 - com.sun.tools.javac.util.FatalError: Fatal Error: Unable to find package java.lang in classpath or bootclasspath
at com.sun.tools.javac.comp.MemberEnter.importAll(MemberEnter.java:123)
at com.sun.tools.javac.comp.MemberEnter.visitTopLevel(MemberEnter.java:509)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:446)
at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:387)
at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:819)
at com.sun.tools.javac.code.Symbol.complete(Symbol.java:386)
at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:758)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:451)
at com.sun.tools.javac.comp.Enter.main(Enter.java:429)
at com.sun.tools.javadoc.JavadocEnter.main(JavadocEnter.java:53)
at com.sun.tools.javadoc.JavadocTool.getRootDocImpl(JavadocTool.java:152)
at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:330)
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)
javadoc: error - fatal error


This error has baffled me for the last time. Though I don't understand why the plugin or javadoc would trigger this error, I found a workaround: adding rt.jar to the "bootclasspath":

<bootclasspath>${java.home}/lib/rt.jar</bootclasspath>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6</version>
<configuration>
<minmemory>128m</minmemory>
<maxmemory>512m</maxmemory>
<!-- fix error can't find java.lang package -->
<bootclasspath>${java.home}/lib/rt.jar</bootclasspath>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
Post a Comment