org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment'

Spring JIRA | Robert Mark Bram | 9 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Also discussed here: http://forum.springframework.org/showthread.php?t=49973 A nested property in Srping config like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="false" /> <property name="location" value="classpath:org/rbram/docpublisher/changeowner/changeowner.properties" /> </bean> <bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close"> <property name="driverClassName"> <value>${${environment}.dataSource.driverClassName}</value> </property> <property name="url"> <value>${${environment}.dataSource.url}</value> </property> <property name="username"> <value>${${environment}.dataSource.username}</value> </property> <property name="password"> <value>${${environment}.dataSource.password}</value> </property> </bean> </beans> With a property file like this: # Environment: local, dev, test, svt or prod. environment=prod prod.dataSource.url=jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=uporac01vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=uporac02vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=uporac03vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=uporac04vip)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORPCORE.cmltd.net.au))) prod.dataSource.username=DOCPUBLISHER_PROD prod.dataSource.password=wescoles07 prod.dataSource.driverClassName=oracle.jdbc.driver.OracleDriver I get this stack trace: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment' at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:252) at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:542) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:516)changeowner.DocumentOwnerChangerSpring(139) - Problem running Document Owner Changer. Rolling back. org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment' at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:252) at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:542) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:516) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:123) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.run(DocumentOwnerChangerSpring.java:115) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.main(DocumentOwnerChangerSpring.java:99) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:123) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.run(DocumentOwnerChangerSpring.java:115) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.main(DocumentOwnerChangerSpring.java:99) But the parseStringValue() method in PropertyPlaceholderConfigurer indicates that the logic should recursively evaluate nested properties. Setting ignoreUnresolvablePlaceholders to true just leaves me with literal i.e. unresolves values ${${environment}.dataSource.driverClassName} etc..

    Spring JIRA | 9 years ago | Robert Mark Bram
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment'
  2. 0

    Also discussed here: http://forum.springframework.org/showthread.php?t=49973 A nested property in Srping config like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders" value="false" /> <property name="location" value="classpath:org/rbram/docpublisher/changeowner/changeowner.properties" /> </bean> <bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close"> <property name="driverClassName"> <value>${${environment}.dataSource.driverClassName}</value> </property> <property name="url"> <value>${${environment}.dataSource.url}</value> </property> <property name="username"> <value>${${environment}.dataSource.username}</value> </property> <property name="password"> <value>${${environment}.dataSource.password}</value> </property> </bean> </beans> With a property file like this: # Environment: local, dev, test, svt or prod. environment=prod prod.dataSource.url=jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=uporac01vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=uporac02vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=uporac03vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=uporac04vip)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORPCORE.cmltd.net.au))) prod.dataSource.username=DOCPUBLISHER_PROD prod.dataSource.password=wescoles07 prod.dataSource.driverClassName=oracle.jdbc.driver.OracleDriver I get this stack trace: org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment' at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:252) at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:542) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:516)changeowner.DocumentOwnerChangerSpring(139) - Problem running Document Owner Changer. Rolling back. org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment' at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:252) at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:542) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:516) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:123) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.run(DocumentOwnerChangerSpring.java:115) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.main(DocumentOwnerChangerSpring.java:99) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:123) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.run(DocumentOwnerChangerSpring.java:115) at org.rbram.docpublisher.changeowner.DocumentOwnerChangerSpring.main(DocumentOwnerChangerSpring.java:99) But the parseStringValue() method in PropertyPlaceholderConfigurer indicates that the logic should recursively evaluate nested properties. Setting ignoreUnresolvablePlaceholders to true just leaves me with literal i.e. unresolves values ${${environment}.dataSource.driverClassName} etc..

    Spring JIRA | 9 years ago | Robert Mark Bram
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment'
  3. 0

    [SPR-4477] PropertyPlaceholderConfigurer - nested placeholders don't work in placeholder keys - Spring JIRA

    spring.io | 1 year ago
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in class path resource : Could not resolve placeholder '${environment'
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Could not resolve properties placeholder, when the properties internally have a placeholders

    Stack Overflow | 5 years ago | Rishi
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'MyQueryBuilder' defined in URL [jar:file:/C:/apache-tomcat-6.0.35/webapps/my-service/WEB-INF/lib/my-app-1.0.2.RC8-SNAPSHOT.jar!/META-INF/spring/config/app-context.xml]: Could not resolve placeholder 'marketId'
  6. 0

    View topic - issue integrating broadleaf, when running standalone • Broadleaf Commerce Discussion Forums

    broadleafcommerce.org | 2 years ago
    org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'blUploadUrlMapping' defined in class path resource [applicationContext-servlet-cms-contentClient.xml]: Could not resolve placeholder 'asset.server.url.prefix'

    15 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.beans.factory.BeanDefinitionStoreException

      Invalid bean definition with name 'dataSource' defined in class path resource [org/rbram/docpublisher/changeowner/changeOwnerPubApplicationContext.xml]: Could not resolve placeholder '${environment'

      at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties()
    2. Spring Beans
      PropertyResourceConfigurer.postProcessBeanFactory
      1. org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:252)
      2. org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
      2 frames
    3. Spring Context
      AbstractApplicationContext.invokeBeanFactoryPostProcessors
      1. org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:542)
      1 frame