I should say "Solved for me" in the Subject line, since there may be multiple reasons why Tomcat with Ant can't find the Java compiler, but here's how I solved the problem. In any case, I think it's a bug in the Tomcat 5.0.3 Windows Service installation.

I was hitting the rather common problem in which I couldn't run any new
JSP pages with Tomcat 5.0.3.  The JSP pages compiled and worked fine
when Tomcat was started from the Windows Command Prompt or the Cygwin
Bash Shell, but failed to compile when run as a Windows Service or
from the "Start Tomcat" menu item.  The message I got (with the jsp
servlet's logVerbosityLevel set to DEBUG) was:

  Unable to find a javac compiler;
  com.sun.tools.javac.Main is not on the classpath.
  Perhaps JAVA_HOME does not point to the JDK

Well, my JAVA_HOME variable indeed pointed to my JDK (C:\j2sdk1.4.2) and was working fine with Ant and Tomcat from the command line.

Here's the trick: Tomcat 5.0.3 needs JAVA_HOME to be defined to the system *during* its installation. (I had defined it after installing Tomcat.) In fact, that's the only time Tomcat 5.0.3 needs any extraneous environment variables when run as a Windows Service. All the extra information it needs is stored in the Windows Registry.

You may need JAVA_HOME defined for other purposes, such as running Ant or Tomcat from the command line, but as a service Tomcat 5.0.3 doesn't appear to need any of JAVA_HOME, ANT_HOME, CATALINA_HOME, nor does it need %JAVA_HOME%/bin or %ANT_HOME%/bin in the PATH. I'm running it just fine now as a service with none of that defined. This problem hit me because I keep the Windows environment variables empty of Java/Ant/Tomcat related stuff and put only what's needed (JAVA_HOME for Ant commands) into my Cygwin Bash Profile ("~/.bash_profile"). I also modify my PATH environment only in Cygwin.

I would think Tomcat could pick up the JDK location from the Windows Registry for JSP compilations as it does for other purposes.

John Neffenger



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to