0

We are trying to upgrade one of our tomcats from 7.0.77 to 8.5.51 and are running into a bit of an issue.

First a bit of history on our current setup:

Apache Tomcat 7.0.77 on Solaris 11.4.20.4.0, 1 webapps warfile with CSH as the shell. In order to set our JAVA_OPTS and our CATALINA_OPTS we have, in the past, edited the bin/catalina.sh and on line 119 have put the following: . opts.inc This setup works perfectly and continues to do so.

an example opts.inc file:

#!/bin/sh
JAVA_OPTS="-d64 -server -Xms1g <snip>"
CATALINA_OPTS="-Dtomcat.session=${JVMROUTE} -Dcom.sun.management.jmxremote <snip>"

Note: We know this is a bad practice and are NOT doing it anymore on our other bash based tomcats (or this one)

The issue is now that we are upgrading to 8.5.51 and we need to use setenv.sh (seemingly required - from our previous other bash env tomcat upgrades). We tried the old way but the logs/catalina.out shows that the ENV params aren't being applied. This isn't a problem on our other tomcats that are running bash because this works:

Working on bash tomcats (tried in csh and didn't work)

#!/bin/sh
JAVA_OPTS="-Dcom1 -Dcom2 -Dcom3 ... etc" 
CATALINA="-Dcom4 -Dcom5 etc"

This works when manually applied on command line, but not in a script

cat $TOMCAT_DIR/bin/setenv.sh 
#!/usr/bin/csh 
setenv FOO "-Dcom1 -Dcom2 -Dcom3 etc"

run the above as a test in that bin dir: ./setenv.sh (no errors)

env |grep FOO

Nothing.

@ csh prompt

setenv FOO "-Dcom1 -Dcom2 -Dcom3"

env |grep FOO

FOO=-Dcom1 -Dcom2 -Dcom3

I really don't know what to do at this point and would appreciate any and all help.

2 Answers2

0

Running your csh script as ./setenv.sh starts a new shell, sets the environment in that shell, and then when that shell exits, nothing has changed.

To have it change the environment variables in your current shell, assuming it is also csh or tcsh, you would need to run it as source ./setenv.sh so the commands in the script are run in your current shell instead of starting a new one just for the script.

alanc
  • 4,102
  • 21
  • 24
  • Thanks for the reply. I am trying to avoid editing any default Tomcat files. I'd like to do whatever necessary to do things the "Apache Tomcat" way. We were running in csh with 7.0.77 and I'm assuming we can still do so on 8.5.x We'd like to be able to simply set the ENV variables. Honestly, I'm not tied to how it's done as long as we can do it in the setenv.sh (as is required by Apache Tomcat). My assumption was that since we are running csh, we'd set #!/usr/bin/csh whereas in our our other ones we put: #!/usr/bin/sh Thoughts? We don't "source" the file, the Apache Tomcat does. – Trae McCombs May 22 '20 at 02:27
  • Ran out of space so adding another comment: We simply need to set: JAVA_OPTS and CATALINA_OPTS in the setenv.sh (What Apache Tomcat 8.5.x now requires) We are running csh and need to know what we need to do to have it properly attribute the correct ENV variables. – Trae McCombs May 22 '20 at 02:32
0

So the simple solution is this: If you are using csh, just use do the following as you normally would. Don't get caught up in the different shells like I did.

#!/usr/bin/sh

JAVA_OPTS="-Dcom1 -Dcom2 -Dcom3"
CATALINA_OPTS="-Dcom1 -Dcom2 etc"

Had I tried this I could have saved myself some heartache. I did also run into some issues with: JasperListener too but this post fixed that issue: JasperListener? Upgrading from Tomcat 8 to Tomcat 9

Thanks for those that have replied and tried to help.