Hi Yuval,

Use as reference the doc for context.xml configuration:

http://tomcat.apache.org/tomcat-8.0-doc/config/context.html

IMO, this is where the context configuration for the WebApp should be use, as for example Resources like database.

There are 2 interesting elements you can use in a context.xml and pass to your WebApp:

<Parameter>

<Environment>

I'm no experienced with that configuration elements, but I would start using them. They have different usage purpose.

The context.xml, is not part of the *webapp* itself, but it's part of the application deployment made by the *server*, and therefore if you are putting sensible information that won't share you can use .properties method.

Regards

Antonio


On 02/11/16 19:27, Yuval Schwartz wrote:
Hello Antonio,

That worked. Thanks.

I added to catalina.properties file.

If I have other API keys and such that I would like to store, should I also
store them there, or does it make more sense to simply create a separate
properties file (since they aren't related to Tomcat)?

Thank you.

On Wed, Nov 2, 2016 at 4:22 PM, Antonio S. Cofiño <cofi...@gmail.com> wrote:

Yuval,

Please take alook atthe second paragraph at Tomcat config doc's:

https://tomcat.apache.org/tomcat-8.0-doc/config/

|You can put your properties on the
|

|$CATALINA_BASE/conf/catalina.properties|

and you can do the variable sustitution in yor configuration file usin

${PropertyName}


for example

<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
                maxActive="100" maxIdle="30" maxWait="10000"
                username="${MyAPP.DBUserName}"
password="${MyApp.DBPassword}" driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost:3306/javatest"/>


instead of using the properties file you can add to the JAVA_OPS or
CATALINA_OPTS enviroment variables

For example in a bash shell

$ export JAVA_OPTS="-DMyAPP.DBUserName=admin -DMyAPP.DBPassword=secret"

You should be condidere that the properties passed to tomcat are dumped
(at least) to the $CATALINA_BAS/logs/catalina.out

Regards

Antonio




On 02/11/16 09:38, Yuval Schwartz wrote:

Tomcat: 8.0.22
Java: jdk1.8.0_05

Hello,

I would like to store credentials that go into the Resource element of my
connection pool, in a properties file. (This is so I can untrack my
properties file when committing to a repo).

How would I go about accessing this properties file in my
META-INF/context.xml file?

What is the best location for this properties file?

Thank you.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to