Solved

error while loading properties file in applicationcontext

Posted on 2013-12-13
4
2,782 Views
Last Modified: 2013-12-16
Hi,

In the application context file  below am setting an properties file, getting an error as

<!-- set application properties -->
 <bean
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations" value="classpath:src//config//global.properties.template" />
  <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
  <property name="ignoreUnresolvablePlaceholders" value="true" />
  <property name="order" value="1" />
 </bean>

getting error as
[code]
Exception in thread "main" org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [src/config/global.properties.template] cannot be opened because it does not exist
 at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:87)
 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
 at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:669)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:461)
 at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
 at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
 at com.med.consumercare.main.Executor.main(Executor.java:63)
Caused by: java.io.FileNotFoundException: class path resource [src/config/global.properties.template] cannot be opened because it does not exist
 at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
 at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:143)
 at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
 at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
 at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
 at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)

Open in new window

0
Comment
Question by:roy_sanu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 39717387
Caused by: java.io.FileNotFoundException: class path resource [src/config/global.properties.template] cannot be opened because it does not exist
 at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)

Open in new window

Are you saying Spring is wrong about that?
0
 

Author Comment

by:roy_sanu
ID: 39718856
No, i have properties file at the right path, but is it gives me the above error, what might be
the reason. Any other way  it can be set on spring applicationcontext
0
 
LVL 36

Expert Comment

by:mccarl
ID: 39719856
No, i have properties file at the right path
It sounds unlikely that you would have a folder called "src" on your classpath. Can you post a directory structure of your project? If you are using Eclipse (or other IDE) posting a screenshot of the project layout/structure would help!
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 39719867
It sounds unlikely that you would have a folder called "src" on your classpath.
Yes, although the word should probably be 'should' rather than 'would'. Spring seems to be saying that you DO have that as a classloading (resource) path. I'd look for that properties file in part of the binaries (class files/jars) tree and use that path instead

I don't do Spring so don't know how it does its builds, but the generic way with resources is often to take resource files from source locations and see that they end up in 'binary locations' by copying. Perhaps that is not getting done owing to some configuration error
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question