Environment variable for TOMCAT based application

I need to pass an environment variable to my application, working under tomcat8. It's a custom variable, nothing to do with tomcat himself.
I tried to put it into /etc/login.conf, I tried to put it into /etc/rc.local, but it is still not visible by my app. The startup script of tomcat is the default one. I can see the variable under root.
Any advise?
 
Evidently non.
It's impossible to login under this user to the console, so I can just do sudo -u www env, and the variable is not here.
My app under Tomcat does not see it neither.
 
You could try the following:

/etc/rc.conf
Code:
tomcat8_prepend="env VAR=VALUE"

According to rc(), this should be prepended to the command that runs tomcat. env() will set the specified variables then run the command.
 
In general, you can always create a file /etc/rc.conf.d/<servicename> that's automatically sourced, so you can define and export environment variables there for a specific service.
 
Back
Top