Announcement Announcement Module
No announcement yet.
Application is failing to load the values from properties file. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

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


    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">

    <bean id="contextSource"
    class=" ontextSource">

    <property name="url" value="${}" />

    I have placed the under classpath..But my application is failed to set the values for url property ...instaed it is setting ${} 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: ${}

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

  • #2
    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:

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

    ApplicationContext context = new ClassPathXmlApplicationContext("/springldap.xml");


    • #3
      Hi Ulsa,


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