This is still a pending question. Hopefully, one day I'll get an answer. Thanks to all who replied.
My question is simple. How do I use ${catalina.home} or ${catalina.base} property inside a Hibernate XML configuration file?
Here's my sample configuration file:
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="hbm2ddl.auto">update</property>
<property name="show_sql">false</property>
<property name="cache.use_second_level_cache">false</property>
<mapping jar="/opt/tomcat/apache-tomcat-5.5.29/webapps/MyApp/WEB-INF/lib/MyHibernateMaps.jar" />
</session-factory>
My current configuration file is okay. But I would like to at least abstract away the tomcat location. Instead of using this:
<mapping jar="/opt/tomcat/apache-tomcat-5.5.29/webapps/MyApp/WEB-INF/lib/MyHibernateMaps.jar" />
I want to convert that to this:
<mapping jar="${catalina.base}/webapps/MyApp/WEB-INF/lib/MyHibernateMaps.jar" />
I tried doing that directly but I just got an error that the jar file is missing or cannot be found. I've Googled but to no avail.
The reason why I need to have a setup like this is because I deploy my apps in three machines. One is for the production. The other one is for development. And the last one is for localhost (at home). These three machines have tomcat installed on three different location.
So everytime I deploy my app I have to modify the line /opt/tomcat/apache-tomcat-5.5.29/ to match the tomcat location on the machine.
Any ideas?
Also, is it preferrable to use catalina.home or catalina.base? I'm only using one tomcat on the localhost. But on the development and production, we have two tomcats (on two different locations of course).
Thanks
By the way, this Hibernate configuration file is used inside a Spring XML config file:
<bean id="appSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="appDataSource"/>
</property>
<property name="configLocation">
<value>${hibernate.config}</value>
</property>
</bean>