Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom context.xml file for Tomcat 7 run from NetBeans 7

I am trying to avoid putting passwords inside both the version-controlled files and the packaged files. In order to do this, I can't have a context.xml (which contains my DB information) inside my project.

I am currently deploying my war file with the Tomcat 7.0.35 Manager because it allows to specify the file path to the context.xml file on the server.

This all works fine except that I haven't found a way to do that in development from Netbeans 7.2.1. Therefore when I am trying to run my project in Netbeans, I get the following message

In-place deployment at (...)/trace
(...)/trace/target/trace/META-INF/context.xml (No such file or directory)

Any help for configuring Netbeans or for another way to fulfill my goal would be greatly appreciated.

like image 832
clark Avatar asked Jan 22 '13 17:01

clark


2 Answers

Netbeans requires a META-INF/context.xml for running your war from the IDE. From my observations if the context.xml doesn't exist it creates it.

How about keeping a META-INF/context.xml in your local project workspace, but add the path to your .gitignore (or SCM equivalent) so you don't accidentally commit it?

like image 55
Leif Gruenwoldt Avatar answered Sep 30 '22 13:09

Leif Gruenwoldt


I have found a suitable way to work that out for my specific situation. I have kept the context.xml but used the Apache Ant-style variable substitution which is supported by Tomcat.

There are several ways to define the environment variables but I chose to use the $CATALINA_BASE/conf/catalina.properties file, which seems more mainteanable to me. I also enclose a catalina.example.properties in my source files to document the variables expected by the application.

Hope this helps someone else.

like image 38
clark Avatar answered Sep 30 '22 12:09

clark