0

I was wondering if anyone could help out (or if this is even possible). I have a Tomcat 7 server application that should be able to connect to one of several databases (sybase, oracle, mysql), and I have a separate context.xml for each of these. What I am trying to do is have something like this -

.../conf/mysql/localhost/context.xml
.../conf/oracle/localhost/context.xml
.../conf/sybase/localhost/context.xml

and in the server.xml, a way of setting which context.xml it will read in depending on a property set, like this

<Engine defaultHost="localhost" name="${dbType}">
    <Host update:appBase="myApplication"/>
    <remove:Realm/>
</Engine>

where ${dbType} property is located in a separate config file, so in theory by setting it to "oracle", it should use the context.xml located under ../conf/oracle and so on.

Judging from the tutorial from http://tomcat.apache.org/tomcat-7.0-doc/config/context.html, this should be possible, however I am unable to even create an instance of tomcat.

Any help is much appreciated!

KingTravisG
  • 1,316
  • 4
  • 21
  • 43
  • Duplicate of [Tomcat - How to specify properties that can be expanded in server.xml](http://stackoverflow.com/questions/8254543/tomcat-how-to-specify-properties-that-can-be-expanded-in-server-xml) - We use this at where I work and replace tons of variables on the server and context XMLs. – Augusto Feb 11 '14 at 10:01
  • I have successfully gotten it to expand the variables - the trouble I'm having is trying to get it to read in a different context.xml depending on what the variable "${dbType}" is set to – KingTravisG Feb 11 '14 at 10:40
  • Were you able to get this to work ? – user2358826 Dec 18 '17 at 22:26

0 Answers0