• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Configuration Issues with Spring Framework on eclipse

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I am new to Spring Frameworks and am using eclipse IDE to run it. I tried a simple program....which seems to be giving some runtime exceptions when I run it. I shall be really grateful if someone can help me with this.

The config.xml is as follows
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"

<bean id = "firstbean"
class = "InjectionBean"
p:name = "andy"
p:roll = "2121"
p:dept = "Engg"
p:college = "BU"/>


My InjectionBean.java is as follows:
public class InjectionBean {
private String name, roll, dept, college;

public String getName() {
return name;

public void setName(String name) {
this.name = name;

public String getRoll() {
return roll;

public void setRoll(String roll) {
this.roll = roll;

public String getDept() {
return dept;

public void setDept(String dept) {
this.dept = dept;

public String getCollege() {
return college;

public void setCollege(String college) {
this.college = college;

public String toString() {
return "InjectionBean [college=" + college + ", dept=" + dept + ", name="
+ name + ", roll=" + roll + ", toString()=" + super.toString()
+ "]";


And I have a main class(Main.java) that runs this app.

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

public class Main {

* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
XmlBeanFactory beanXml = new XmlBeanFactory(new ClassPathResource("config.xml"));
InjectionBean firstBean = (InjectionBean) beanXml.getBean("firstbean");


When I am running the main class.....as a java application...I am getting the following error/exception.

Jul 8, 2009 6:35:47 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [config.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [config.xml]; nested exception is java.io.FileNotFoundException: class path resource [config.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:349)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at Main.main(Main.java:12)
Caused by: java.io.FileNotFoundException: class path resource [config.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:142)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
... 4 more

I have the commons-logging-1.0.1.jar and spring.jar included in my eclipse project. Any response to get rid of this exception shall be highly appreciated.

Posts: 14691
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
config.xml is not in your classpath. In Eclipse's Run configuration window, go to the Classpath tab, select User entry, and add the folder where config.xml is in.
Ak Rahul
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe. It works fine now. I really appreciate your help.
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!