Results 1 to 3 of 3

Thread: Application is failing to load the values from properties file.

  1. #1
    Join Date
    Apr 2010
    Posts
    7

    Default Application is failing to load the values from properties file.

    Hi,

    I am using maven for packaging my application.

    My springldap.xml has

    <bean id="propertyPlaceHolderPMSServices"
    class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>classpath:settings.properties</value>
    </list>
    </property>
    </bean>

    <bean id="contextSource"
    class="org.springframework.ldap.core.support.LdapC ontextSource">

    <property name="url" value="${ldap.host}" />
    </bean>

    I have placed the settings.properties under classpath..But my application is failed to set the values for url property ...instaed it is setting ${ldap.host} as value for url.

    My application throws :
    org.springframework.ldap.UncategorizedLdapExceptio n: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: Cannot parse url: ${ldap.host}

    Please advice on the possible mistakes I must be doing at my workspace..

  2. #2
    Join Date
    Jul 2005
    Location
    Helsingborg, Sweden
    Posts
    504

    Default

    A common mistake is to use BeanFactory instead of ApplicationContext, without realizing what BeanFactory doesn't do for you. To quote the Spring reference manual:

    It is important to know that a BeanFactory treats bean post-processors slightly differently than an ApplicationContext. An ApplicationContext will automatically detect any beans which are deployed into it which implement the BeanPostProcessor interface, and register them as post-processors, to be then called appropriately by the factory on bean creation. Nothing else needs to be done other than deploying the post-processor in a similar fashion to any other bean. On the other hand, when using plain BeanFactories, bean post-processors have to manually be explicitly registered [...]
    You probably have code that looks something like this:

    Code:
    Resource res = new ClassPathResource("/springldap.xml");
    BeanFactory context = new XmlBeanFactory(res);
    If you want to have the PropertyPlaceholderConfigurer registered for you, write this instead:

    Code:
    ApplicationContext context = new ClassPathXmlApplicationContext("/springldap.xml");
    Ulrik Sandberg
    Jayway (www.jayway.com)
    Spring LDAP project member

  3. #3
    Join Date
    Apr 2010
    Posts
    7

    Default

    Hi Ulsa,

    Thanks..

    Using ApplicationContext context = new ClassPathXmlApplicationContext("/springldap.xml"); loads all the beans mentioned in the xml.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •