Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to get Apache Tomcat set up on a Windows Server 2003 machine. If I use the command line version (catalina.bat start) it all works fine, but if I try and use it as a Windows Service it seems to pick up the wrong value for JAVA_HOME - it ignores the environment variable I have set, and it's using the runtime path rather than the JDK path. As a result, my scripts won't compile and the app fails to run.

I'm using pretty old version of everything: Tomcat 4 and Java 1.4.2_19 (it's a legacy app that I don't have time to update at the mo - I just want to get it running, for phase 1).

I have the JDK installed to C:\j2sdk1.4.2_19 and Tomcat installed to C:\Program Files\Apache Software Foundation\Tomcat 4.1. The "Java Virtual Machine" setting for the service is set to C:\j2sdk1.4.2_19\jre\bin\client\jvm.dll. The JAVA_HOME environment variable is set to C:\j2sdk1.4.2_19.

When I try and launch my app, it writes the following error to the log:

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. It is currently set to "C:\j2sdk1.4.2_19\jre"

i.e. it's added an extra "\jre" to the JAVA_HOME that shouldn't be there!

I also wondered whether it might be a registry setting somewhere, but I looked in all the obvious places. HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Procrun 2.0\Tomcat4\Parameters\Java\JavaHome is set to the same as the JAVA_HOME environment variable, as is the JavaHome key under places like JavaSoft\Java Development Kit\1.4 and JavaSoft\Java Runtime Environment\1.4.2_19.

I'm starting to get rather frustrated trying to figure out why it won't work!

share|improve this question

2 Answers 2

up vote 3 down vote accepted

I fixed it in the end by firing up a command window, setting JAVA_HOME appropriately, then running the following scripts from Tomcat's bin directory:

service.bat remove
service.bat install

I don't know how it did it, but that reconfigured the service to use the new value of JAVA_HOME.

share|improve this answer
    
Service.bat is similar to catalina.bat, but has an "create service" section. Like catalina.bat, he tries to find the JAVA_HOME variables, and many others, and like in catalina.bat, u can configure things like memory and so on. I recommend you open service.bat and investigate, because there's some params that will be interesting, like the name of the service. That Second run on service.bat just detectect correclty the Java Variables (if unmodified, catalina y service are quite similar). That's why works. –  Carlos Jan 26 '11 at 8:21

I faced similar issue with Tomcat 6 and Java 6. (I realize that you are talking about Tomcat 4 and Java 1.4)

I would check in appwiz.cpl whether there is JRE 1.6* installed on the machine - because if it is, then JAVA_HOME is not anymore taken from the environment variables but from the registry entry created by JRE 1.6 installation. (In worst case you can edit %TOMCAT_HOME%/bin/catalina.bat and set JAVA_HOME that points to your good JDK there///)

The relevant link could be

https://issues.apache.org/bugzilla/show_bug.cgi?id=41538

share|improve this answer
    
I'm pretty sure that catalina.bat isn't used when running as a service, surely? –  andygeers Jan 18 '11 at 14:10
    
Correct. Catalina.bat isn't used when running as service. –  Carlos Jan 26 '11 at 8:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.