Storing treecache cluster properties in property file
I'm using Jboss 4, hibenate, spring and treecache. As we have different environments, I would like to store the cluster information in a separated property file and reference to the content from the treecache xml file. I copied the treecache-optimistic.xml
into
\jboss-4.2.0.GA\server\Pearl\conf
a开发者_运维百科nd setup the properties in \jboss-4.2.0.GA\server\Pearl\deploy\properties-service.xml
<attribute name="Properties">
cluster.name=CluterName
cluster.ip=228.1.3.1
cluster.port=48866
</attribute>
I tried to reference it in the treecache-optimistic.xml like this:
<attribute name="ClusterName">${cluster.name}</attribute>
After starting the instance I found via JMX that the name of the cluster is ${cluster.name}
and not the value of the property (ClusterName
). I thought that it can not find the property somehow, but if I change the reference to
<attribute name="ClusterName">${cluster.name:DefaultValue}</attribute>
then I get the following error:
Exception starting filter
ServletRequestScopeFilter
org.springframework.beans.factory.BeanCreationException
: Error creating bean with name 'pearlSessionFactory
' defined in class path resource [hibernate-spring.xml
]: Invocation ofinit
method failed; nested exception isorg.hibernate.cache.CacheException
:javax.management.MalformedObjectNameException
: Invalid character ':' in value part of property
The hibernate properties are configured by spring:
<!-- Database Property -->
<bean id="hibernatePropertiesPearl"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.TreeCacheProvider</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.max_fetch_depth">0</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
I do not know why the treecache-optimistic.xml
can not handle property files :-(
Thanks Zoltan
精彩评论