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.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With