On 11/07/2012 16:12, Dave Shevett wrote: > Hi folks, this has come up in the list archives a couple times, but I'm > having a devil of a time getting it working right. > > I'm trying to set a basic set of properties to a deployed app into > Tomcat. Note that this app is being deployed via the tomcat manager (in > fact it's coming from Jenkins), and is in a VHost. > > The problem is I can't find the magic combination to get a couple basic > config params (in this case database connection details) on a per-vhost > basis to be available to the app. > > Right now I have a Spring PPC loading properties: > <bean id="propertyPlaceholderConfigurer" > class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> > > <property name="location"> > <value>classpath:congo.properties</value> > </property> > </bean> > > which loads 'congo.properties' off the classpath. This is working, but I > think Tomcat does not have separate classpaths for each vhost, so I > can't just drop 'congo.properties' into Catalina/hostname/ and have it > referenced for JUST that vhost, is that correct?
Correct. If you really need separate host configs, use split CATALINA_HOST, CATALINA_BASE - see RUNNING.txt in your distribution. Then you can refer to a resource inside Spring: <util:properties id="appProps" location="file:${catalina.base}/conf/app.properties"/> <context:property-placeholder properties-ref="appProps"/> p > I can't build config parameters into the app, since the app needs to be > generic (a .war file). I need to pass parameters into the > applicationContext.xml on a per-vhost basis, with the results here: > > <bean id="com.stonekeep.congo.database.Pool" > class="com.mchange.v2.c3p0.ComboPooledDataSource" > destroy-method="close"> > <property name="driverClass" value="com.mysql.jdbc.Driver"/> > > <property name="testConnectionOnCheckout" value="true"/> > > <property name="jdbcUrl" value="${congo.jdbcurl}" /> > <property name="user" value="${congo.user}" /> > <property name="password" value="${congo.password}" /> > </bean> > > I've thought about using <Context> blocks in the vhost, or in the <Host> > block for the vhost, but I can't figure out the proper mojo to get those > Context parameters into the Spring applicationContext. > > My Spring is weak, I do apologize, but would really appreciate any help. > > Thanks! > > -d > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > -- [key:62590808]
signature.asc
Description: OpenPGP digital signature