Thursday, July 8, 2010

Issue Installing Tomcat as a Service on Windows With Solution

We have spent a few days trying to get Tomcat working on some of our systems.

We set up four virtual machines for testing.

We downloaded Java 1.6 and set the JAVA_HOME to point to Java home and added the bin directory to our classpath.

We downloaded the Tomcat windows installer, but that contained the same issue when we installed Tomcat using the service.bat file.

We first tried to use Tomcat 6 but had other issues. This might be the fix for Tomcat 6 as well, but I haven't tried it yet. I am going to stick with Tomcat 5.527.

We downloaded the zip version of Tomcat 5.527 and unzipped it, and then we deployed are applications to the webapps folder.

We also set our CATALINA_HOME environmental variables to point to Tomcat Home.

When we started Tomcat using the startup.bat file in the bin directory, everything worked as expected. We then typed C:>Tomcat\bin\service.bat install
from our command prompt to install it as a service. It installed fine.

When we ran our application, we kept getting the following error:

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


First off, we are currently using Tomcat 5.0.28 version as a service and it works perfectly. We installed that version on one of our virtual systems and it still worked. This issue is related to the newer versions of Tomcat.

We had our environmental variables set correctly.

After we spent time googling, we noticed that people were saying two things.

They were saying that Tomcat didn't install the msvcr71.dll correctly. That didn't matter to us, and I don't think that is a necessary fix.

The other issue was that we needed to add the tools.jar to our classpath variable.

We added it to the classpath located in our environmental variables. However, only some of our jsp pages compiled while others gave us the same error which didn't make any sense.

We copied the tools.jar file to the Tomcat/common/lib folder and that gave us another error.
The error we received said it couldn't find our jar files which were located in our application/webapps/lib folder. It wasn't loading our specific library within our application. It was giving import not found errors.

We then opened up the tomcat5w.exe file and thought we could change the parameters there. We added the tools.jar file to the classpath in the tomcat5w.exe and that didn't work. That data is set after the service is created.

What did work is editing the service.bat file. We located the CLASSPATH variable in the service.bat file located in the bin directory.

I opened the service.bat file and added the tools.jar file to the the CLASSPATH like so:
set PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%JAVA_HOME%\lib\tools.jar

You then need to uninstall the service if it is still installed by typing from the command prompt in the bin directory: C\tomcat\bin\:>service.bat remove.

After you have uninstalled it, then you should reinstall it. After you reinstall it, start the service, set it to automatic and reboot the computer.

After the computer is reloaded, your application should work with Tomcat.

I hope this helps.

0 comments: