Passing Environment Variables to Tomcat have no effect

Answered

I think this is a bug, but I'm posting here first to check that I'm not missing something stupid.

Environment:

  • Intellij IDEA 2016.1.3
  • Apache Tomcat 7.0.67
  • Linux Mint 17.3 'Rosa' 64-bit

I specified CATALINA_BASE, but the default configs are used instead. I then modified the tomcat startup script (~/Applications/apache-tomcat-7.0.67/bin/catalina.sh) to write catalina environment variables to ~/catalina.log, including a test variable 'FOO' (screenshot of IDEA run configurations below), like this:

124: echo "HOME(bin):\t$CATALINA_HOME\nBASE(conf):\t$CATALINA_BASE\nFOO:\t$FOO" > ~/catalina.log

This is the result:

HOME(bin): /home/jakob/Applications/apache-tomcat-7.0.67
BASE(conf): /home/jakob/.IntelliJIdea2016.1/system/tomcat/Unnamed_parent
FOO: 

Am I doing something wrong here or is this not working?

7 comments
Comment actions Permalink

Solved.

So I was missing something stupid; I was running in debug mode. I defined everything for normal Run mode and did not consider that environment variables do not carry over to Debug. So, problem solved by duplicating environment variables from Run to Debug like so:



As a side note, now I'm thinking it would be nice with a checkbox to duplicate environment variables to Debug and Coverage. It could maybe make it more obvious what's going on here.

6
Comment actions Permalink

Can't reproduce. Could be specific to your Linux distribution and/or Tomcat. On my system environment variables are correctly printed from the startup script and from the web application.

Please report a bug at https://youtrack.jetbrains.com/issues/IDEA and attach idea.log (https://intellij-support.jetbrains.com/hc/articles/207241085).

0
Comment actions Permalink

Thank you for fast response.

Will do.

0
Comment actions Permalink

Please also try with the latest 2016.2 release and Tomcat 8.

0
Comment actions Permalink

Hate to state the obvious but you know environmental variables are not system properties right?

Other than that $CATALINA_HOME and $CATALINA_BASE specifically are likely to cause issues as IDEA hosts tomcat from a hidden generated tomcat dir inside your ~/.IntelliJIdea2016.X/system/tomcat dir. I've been meaning to ask for this to be exposed to IDEA as some kind of property as it makes adding the logfiles to the log monitoring so much more difficult (we log to $CATALINA_BASE/log/). So I suspect the tomcat locations may not be what you'd expect.

0
Comment actions Permalink

Well, at least on Windows environment variable is passed to the startup script:

http://i.imgur.com/Ks1hhqX.png
http://i.imgur.com/0ikMH6e.png
http://i.imgur.com/sT1a4B4.png

0
Comment actions Permalink

Yeah this is really stupid. I cant think of a scenario when I would need different setup for debug and run.

0

Please sign in to leave a comment.