Tuesday, October 17, 2006

CLASSPATH

The jwsc ant task internally invokes Javadoc (probably to look at the JSR 181 tags). This spawns the following error:


An error has occurred while invoking javadoc to inspect your source
files. This may be due to the fact that $JAVA_HOME/lib/tools.jar does
not seem to be in your system classloader. One common case in which
this happens is when using the 'ant' tool, which uses a special
context classloader to load classes from tools.jar.

This situation elicits what is believed to a javadoc bug in the initial
release of JDK 1.5. Javadoc attempts to use its own context classloader
tools.jar but ignores one that may have already been set, which leads
to some classes being loaded into two different classloaders. The
telltale sign of this problem is a javadoc error message saying that
'languageVersion() must return LanguageVersion - you might see this\nmessage in your process' output.

This will hopefully be fixed in a later release of JDK 1.5; if a new
version of 1.5 has become available, you might be able to solve this\nby simply upgrading to the latest JDK.

Alternatively, you can work around it by simply including
$JAVA_HOME/lib/tools.jar in the java -classpath\nparameter. If you are running ant, you will need to modify the standard\nant script to include tools.jar in the -classpath.


invoking javadoc is done by com.bea.util.jam.internal.javadoc.JavadocRunner, which uses its own classloader:
int result = Main.execute("JAM", spewWriter, spewWriter, spewWriter, getClass().getName(), args);

Sure enough, explicitly adding $JAVA_HOME/lib/tools.jar to $CLASSPATH *does* fix the problem. However, $JAVA_HOME had to be C:/path/lib/tools.jar, not C:\path\lib\tools.jar nor /cygwin/c/path/lib/tools.jar!