3

I am inheriting a project and (per the other developer's instructions) overwrote my Tomcat's version of catalina.bat with his (he's using the same version). I then tried to restart Tomcat and got an exception relating to the commons-logging.jar, which is a Tomcat dependency.

After a lot of frustration, I just downloaded a different version of Tomcat and tried running it right out of the box (no configuration)...and I got the same error!

So I asked this question on SO a few days ago. The consensus was that my classpath had somehow gotten "dirty", and now I'm wondering if the catalina.bat file I blindly copied over somehow set environmental variables that is affecting Tomcat's ability to bootstrap - even across versions.

I know this question is similar to the other one I asked but is different. Whereas my first question was "what's wrong here" and was much more general, what I am asking now (although related), is more specific and is about catalina.bat and how it relates to Windows 7 environment variables.

Thanks for any help here.

Edit: I see this question already has a closevote for being "off topic". My argument against that is as follows: SO is a programming Q&A site for asking specific questions related to code and programming. catalina.bat is a script, which is code, and this question concerns itself with a potential bug/defect in a script that I am using.

Edit: Found the line in catalina.bat where the error message is coming from (and, likewise, where Tomcat startup is dying from). It's is line (from 7.0.19's unchanged version):

%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%

I was able to place echos in the script and obtained the following values:

JAVA_OPTS = -Djava.util.logging.config.file="C:\Program Files\Apache\apache-to
mcat-7.0.19\conf\logging.properties" -Djava.util.logging.manager=org.apache.juli
.ClassLoaderLogManager
CATALINA_OPTS =
DEBUG_OPTS =
JAVA_ENDORSED_DIRS = C:\Program Files\Apache\apache-tomcat-7.0.19\endorsed
CLASSPATH = C:\Program Files\Apache\apache-tomcat-7.0.19\bin\bootstrap.jar
CATALINA_BASE = C:\Program Files\Apache\apache-tomcat-7.0.19
CATALINA_HOME = C:\Program Files\Apache\apache-tomcat-7.0.19
CATALINA_TMPDIR = C:\Program Files\Apache\apache-tomcat-7.0.19\temp
MAINCLASS is org.apache.catalina.startup.Bootstrap
CMD_LINE_ARGS =
ACTION = start

JAVA_OPTS has my full attention with the logging.properties and ClassLoaderLogManager entries. Does this mean anything to anyone?!?

Community
  • 1
  • 1
IAmYourFaja
  • 55,468
  • 181
  • 466
  • 756

2 Answers2

2

you can set the environment variables in any batch file, including catalina.bat. But these changes stay only in the current running environment and will not affect all the other running environments.

For CLASSPATH, look in the corresponding batch files if you see something like set CLASSPATH= which give you information about the classpath being set.

belgther
  • 2,544
  • 17
  • 15
  • if you only have `set CLASSPATH=` and nothing else at that line, it means that your catalina.bat indeed destroys your entire CLASSPATH. Try to comment it (`rem set CLASSPATH=`) and check if it fixed the problem. – belgther Mar 14 '12 at 13:50
  • Thanks belgther - please see my 2nd edit which includes the echoed values of EXECJAVA command. – IAmYourFaja Mar 14 '12 at 18:50
1

Looking at previous answers in your other question, it doesn't appear that the consensus was that the classpath had gotten 'dirty'. But that rather the Tomcat setup itself had become dirty by being a mix of several different Tomcat versions.

Note that Tomcat, by default, does not use values from your CLASSPATH, precisely to avoid problems like you outlined. You should examine the file your coworker gave you to see what exactly he changed in it (considering you can script out pretty much anything in a BAT file it's almost impossible to pin down the exact problem based on the description you've given).

Good luck.

Perception
  • 79,279
  • 19
  • 185
  • 195
  • Thanks for the response Perception, but what I am saying is that I am experiencing the same problem even **after** I download a different version of Tomcat and run `startup.bat` right out of the box (zero changes). Env vars are the only thing I can think of as the culprits here. I think the `catalina.bat` I was given by my co-worker messed with my env vars, and now *no* version of Tomcat will work. I am simply asking if this is a crazy notion or not. Thanks again for your feedback though! – IAmYourFaja Mar 14 '12 at 12:51
  • Ah, I thought you downloaded a newer version of Tomcat and it worked, my mistake. But, have you checked your environment variables? Check for all the `CATALINA` ones, and particularly, check if `JAVA_OPTS` is set. – Perception Mar 14 '12 at 14:16
  • I'm not seeing JAVA_OPTS, just JAVA_HOME – IAmYourFaja Mar 14 '12 at 14:28
  • Try these two things - First thing, nset your classpath completely. You can save it off somewhere if you really need too, then restore it after the test. Second thing, verify there are no third party libraries in the JRE ext directory. Then try starting Tomcat. – Perception Mar 14 '12 at 16:22
  • Thanks perception - I tried both suggestions to no avail. Please see my 2nd edit which contains echoed values of the EXECJAVA command's options. – IAmYourFaja Mar 14 '12 at 18:51