Announcement Announcement Module
Collapse
No announcement yet.
PropertyFile Loader with placeHolder variable Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PropertyFile Loader with placeHolder variable

    Hi,

    I have a project with configurations like below

    applicationContext-mblox.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"
    	default-lazy-init="true">
    
    	<bean id="mbloxSmsClient" class="com.cmc.mblox.client.impl.MBloxSMSClient">
    		<property name="mbloxClient" ref="mbloxClient" />
    	</bean>
    
    	<bean id="mbloxClient" class="com.mblox.gateway.clientapi.MbloxClient">
    		<constructor-arg index="0" value="${confPath}" />
    		<constructor-arg index="1" value="" />
    		<constructor-arg index="2" value="true" />
    		<constructor-arg index="3" ref="smsListener" />
    	</bean>
    
    	<bean id="smsListener" class="com.cmc.mblox.MBloxSMSListener">
    		<property name="smsChannelManager" ref="smsChannelResultManager" />
    	</bean>
    
    	<bean id="mBloxConfigurer"
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="locations">
    			<list>
    				<value>classpath:mblox.properties</value>
    			</list>
    		</property>
    	</bean>
    
    </beans>
    mblox.properties

    Code:
    # This properties file is used to configure mblox settings.
    # npelleti 07/17/09 Added parm confPath for mBloxClient.
    confPath=conf.dat
    with above code its working good with junits and main method.

    I made above project as jar and added it to another project. There am importing applicationContext-mblox.xml, at that am getting exception like ${confPath} not resolved

  • #2
    Originally posted by bcaramu View Post
    ...
    with above code its working good with junits and main method.

    I made above project as jar and added it to another project. There am importing applicationContext-mblox.xml, at that am getting exception like ${confPath} not resolved
    Possible problems:
    • you don't put 'mblox.properties' to the classpath during working with 'applicationContext-mblox.xml' as a part of another project;
    • you have class loaders problem that prevents your properties file from being accessible via Class.getResourceAsStream()/ClassLoader.getResourceAsStream();
    • another PPC with the same placeholder prefix & suffix is defined at another xml that is used in conjunction with the 'applicationContext-mblox.xml';

    The easiest way to find out the problem is to set a breakpoint at the org.springframework.core.io.support.PropertiesLoad erSupport.loadProperties()
    and debug 'location.getInputStream()' processing.

    Comment


    • #3
      Am not putting mblox.properties as it was in jar file


      Originally posted by denis.zhdanov View Post
      Possible problems:
      • you don't put 'mblox.properties' to the classpath during working with 'applicationContext-mblox.xml' as a part of another project;
      • you have class loaders problem that prevents your properties file from being accessible via Class.getResourceAsStream()/ClassLoader.getResourceAsStream();
      • another PPC with the same placeholder prefix & suffix is defined at another xml that is used in conjunction with the 'applicationContext-mblox.xml';

      The easiest way to find out the problem is to set a breakpoint at the org.springframework.core.io.support.PropertiesLoad erSupport.loadProperties()
      and debug 'location.getInputStream()' processing.

      Comment

      Working...
      X