GeeCON Prague 2014*
The moose likes Tomcat and the fly likes Tomcat not seeing setenv values in Windows 2003 Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat not seeing setenv values in Windows 2003 Server" Watch "Tomcat not seeing setenv values in Windows 2003 Server" New topic
Author

Tomcat not seeing setenv values in Windows 2003 Server

Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Okay, now I'm even more confused. I created setenv.bat in my tomcat/bin dir. It defines JRE_HOME and sets some other options. It works perfectly on Windows XP. But when I try to run it on Windows 2000 or 2003 Server, it fails because setclasspath.bat doesn't see that I've set JRE_HOME.

At first I thought it was because of the bat files calling setlocal, but then I just realized that Windows XP returns Windows_NT for it's OS variable. So it's some other reason that setclasspath doesn't see the variables set in setenv.

Any ideas? TIA.
[ September 30, 2008: Message edited by: Bai Shen ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
How was Tomcat installed on the servers, as a service or as an application?

Which version of Tomcat?

How are you trying to start Tomcat - with startup.bat?

What error message do you get?

Bill
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Okay, it turns out my original assumption was wrong. I've been down quite a few tunnels with this problem.

It's not the setlocal problem that I thought originally. When I got rid of the echo off statements from the bat file, I don't see it throwing the same error.

I'm running Tomcat 6.0.18. I'm starting it as a regular java app using startup.bat

The problem is that I don't get any error message.

On Windows XP, everything works perfectly fine.

On Windows 2000 or Windows 2003 Server, I get the following symptoms.

If I run startup.bat or catalina.bat start from the command prompt I immediately get returned to a blank command prompt with no output.

I removed the echo off statements from catalina.bat and setclasspath.bat After catalina.bat calls setclasspath.bat, there is the following line.

if errorlevel 1 goto end

And that appears to be what's causing the problem, for when I comment it out, Tomcat starts normally. I thought at first that setclasspath was returning an error, but the last line it executes is goto end, which AFAIK, skips over the exit /b 1 line.

So I'm pretty much at a loss to what the problem is.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Are there any errors in the log files 'TOMACAT/logs/*' ??


Regards, Rene Larsen
Dropbox Invite
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Nope. It doesn't get far enough to generate any logs.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

I just saw that you wrote "JRE_HOME" in your first post - you do mean "JAVA_HOME" - right?? because it is JAVA_HOME that you have to set.
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
No, the newer versions of Tomcat let you use a JRE instead of a JDK. So you set JAVA_HOME to "" and JRE_HOME to the location of your JRE.

As I mentioned, it works perfectly fine in Windows XP. There's just something about 2000/2003 that causes it to fail.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

That is not completely correct.

This is what written in "catalina.sh/cataline.bat":
# JAVA_HOME Must point at your Java Development Kit installation.
# Required to run the with the "debug" or "javac" argument.
#
# JRE_HOME Must point at your Java Development Kit installation.
# Defaults to JAVA_HOME if empty.

As I read this, the JRE_HOME can be empty - and if it is empty, it will be set to JAVA_HOME.

In some of the other scripts in the bin folder the JRE_HOME is not used at all - but the JAVA_HOME is.

Have you tried to set JAVA_HOME instead??

On your XP - are you sure that you haven't set JAVA_HOME??
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Ah, okay. Missed the default to part.

And no, I'm explicitly setting JAVA_HOME to "" and JRE_HOME to my JRE in setenv.bat
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Okay, apparently Tomcat doesn't like my setenv.bat I just copied over a virgin install of Tomcat, and after setting JRE_HOME, it started right up. Then I moved my setenv.bat over and it gave me the same problem. I'm not sure why it doesn't like my setting the JRE_HOME in the setenv.bat

The contents of my setenv.bat are as follows.

set JAVA_HOME=
set JRE_HOME=..\..\jre
set JAVA_OPTS=-Xms64m -Xmx256m

Tomcat doesn't seem to have a problem with the sets, as I did them before calling startup, and it worked fine. It's just when they're placed in the setenv.bat file. The only thing I can think of is that the setclasspath.bat file can't see the JRE_HOME setting, but I can't see where it throws an error about it.
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Okay, after some more experimentation, it seems that 2k/2k3 objects to the following line.

set JAVA_HOME=

If I remove that and JAVA_HOME isn't set in the control panel, Tomcat starts right up. However, I can't guarantee that it won't be set on all machines. Anybody know another way to unset JAVA_HOME?

Also, how can I tell the difference between XP/2k/2k3? They all return OS=Windows_NT. For the time being, I was considering putting an if statement on the JAVA_HOME to not run in 2k or 2k3.
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
Okay, I finally figured out what the problem was. When you try to unset an environment variable that wasn't set, Windows 2000 and Windows 2003 Server throw an error, while Windows XP doesn't.

So I just need to change my batch file to check if JAVA_HOME is already set, and if not, don't try to unset it.

Thanks to all those that responded.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
Thank you for reporting the solution. Some future reader is going to go AHA and save a lot of work.
Bai Shen
Ranch Hand

Joined: Sep 24, 2008
Posts: 323
NP. I've been on the other side.

Oh, and for those interested, the following command accomplished it.

if defined JAVA_HOME set JAVA_HOME=
 
GeeCON Prague 2014
 
subject: Tomcat not seeing setenv values in Windows 2003 Server