java - Externalising app context and hibernate.properties from the war -


i have externalised config files war, , wondering how resolve absolute location being forced provide in app context in order work.

in web.xml have -

<context-param>     <param-name>contextconfiglocation</param-name>     <param-value>file:c:/program%20files/somedirectory/webappcontext.xml</param-value> </context-param> 

c:/program%20files/somedirectory/webappcontext.xml has entry below:

<import resource="applicationcontext-persistence.xml" /> 

application context - persistence.xml present in same directory webappcontext.xml , has line -

<util:properties id="hibernateproperties" location="hibernate.properties" /> <encryption:encryptable-property-placeholder encryptor="stringencryptor" location="hibernate.properties"/>  

tomcat unable find hibernate.properties file located in same directory. instead forces me define below:

<util:properties id="hibernateproperties" location="file:c:/program%20files/somedirectory/hibernate.properties" /> <encryption:encryptable-property-placeholder encryptor="stringencryptor" location="file:c:/program%20files/somedirectory/hibernate.properties"/> 

is there way around specifying full path? why line in webappcontext.xml work , not lines in applicationcontext-persistence.xml? both similar in nature in referencing files located in same directory.

the webappcontext.xml should reside in war, can contain like:

<bean id="coreproperties" class="org.springframework.beans.factory.config.propertiesfactorybean">     <property name="locations">         <list>             <value>classpath:/properties/*.properties</value>             <value>file:${app.home}/properties/*.properties</value>         </list>     </property> </bean>   <bean class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">     <property name="ignoreunresolvableplaceholders" value="true"/>     <property name="systempropertiesmodename" value="system_properties_mode_override"/>     <property name="ignoreresourcenotfound" value="false"/>      <property name="properties" ref="coreproperties" /> </bean> 

now have pass app.home system property when application starts:

# cat setenv.sh export catalina_opts="$catalina_opts -dapp.home=/home/user/my-app" 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -